Skip to content

feat: make sinon.restoreObject idempotent#2737

Open
icholy wants to merge 1 commit into
sinonjs:mainfrom
icholy:restore-object-idempotent
Open

feat: make sinon.restoreObject idempotent#2737
icholy wants to merge 1 commit into
sinonjs:mainfrom
icholy:restore-object-idempotent

Conversation

@icholy

@icholy icholy commented Jun 26, 2026

Copy link
Copy Markdown

Purpose (TL;DR) - mandatory

Fix #2736 by making sinon.restoreObject a no-op on empty/stub-less objects.

How to verify - mandatory

  1. Check out this branch
  2. npm install
  3. npm test

Checklist for author

  • npm run lint passes
  • References to standard library functions are cached.

Passing an object with no live fakes to restoreObject now restores
nothing instead of throwing, giving it symmetry with sinon.restore()
and sandbox.restore(). The strict "found no methods" check is retained
for spy(object) and stub(object) via a new strict flag on walkObject
that defaults to true. Passing a falsy value still throws.

Fixes sinonjs#2736
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make sinon.restoreObject idempotent

1 participant