New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default sandbox's restore method does not restore stubs/spies #1775
Comments
mroderick
added a commit
to mroderick/sinon
that referenced
this issue
May 2, 2018
This was caused by adding stub, spy, mock explicitly to apiMethods, thus shadowing the methods from Sanbox, which are the ones that collect the fakes for restoring. Removing these methods, allows the caller to use the sandbox methods, and all is well.
Thank you for your detailed error report 👍 |
This has been fixed in |
Thanks for addressing this so quickly! Much appreciated :) |
With good error reports, most bugs are easy to squash |
This was referenced May 21, 2018
franck-romano
pushed a commit
to franck-romano/sinon
that referenced
this issue
Oct 1, 2019
This was caused by adding stub, spy, mock explicitly to apiMethods, thus shadowing the methods from Sanbox, which are the ones that collect the fakes for restoring. Removing these methods, allows the caller to use the sandbox methods, and all is well.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When using any sandbox method on the default sandbox,
restore()
does not restore mocks or spies properly. A minimal repro case on Sinon v5.0.2:It seems that in the call to
extend
inlib/sinon.js
, the un-sandboxedstub/spy/etc.
exports fromapiMethods
end up shadowing the sandbox methods, and sorestore()
doesn't do anything. The Sandbox API docs and source inlib/sinon.js
seem to suggest that this is intended usage.I only tested
stub
andspy
, but I would expect any other shadowed methods also do not work as intended.I ran these tests on Node v8.9.4 and Chrome 66.0.3359.117 via Karma/Chromedriver, though this issue seems unrelated to environment.
The text was updated successfully, but these errors were encountered: