|
| 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