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
Is your feature request related to a problem? Please describe.
In most cases, I want to use sinon.restoreObject(value) in a test hook like beforeEach/afterEach. However, not every single test case necessarily stubs value.
afterEach(()=>{sinon.restoreObject(value);})it('should do x',()=>{sinon.stub(value,'foo').returns(123);// ...});it('should do y',()=>{// no value stub})
This will throw after the second test because value does not contain a stub.
Describe the solution you'd like
I want the sinon.restoreObject method to have symmetry with sinon.restore() and sandbox.restore(). Ie, passing an empty/un-mocked object should be a no-op.
However, it doesn't handle nesting. Another alternative would be to leave sinon.restoreObject as-is and allow passing a value to sinon.restore(value).
Additional context
The strict behaviour was originally introduced here: #2092
I think the stricter behaviour makes sense for the other methods, but not for restoreObject.
Activity
feat: make sinon.restoreObject idempotent
feat: make sinon.restoreObject idempotent (sinonjs#2737)