Comments (5)
This is sound IMO. The concerto module includes test coverage for the usual unstubbed case.
from concerto-tools.
I'm suspecting the error is triggered by this line in the latest Concerto code:
https://github.com/accordproject/concerto/blob/ad309eaf207f8e57f219d30dd574970e694f2e77/lib/modelmanager.js#L641
from concerto-tools.
The new Concerto code seems to make use of https://joshmiller.cc/symbol-hasinstance/
from concerto-tools.
A slightly more specific analysis of what I think the problem is, and a proposed fix.
Why are tests failing:
- the behaviour for
instanceof
in Concerto classes (e.g., forModelManager
) is overridden using the idiom here: https://github.com/accordproject/concerto/blob/ad309eaf207f8e57f219d30dd574970e694f2e77/lib/modelmanager.js#L641
which means it relies on the presence of a_isModelManager
field in the object instance. sinon
'screateStubInstance
method does not call the constructors which means_isModelManager
is not initialised.- as a result tests relying on
instanceof
(e.g., visitors) will always return false
So I believe the support for instanceof
should work as expected when using the library, but will fail in the mocked tests.
I could not find a very official way to mock the constructor through sinon in Stack overflow or in the Sinon documentation. However, the following does work:
Instead of:
let thing = sinon.createStubInstance(ModelManager);
in the tests, use:
let thing = sinon.createStubInstance(ModelManager);
thing._isModelManager = true;
Better suggestions to address this are welcome.
from concerto-tools.
This is sound IMO. The concerto module includes test coverage for the usual unstubbed case.
Thanks so much for the quick feedback. Corresponding fixes are in PR #24
from concerto-tools.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from concerto-tools.