-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy patherrors.test.ts
75 lines (67 loc) · 1.96 KB
/
errors.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
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
import { expect, test } from '@playwright/test';
import { waitForError } from '@sentry-internal/test-utils';
test('errors on frontend and backend are connected by the same trace', async ({ page }) => {
const clientErrorPromise = waitForError('sveltekit-2-twp', evt => {
return evt.exception?.values?.[0].value === 'Client Error';
});
const serverErrorPromise = waitForError('sveltekit-2-twp', evt => {
return evt.exception?.values?.[0].value === 'No search query provided';
});
await page.goto('/errors');
const clientError = await clientErrorPromise;
const serverError = await serverErrorPromise;
expect(clientError).toMatchObject({
contexts: {
trace: {
parent_span_id: expect.stringMatching(/[a-f0-9]{16}/),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
},
},
environment: 'qa',
exception: {
values: [
{
mechanism: {
handled: false,
type: 'onunhandledrejection',
},
stacktrace: expect.any(Object),
type: 'Error',
value: 'Client Error',
},
],
},
level: 'error',
platform: 'javascript',
release: '1.0.0',
timestamp: expect.any(Number),
transaction: '/errors',
});
expect(serverError).toMatchObject({
contexts: {
trace: {
span_id: expect.stringMatching(/[a-f0-9]{16}/),
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
},
},
environment: 'qa',
exception: {
values: [
{
mechanism: {
handled: true,
type: 'generic',
},
stacktrace: {},
},
],
},
platform: 'node',
timestamp: expect.any(Number),
transaction: 'GET /errors',
});
const clientTraceId = clientError.contexts?.trace?.trace_id;
const serverTraceId = serverError.contexts?.trace?.trace_id;
expect(clientTraceId).toBe(serverTraceId);
});