-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathpageload.client.test.ts
More file actions
105 lines (97 loc) · 3.37 KB
/
pageload.client.test.ts
File metadata and controls
105 lines (97 loc) · 3.37 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
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 '@playwright/test';
import { waitForTransaction } from '@sentry-internal/test-utils';
import { APP_NAME } from '../constants';
test.describe('client - pageload performance', () => {
test('should send pageload transaction', async ({ page }) => {
const txPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance';
});
await page.goto(`/performance`);
const transaction = await txPromise;
expect(transaction).toMatchObject({
contexts: {
trace: {
span_id: expect.any(String),
trace_id: expect.any(String),
data: {
'sentry.origin': 'auto.pageload.react_router',
'sentry.op': 'pageload',
'sentry.source': 'route',
},
op: 'pageload',
origin: 'auto.pageload.react_router',
},
},
spans: expect.any(Array),
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
transaction: '/performance',
type: 'transaction',
transaction_info: { source: 'route' },
measurements: expect.any(Object),
platform: 'javascript',
request: {
url: expect.stringContaining('/performance'),
headers: expect.any(Object),
},
event_id: expect.any(String),
environment: 'qa',
sdk: {
integrations: expect.arrayContaining([expect.any(String)]),
name: 'sentry.javascript.react-router',
version: expect.any(String),
packages: [
{ name: 'npm:@sentry/react-router', version: expect.any(String) },
{ name: 'npm:@sentry/browser', version: expect.any(String) },
],
},
tags: { runtime: 'browser' },
});
});
test('should update pageload transaction for dynamic routes', async ({ page }) => {
const txPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance/with/:param';
});
await page.goto(`/performance/with/sentry`);
const transaction = await txPromise;
expect(transaction).toMatchObject({
contexts: {
trace: {
span_id: expect.any(String),
trace_id: expect.any(String),
data: {
'sentry.origin': 'auto.pageload.react_router',
'sentry.op': 'pageload',
'sentry.source': 'route',
},
op: 'pageload',
origin: 'auto.pageload.react_router',
},
},
spans: expect.any(Array),
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
transaction: '/performance/with/:param',
type: 'transaction',
transaction_info: { source: 'route' },
measurements: expect.any(Object),
platform: 'javascript',
request: {
url: expect.stringContaining('/performance/with/sentry'),
headers: expect.any(Object),
},
event_id: expect.any(String),
environment: 'qa',
sdk: {
integrations: expect.arrayContaining([expect.any(String)]),
name: 'sentry.javascript.react-router',
version: expect.any(String),
packages: [
{ name: 'npm:@sentry/react-router', version: expect.any(String) },
{ name: 'npm:@sentry/browser', version: expect.any(String) },
],
},
tags: { runtime: 'browser' },
});
});
});