Restore all sinon stubs after each test #7338
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #7033
Add a call to
sinon.restore()
in our tests bootstrap'sbeforeEach
, so that all mocks are restored after each test.This is necessary because sinon keeps track of all mocks created via
sinon.stub()
, and you need to either callrestore()
on the mock itself, or do it "globally" to ensure memory can be released.If more than 10,000 stubs are created, then sinon prints a warning message.
Since having to remember to call
restore()
every time is error prone, this PR adds a global call that makes it unnecessary.Before this PR, the tests output would include a line like this:
With these changese, that warning is no longer reported:
Considerations
This PR makes individual
restore
calls no longer needed, but I decided to not remove them here to reduce the noise.