spy.restore
Replaces the spy or stub with the original method. Only available if the spy or stub replaced an existing method.
js
import tap from "tap";
import * as sinon from "sinon";
tap.test("spy.restore", (t) => {
const obj = {
hello: () => {
return "world";
}
};
const s = sinon.stub(obj, "hello").callsFake(() => {
return "sailor";
});
t.equal(obj.hello(), "sailor", "stub returns stubbed value");
s.restore();
t.equal(obj.hello(), "world", "original method restored");
t.end();
});Other ways of restoring
You can also reset the whole sandbox, by using sinon.restore or sinon.reset.
