-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
38 lines (31 loc) · 1.17 KB
/
test.ts
File metadata and controls
38 lines (31 loc) · 1.17 KB
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
import { expect } from '@playwright/test';
import type { Event } from '@sentry/core';
import { sentryTest } from '../../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest, runScriptInSandbox } from '../../../../../utils/helpers';
sentryTest('should catch syntax errors', async ({ getLocalTestUrl, page, browserName }) => {
if (browserName === 'webkit') {
// This test fails on Webkit as errors thrown from `runScriptInSandbox` are Script Errors and skipped by Sentry
sentryTest.skip();
}
const url = await getLocalTestUrl({ testDir: __dirname });
await page.goto(url);
const errorEventPromise = getFirstSentryEnvelopeRequest<Event>(page);
await runScriptInSandbox(page, {
content: `
foo{}; // SyntaxError
`,
});
const eventData = await errorEventPromise;
expect(eventData.exception?.values).toHaveLength(1);
expect(eventData.exception?.values?.[0]).toMatchObject({
type: 'SyntaxError',
value: "Failed to execute 'appendChild' on 'Node': Unexpected token '{'",
mechanism: {
type: 'auto.browser.global_handlers.onerror',
handled: false,
},
stacktrace: {
frames: expect.any(Array),
},
});
});