-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy patherrors.client.test.ts
105 lines (89 loc) · 2.9 KB
/
errors.client.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
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import { expect, test } from '@nuxt/test-utils/playwright';
import { waitForError } from '@sentry-internal/test-utils';
test.describe('client-side errors', async () => {
test('captures error thrown on click', async ({ page }) => {
const errorPromise = waitForError('nuxt-3', async errorEvent => {
return errorEvent?.exception?.values?.[0]?.value === 'Error thrown from Nuxt-3 E2E test app';
});
await page.goto(`/client-error`);
await page.locator('#errorBtn').click();
const error = await errorPromise;
expect(error.transaction).toEqual('/client-error');
expect(error).toMatchObject({
exception: {
values: [
{
type: 'Error',
value: 'Error thrown from Nuxt-3 E2E test app',
mechanism: {
handled: false,
},
},
],
},
});
});
test('shows parametrized route on button error', async ({ page }) => {
const errorPromise = waitForError('nuxt-3', async errorEvent => {
return errorEvent?.exception?.values?.[0]?.value === 'Error thrown from Param Route Button';
});
await page.goto(`/test-param/1234`);
await page.locator('#errorBtn').click();
const error = await errorPromise;
expect(error.sdk.name).toEqual('sentry.javascript.nuxt');
expect(error.transaction).toEqual('/test-param/:param()');
expect(error.request.url).toMatch(/\/test-param\/1234/);
expect(error).toMatchObject({
exception: {
values: [
{
type: 'Error',
value: 'Error thrown from Param Route Button',
mechanism: {
handled: false,
},
},
],
},
});
});
test('page is still interactive after client error', async ({ page }) => {
const error1Promise = waitForError('nuxt-3', async errorEvent => {
return errorEvent?.exception?.values?.[0]?.value === 'Error thrown from Nuxt-3 E2E test app';
});
await page.goto(`/client-error`);
await page.locator('#errorBtn').click();
const error1 = await error1Promise;
const error2Promise = waitForError('nuxt-3', async errorEvent => {
return errorEvent?.exception?.values?.[0]?.value === 'Another Error thrown from Nuxt-3 E2E test app';
});
await page.locator('#errorBtn2').click();
const error2 = await error2Promise;
expect(error1).toMatchObject({
exception: {
values: [
{
type: 'Error',
value: 'Error thrown from Nuxt-3 E2E test app',
mechanism: {
handled: false,
},
},
],
},
});
expect(error2).toMatchObject({
exception: {
values: [
{
type: 'Error',
value: 'Another Error thrown from Nuxt-3 E2E test app',
mechanism: {
handled: false,
},
},
],
},
});
});
});