-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
test.ts
41 lines (33 loc) · 1.17 KB
/
test.ts
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
31
32
33
34
35
36
37
38
39
40
41
import { expect } from '@playwright/test';
import type { Event } from '@sentry/types';
import { sentryTest } from '../../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest, runScriptInSandbox } from '../../../../../utils/helpers';
sentryTest('should catch thrown objects', async ({ getLocalTestPath, page, browserName }) => {
if (browserName === 'webkit') {
// This test fails on Webkit as erros thrown from `runScriptInSandbox` are Script Errors and skipped by Sentry
sentryTest.skip();
}
const url = await getLocalTestPath({ testDir: __dirname });
await page.goto(url);
const errorEventPromise = getFirstSentryEnvelopeRequest<Event>(page);
await runScriptInSandbox(page, {
content: `
throw {
error: 'stuff is broken',
somekey: 'ok'
};`,
});
const eventData = await errorEventPromise;
expect(eventData.exception?.values).toHaveLength(1);
expect(eventData.exception?.values?.[0]).toMatchObject({
type: 'Error',
value: 'Object captured as exception with keys: error, somekey',
mechanism: {
type: 'onerror',
handled: false,
},
stacktrace: {
frames: expect.any(Array),
},
});
});