-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy patherrors.test.ts
More file actions
53 lines (41 loc) · 1.98 KB
/
errors.test.ts
File metadata and controls
53 lines (41 loc) · 1.98 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
import { expect, test } from '@playwright/test';
import { waitForError } from '@sentry-internal/test-utils';
import { APP_NAME } from './constants';
test('captures error thrown in route handler', async ({ baseURL }) => {
const errorWaiter = waitForError(APP_NAME, event => {
return event.exception?.values?.[0]?.value === 'This is a test error for Sentry!';
});
const response = await fetch(`${baseURL}/error/test-cause`);
expect(response.status).toBe(500);
const event = await errorWaiter;
expect(event.exception?.values?.[0]?.value).toBe('This is a test error for Sentry!');
});
test('captures HTTPException with 502 status', async ({ baseURL }) => {
const errorWaiter = waitForError(APP_NAME, event => {
return event.exception?.values?.[0]?.value === 'HTTPException 502';
});
const response = await fetch(`${baseURL}/http-exception/502`);
expect(response.status).toBe(502);
const event = await errorWaiter;
expect(event.exception?.values?.[0]?.value).toBe('HTTPException 502');
});
// TODO: 401 and 404 HTTPExceptions should not be captured by Sentry by default,
// but currently they are. Fix the filtering and update these tests accordingly.
test('captures HTTPException with 401 status', async ({ baseURL }) => {
const errorWaiter = waitForError(APP_NAME, event => {
return event.exception?.values?.[0]?.value === 'HTTPException 401';
});
const response = await fetch(`${baseURL}/http-exception/401`);
expect(response.status).toBe(401);
const event = await errorWaiter;
expect(event.exception?.values?.[0]?.value).toBe('HTTPException 401');
});
test('captures HTTPException with 404 status', async ({ baseURL }) => {
const errorWaiter = waitForError(APP_NAME, event => {
return event.exception?.values?.[0]?.value === 'HTTPException 404';
});
const response = await fetch(`${baseURL}/http-exception/404`);
expect(response.status).toBe(404);
const event = await errorWaiter;
expect(event.exception?.values?.[0]?.value).toBe('HTTPException 404');
});