sandbox = sinon.sandbox.create();
sandbox.stub(db, 'query', () => {
return Promise.resolve();
});
sandbox.stub(process, 'exit', () => { });
sandbox.restore();
removes all the stubs.
I want to remove ONE stub so I can restub it. For example the query
stub.
Is this possible? I can't find any information on this.
sandbox = sinon.sandbox.create();
sandbox.stub(db, 'query', () => {
return Promise.resolve();
});
sandbox.stub(process, 'exit', () => { });
sandbox.restore();
removes all the stubs.
I want to remove ONE stub so I can restub it. For example the query
stub.
Is this possible? I can't find any information on this.
Share Improve this question asked Nov 23, 2016 at 10:11 basickarlbasickarl 40.6k69 gold badges238 silver badges355 bronze badges1 Answer
Reset to default 9You can restore single method like this:
db.query.restore();
for your particular case.
Per sinon documentation:
var stub = sinon.stub(object, "method");
Replaces object.method with a stub function. An exception is thrown if the property is not already a function.
The original function can be restored by calling object.method.restore(); (or stub.restore();).
See http://sinonjs/releases/v2.3.6/stubs/