-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy patherrors.test.ts
More file actions
56 lines (40 loc) · 2.01 KB
/
errors.test.ts
File metadata and controls
56 lines (40 loc) · 2.01 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
import { expect, test } from '@playwright/test';
import { waitForError } from '@sentry-internal/test-utils';
test('Captures manually reported error', async ({ baseURL }) => {
const errorEventPromise = waitForError('effect-3-node', event => {
return !event.type && event.exception?.values?.[0]?.value === 'This is an error';
});
const response = await fetch(`${baseURL}/test-error`);
const body = await response.json();
const errorEvent = await errorEventPromise;
expect(body.exceptionId).toBeDefined();
expect(errorEvent.exception?.values).toHaveLength(1);
expect(errorEvent.exception?.values?.[0]?.value).toBe('This is an error');
});
test('Captures thrown exception', async ({ baseURL }) => {
const errorEventPromise = waitForError('effect-3-node', 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');
});
test('Captures Effect.fail as error', async ({ baseURL }) => {
const errorEventPromise = waitForError('effect-3-node', event => {
return !event.type && event.exception?.values?.[0]?.value === 'Effect failure';
});
await fetch(`${baseURL}/test-effect-fail`);
const errorEvent = await errorEventPromise;
expect(errorEvent.exception?.values).toHaveLength(1);
expect(errorEvent.exception?.values?.[0]?.value).toBe('Effect failure');
});
test('Captures Effect.die as error', async ({ baseURL }) => {
const errorEventPromise = waitForError('effect-3-node', event => {
return !event.type && event.exception?.values?.[0]?.value?.includes('Effect defect');
});
await fetch(`${baseURL}/test-effect-die`);
const errorEvent = await errorEventPromise;
expect(errorEvent.exception?.values).toHaveLength(1);
expect(errorEvent.exception?.values?.[0]?.value).toContain('Effect defect');
});