-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
test: Fix flaky onunhandledrejection tests #3482
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
Conversation
size-limit report
|
rhcarvalho
left a comment
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.
Do we have examples of the flakiness in CI (to document in the PR description)?
| import { OnUnhandledRejection } from '../src/integrations/onunhandledrejection'; | ||
|
|
||
| jest.mock('@sentry/hub', () => { | ||
| // we just want to short-circuit it, so dont worry about types |
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.
I understand the rest of the change, don't fully understand this.
Why do we want to short-circuit?
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.
Because setupOnce is checking whether an integration is installed, which in the case of these tests should always be the case. I think this was the reason for flakyness, because hub is attached to the global object.
| import { Scope } from '@sentry/core'; | ||
| import { Hub } from '@sentry/hub'; |
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.
For my learning -- Does changing this import affect the test, or is it just cosmetic/preference?
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.
Cosmetic preference
|
Linked an example |
Example failed test: https://github.com/getsentry/sentry-javascript/runs/2457635380