-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
test.ts
49 lines (38 loc) · 1.33 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
42
43
44
45
46
47
48
49
import { expect } from '@playwright/test';
import type { Event } from '@sentry/types';
import { sentryTest } from '../../../../utils/fixtures';
import {
getMultipleSentryEnvelopeRequests,
runScriptInSandbox,
shouldSkipTracingTest,
} from '../../../../utils/helpers';
sentryTest(
'should capture an error within a sync startSpan callback',
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();
}
if (shouldSkipTracingTest()) {
sentryTest.skip();
}
const url = await getLocalTestPath({ testDir: __dirname });
await page.goto(url);
const errorEventsPromise = getMultipleSentryEnvelopeRequests<Event>(page, 2);
runScriptInSandbox(page, {
content: `
function run() {
Sentry.startSpan({ name: 'parent_span' }, () => {
throw new Error('Sync Error');
});
}
setTimeout(run);
`,
});
const events = await errorEventsPromise;
const txn = events.find(event => event.type === 'transaction');
const err = events.find(event => !event.type);
expect(txn).toMatchObject({ transaction: 'parent_span' });
expect(err?.exception?.values?.[0]?.value).toBe('Sync Error');
},
);