Skip to content

Commit 7096bfa

Browse files
committed
add performance test
1 parent b6dcb74 commit 7096bfa

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import exp from 'constants';
2+
import { expect, test } from '@playwright/test';
3+
import { waitForTransaction } from '@sentry-internal/test-utils';
4+
5+
test('captures a pageload transaction', async ({ page }) => {
6+
// `pageload` transaction
7+
const transactionPromise = waitForTransaction('default-browser', async transactionEvent => {
8+
return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'pageload';
9+
});
10+
11+
await page.goto(`/`);
12+
13+
// `waitForTransaction` hangs here because `transaction` (or `span`) event is not emitted,
14+
// so the code past this line is never executed.
15+
const pageLoadTransaction = await transactionPromise;
16+
17+
expect(pageLoadTransaction).toEqual({
18+
contexts: {
19+
trace: {
20+
data: expect.objectContaining({
21+
'sentry.idle_span_finish_reason': 'idleTimeout',
22+
'sentry.op': 'pageload',
23+
'sentry.origin': 'auto.pageload.browser',
24+
'sentry.sample_rate': 1,
25+
'sentry.source': 'url',
26+
}),
27+
op: 'pageload',
28+
origin: 'auto.pageload.browser',
29+
span_id: expect.stringMatching(/[a-f0-9]{16}/),
30+
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
31+
},
32+
},
33+
environment: 'qa',
34+
event_id: expect.stringMatching(/[a-f0-9]{32}/),
35+
measurements: {
36+
'connection.rtt': {
37+
unit: 'millisecond',
38+
value: expect.any(Number),
39+
},
40+
fcp: {
41+
unit: 'millisecond',
42+
value: expect.any(Number),
43+
},
44+
fp: {
45+
unit: 'millisecond',
46+
value: expect.any(Number),
47+
},
48+
lcp: {
49+
unit: 'millisecond',
50+
value: expect.any(Number),
51+
},
52+
ttfb: {
53+
unit: 'millisecond',
54+
value: expect.any(Number),
55+
},
56+
'ttfb.requestTime': {
57+
unit: 'millisecond',
58+
value: expect.any(Number),
59+
},
60+
},
61+
platform: 'javascript',
62+
release: 'e2e-test',
63+
request: {
64+
headers: {
65+
'User-Agent': expect.any(String),
66+
},
67+
url: 'http://localhost:3030/',
68+
},
69+
sdk: {
70+
integrations: expect.any(Array),
71+
name: 'sentry.javascript.browser',
72+
packages: [
73+
{
74+
name: 'npm:@sentry/browser',
75+
version: expect.any(String),
76+
},
77+
],
78+
version: expect.any(String),
79+
},
80+
spans: expect.any(Array),
81+
start_timestamp: expect.any(Number),
82+
timestamp: expect.any(Number),
83+
transaction: '/',
84+
transaction_info: {
85+
source: 'url',
86+
},
87+
type: 'transaction',
88+
});
89+
});

0 commit comments

Comments
 (0)