-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy patherrors.server.test.ts
More file actions
66 lines (52 loc) · 2.43 KB
/
errors.server.test.ts
File metadata and controls
66 lines (52 loc) · 2.43 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
57
58
59
60
61
62
63
64
65
66
import { expect, test } from '@playwright/test';
import { waitForError } from '@sentry-internal/test-utils';
test.describe('server-side errors', async () => {
test('captures api fetch error (fetched on click)', async ({ page }) => {
const errorPromise = waitForError('nuxt-4', async errorEvent => {
return errorEvent?.exception?.values?.[0]?.value === 'Nuxt 4 Server error';
});
await page.goto(`/fetch-server-routes`);
await page.getByText('Fetch Server API Error', { exact: true }).click();
const error = await errorPromise;
expect(error.transaction).toEqual('GET /api/server-error');
const exception0 = error.exception.values[0];
const exception1 = error.exception.values[1];
expect(exception0.type).toEqual('Error');
expect(exception0.value).toEqual('Nuxt 4 Server error');
expect(exception0.mechanism).toEqual({
handled: false,
type: 'auto.function.nuxt.nitro',
exception_id: 1,
parent_id: 0,
source: 'cause',
});
expect(exception1.type).toEqual('Error');
expect(exception1.value).toEqual('Nuxt 4 Server error');
// TODO: This isn't correct but requires adjustment in the core SDK
expect(exception1.mechanism).toEqual({ handled: true, type: 'generic', exception_id: 0 });
});
test('captures api fetch error (fetched on click) with parametrized route', async ({ page }) => {
const errorPromise = waitForError('nuxt-4', async errorEvent => {
return errorEvent?.exception?.values?.[0]?.value === 'Nuxt 4 Param Server error';
});
await page.goto(`/test-param/1234`);
await page.getByRole('button', { name: 'Fetch Server API Error', exact: true }).click();
const error = await errorPromise;
expect(error.transaction).toEqual('GET /api/param-error/1234');
const exception0 = error.exception.values[0];
const exception1 = error.exception.values[1];
expect(exception0.type).toEqual('Error');
expect(exception0.value).toEqual('Nuxt 4 Param Server error');
expect(exception0.mechanism).toEqual({
handled: false,
type: 'auto.function.nuxt.nitro',
exception_id: 1,
parent_id: 0,
source: 'cause',
});
expect(exception1.type).toEqual('Error');
expect(exception1.value).toEqual('Nuxt 4 Param Server error');
// TODO: This isn't correct but requires adjustment in the core SDK
expect(exception1.mechanism).toEqual({ handled: true, type: 'generic', exception_id: 0 });
});
});