You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We understand you have a problem and are in a hurry, but please provide us with some info to make it much more likely for your issue to be understood, worked on and resolved quickly.
Sinon version : 1.x.x But confirmed that bug did exist in latest version
Environment :
Example URL :
Other libraries you are using:
What did you expect to happen?
For the function to be be stubbed
What actually happens
Nothing
How to reproduce
Describe with code how to reproduce the faulty behaviour,
//...my module.js constConstructor=require('./constructor')//...just exports a singleton// Need to namespace some of my functions and retain the `this` contextObject.defineProperty(Constructor.prototype,'es',{get: function(){return{method: require('./implementations/doesSomething.js').bind(this)}}});module.exports=Constructor;//...testFile.jsconstConstructor=require('./constructor');constinstance=newConstructor();constsinon=require('sinon');sinon.stub(instance.es,'method',function(){return'hijacked original method'});/* ...some test cases Namespaced functions will not be stubbed, but functions not namespaced (directly defined on the prototype) are stubbed as I would expect*/
or link to code on JSBin or similar
Really long code sample or stacktrace
If you need to provide a dump of a stack trace or
other lengthy material, such as 80 lines of example code,
please stuff it in a `<details>` tag such as this
to make the issue more readable. Thanks.
The text was updated successfully, but these errors were encountered:
namespacing is of course not the issue here. try defining your property without Object.defineProperty: it will still be namespaced, but suddenly it will be stubbable ... Check up on the default values for writeable and configurable
@fatso83 Hey thanks for the suggestion the only problem is that the this context is being lost, I suspected that this would still be a bug because regardless of how I go about namespacing, I would assume Sinon given a path to a function it should be stubbed, no?
As this is a pure usage question and not a bug with sinon I need to close this to keep noise/signal down, but I answered your question on Stack Overflow
1.x.x
But confirmed that bug did exist in latest versionWhat did you expect to happen?
For the function to be be stubbed
What actually happens
Nothing
How to reproduce
Really long code sample or stacktrace
The text was updated successfully, but these errors were encountered: