-
-
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
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 |
|---|---|---|
| @@ -1,15 +1,29 @@ | ||
| import { Hub, init, Integrations, Scope } from '../src'; | ||
| import { Scope } from '@sentry/core'; | ||
| import { Hub } from '@sentry/hub'; | ||
|
|
||
| const dsn = 'https://[email protected]/4291'; | ||
| import { OnUnhandledRejection } from '../src/integrations/onunhandledrejection'; | ||
|
|
||
| jest.mock('@sentry/hub', () => { | ||
| // we just want to short-circuit it, so dont worry about types | ||
|
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. I understand the rest of the change, don't fully understand this. Why do we want to short-circuit?
Contributor
Author
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. Because |
||
| const original = jest.requireActual('@sentry/hub'); | ||
| original.Hub.prototype.getIntegration = () => true; | ||
| return { | ||
| ...original, | ||
| getCurrentHub: () => new Hub(), | ||
| }; | ||
| }); | ||
|
|
||
| describe('unhandled promises', () => { | ||
| test('install global listener', () => { | ||
| init({ dsn }); | ||
| const integration = new OnUnhandledRejection(); | ||
| integration.setupOnce(); | ||
| expect(process.listeners('unhandledRejection')).toHaveLength(1); | ||
| }); | ||
|
|
||
| test('sendUnhandledPromise', () => { | ||
| const integration = new Integrations.OnUnhandledRejection(); | ||
| const integration = new OnUnhandledRejection(); | ||
| integration.setupOnce(); | ||
|
|
||
| const promise = { | ||
| domain: { | ||
| sentryContext: { | ||
|
|
||
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