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
Other libraries you are using: Karma, Jasmine, Typescript
What did you expect to happen?
I was hoping to find an easy way to reset all of the stubs in an object returned by createStubInstance().
Given that the sandbox mirrors most methods that of stubs and spies, I was hoping to find a method like sandbox.createStubInstance() that would create an object whose stubbed methods were tied to the sandbox.
What actually happens
sinon.createStubInstance() creates independent stubs for each method, which appear to not be associated with any sandbox to which I have access. There is no analogous sandbox method.
How to reproduce
I've made a utility helper function in my own code to achieve this:
Then, whenever I call sandbox.reset(), all of the stubs in the object created by the call to createStubInstance() will be reset (for behavior and history).
What did you expect to happen?
I was hoping to find an easy way to reset all of the stubs in an object returned by createStubInstance().
Given that the sandbox mirrors most methods that of stubs and spies, I was hoping to find a method like sandbox.createStubInstance() that would create an object whose stubbed methods were tied to the sandbox.
What actually happens
sinon.createStubInstance() creates independent stubs for each method, which appear to not be associated with any sandbox to which I have access. There is no analogous sandbox method.
How to reproduce
I've made a utility helper function in my own code to achieve this:
Then, whenever I call
sandbox.reset()
, all of the stubs in the object created by the call to createStubInstance() will be reset (for behavior and history).This lets me write cleaner code:
whereas before, this code would either have assigned a new sandbox.stub() before every test:
or the afterEach would need to clean up the stub by-name:
What now?
I'm rather a novice with using Sinon; if there's a better way to achieve what I'm trying to do, I'd love to hear about it.
If there's interest in this feature request, I'll spend some time to create a pull request.
Thanks for reading!
The text was updated successfully, but these errors were encountered: