Reputation: 7236
I have this stub in one of my tests:
sinon.stub(service, 'batchNote')
.resolves(mResponse);
Is it possible to clear it down after the test? If so, how?
Upvotes: 1
Views: 2871
Reputation: 6718
Yes it's possible.
Sinon
API have restore
method for stubs
. From the docs
The original function can be restored by calling
object.method.restore()
; (orstub.restore()
)
So using your example you could simply do:
const stub = sinon.stub(service, 'batchNote');
stub.resolves(mResponse);
console.log(service.batchNote()); // outputs stubbed value
stub.restore()
console.log(service.batchNote()); // outputs original
Upvotes: 3