Skip to content

Commit

Permalink
test: Add loader test for unhandled promise rejection (#9581)
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea authored Nov 16, 2023
1 parent d68ab17 commit e4cd09c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/browser-integration-tests/fixtures/loader.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
new Promise(function (resolve, reject) {
reject('this is unhandled');
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers';

sentryTest('unhandled promise rejection handler works', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });
const req = await waitForErrorRequestOnUrl(page, url);

const eventData = envelopeRequestParser(req);
expect(eventData.exception?.values?.length).toBe(1);
expect(eventData.exception?.values?.[0]?.value).toBe(
'Non-Error promise rejection captured with value: this is unhandled',
);
});

0 comments on commit e4cd09c

Please sign in to comment.