Repository navigation
test(storage): isolate Sinon sandboxes and fake timers in unit tests #9919
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,7 +43,7 @@ import {DownloadResponseWithStatus, SkipReason} from '../src/file.js'; | |
|
|
||
| describe('Transfer Manager', () => { | ||
| const BUCKET_NAME = 'test-bucket'; | ||
| const STORAGE = sinon.stub( | ||
| const STORAGE = sinon.createSandbox().stub( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Defining a stubbed Consider instantiating and stubbing |
||
| new Storage({ | ||
| retryOptions: { | ||
| autoRetry: true, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating an isolated sandbox with
sinon.createSandbox()is a great way to prevent test pollution. However, since this sandbox is never restored, it can lead to resource leaks in persistent test runner environments (such as watch mode). Consider declaring the sandbox at the suite level and restoring it in anafterhook.