-
-
Notifications
You must be signed in to change notification settings - Fork 780
Closed
Description
Without using sandboxes, there is no quick reversal to sinon.stub(obj). sinon.restore(obj) and/or sinon.stub.restore(obj) could be added to serve as the inverse to sinon.stub(obj). With the walk utility function, this should be pretty easy; with approval, I can add the feature.
An example of its usefulness (using Karma):
const sinon = require('sinon');
const testedLibrary = require('testedLibrary'),
dependency = require('dependency');
describe('testedLibrary', function() {
beforeEach(function() {
sinon.stub(dependency);
});
it('should test something', function() {
// changing dependency.method behavior here automatically changes it in `testedLibrary.js` as well
// since the same object is used in both files
});
afterEach(function() {
// without this you either have to clear the cache or iterate over dependency yourself
sinon.restore(dependency);
});
});
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels