-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy patherrors.test.ts
30 lines (23 loc) · 1.03 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
import { expect, test } from '@playwright/test';
import { waitForError } from '@sentry-internal/test-utils';
test('Sends correct error event', async ({ baseURL }) => {
const errorEventPromise = waitForError('node-fastify-5', event => {
return !event.type && event.exception?.values?.[0]?.value === 'This is an exception with id 123';
});
await fetch(`${baseURL}/test-exception/123`);
const errorEvent = await errorEventPromise;
expect(errorEvent.exception?.values).toHaveLength(1);
expect(errorEvent.exception?.values?.[0]?.value).toBe('This is an exception with id 123');
expect(errorEvent.request).toEqual({
method: 'GET',
cookies: {},
headers: expect.any(Object),
url: 'http://localhost:3030/test-exception/123',
});
expect(errorEvent.transaction).toEqual('GET /test-exception/:id');
expect(errorEvent.contexts?.trace).toEqual({
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
parent_span_id: expect.stringMatching(/[a-f0-9]{16}/),
});
});