-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy patherrors.client.test.ts
More file actions
80 lines (73 loc) · 2.32 KB
/
errors.client.test.ts
File metadata and controls
80 lines (73 loc) · 2.32 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { expect, test } from '@playwright/test';
import { waitForError } from '@sentry-internal/test-utils';
test.describe('client-side errors', () => {
test('captures error thrown on click', async ({ page }) => {
const errorEventPromise = waitForError('astro-4', errorEvent => {
return errorEvent?.exception?.values?.[0]?.value === 'client error';
});
await page.goto('/client-error');
await page.getByText('Throw Error').click();
const errorEvent = await errorEventPromise;
const errorEventFrames = errorEvent.exception?.values?.[0]?.stacktrace?.frames;
expect(errorEventFrames?.[errorEventFrames?.length - 1]).toEqual(
expect.objectContaining({
colno: expect.any(Number),
lineno: expect.any(Number),
filename: expect.stringContaining('/client-error'),
function: 'HTMLButtonElement.onclick',
in_app: true,
}),
);
expect(errorEvent).toMatchObject({
exception: {
values: [
{
mechanism: {
handled: false,
type: 'auto.browser.global_handlers.onerror',
},
type: 'Error',
value: 'client error',
stacktrace: expect.any(Object), // detailed check above
},
],
},
level: 'error',
platform: 'javascript',
request: {
url: expect.stringContaining('/client-error'),
headers: {
'User-Agent': expect.any(String),
},
},
event_id: expect.stringMatching(/[a-f0-9]{32}/),
timestamp: expect.any(Number),
sdk: {
integrations: expect.arrayContaining([
'InboundFilters',
'FunctionToString',
'BrowserApiErrors',
'Breadcrumbs',
'GlobalHandlers',
'LinkedErrors',
'Dedupe',
'HttpContext',
'BrowserSession',
'BrowserTracing',
]),
name: 'sentry.javascript.astro',
version: expect.any(String),
packages: expect.any(Array),
},
transaction: '/client-error',
contexts: {
trace: {
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
parent_span_id: expect.stringMatching(/[a-f0-9]{16}/),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
},
},
environment: 'qa',
});
});
});