Skip to content

Commit eaf2e81

Browse files
authored
test(tracing): Add FP and FCP tests (#4422)
1 parent 2fcf480 commit eaf2e81

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title></title>
6+
<script src="{{htmlWebpackPlugin.options.initialization}}"></script>
7+
</head>
8+
<body>
9+
<div>Rendered</div>
10+
</body>
11+
</html>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { expect } from '@playwright/test';
2+
3+
import { sentryTest } from '../../../../utils/fixtures';
4+
import { getSentryTransactionRequest } from '../../../../utils/helpers';
5+
6+
sentryTest('should capture FP vital.', async ({ browserName, getLocalTestPath, page }) => {
7+
// FP is not generated on webkit or firefox
8+
if (browserName !== 'chromium') {
9+
sentryTest.skip();
10+
}
11+
12+
const url = await getLocalTestPath({ testDir: __dirname });
13+
const eventData = await getSentryTransactionRequest(page, url);
14+
15+
expect(eventData.measurements).toBeDefined();
16+
expect(eventData.measurements?.fp?.value).toBeDefined();
17+
18+
expect(eventData.measurements?.['mark.fp']?.value).toBeDefined();
19+
20+
const fpSpan = eventData.spans?.filter(({ description }) => description === 'first-paint')[0];
21+
22+
expect(fpSpan).toBeDefined();
23+
expect(fpSpan?.op).toBe('paint');
24+
expect(fpSpan?.parentSpanId).toBe(eventData.contexts?.trace_span_id);
25+
});
26+
27+
sentryTest('should capture FCP vital.', async ({ getLocalTestPath, page }) => {
28+
const url = await getLocalTestPath({ testDir: __dirname });
29+
const eventData = await getSentryTransactionRequest(page, url);
30+
31+
expect(eventData.measurements).toBeDefined();
32+
expect(eventData.measurements?.fcp?.value).toBeDefined();
33+
34+
expect(eventData.measurements?.['mark.fcp']?.value).toBeDefined();
35+
36+
const fcpSpan = eventData.spans?.filter(({ description }) => description === 'first-contentful-paint')[0];
37+
38+
expect(fcpSpan).toBeDefined();
39+
expect(fcpSpan?.op).toBe('paint');
40+
expect(fcpSpan?.parentSpanId).toBe(eventData.contexts?.trace_span_id);
41+
});

0 commit comments

Comments
 (0)