-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
30 lines (23 loc) · 977 Bytes
/
test.ts
File metadata and controls
30 lines (23 loc) · 977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { expect } from '@playwright/test';
import { sentryTest } from '../../../../utils/fixtures';
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers';
sentryTest(
'sentryOnLoad callback is called before Sentry.onLoad() and handles errors in handler',
async ({ getLocalTestUrl, page }) => {
const errors: string[] = [];
page.on('console', msg => {
if (msg.type() === 'error') {
errors.push(msg.text());
}
});
const url = await getLocalTestUrl({ testDir: __dirname });
const req = await waitForErrorRequestOnUrl(page, url);
const eventData = envelopeRequestParser(req);
expect(eventData.message).toBe('Test exception');
expect(await page.evaluate('Sentry.getClient().getOptions().tracesSampleRate')).toEqual(0.123);
expect(errors).toEqual([
'Error while calling `sentryOnLoad` handler:',
expect.stringContaining('Error: sentryOnLoad error'),
]);
},
);