-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy patherrors.test.ts
More file actions
33 lines (25 loc) · 1021 Bytes
/
errors.test.ts
File metadata and controls
33 lines (25 loc) · 1021 Bytes
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
import { expect, test } from '@playwright/test';
import { waitForError } from '@sentry-internal/test-utils';
test('captures a client-side error', async ({ page }) => {
const errorEventPromise = waitForError('vinext-app', errorEvent => {
return errorEvent?.exception?.values?.[0]?.value === 'E2E Test Error';
});
await page.goto('/error-page');
await page.locator('#error-button').click();
const errorEvent = await errorEventPromise;
expect(errorEvent.exception?.values?.[0]).toMatchObject({
type: 'Error',
value: 'E2E Test Error',
});
});
test('captures a server-side API route error', async ({ baseURL }) => {
const errorEventPromise = waitForError('vinext-app', errorEvent => {
return errorEvent?.exception?.values?.[0]?.value === 'API Route Error';
});
await fetch(`${baseURL}/api/test`, { method: 'POST' });
const errorEvent = await errorEventPromise;
expect(errorEvent.exception?.values?.[0]).toMatchObject({
type: 'Error',
value: 'API Route Error',
});
});