Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tracing): Fix flakey web vitals LCP test #13117

Closed
wants to merge 9 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ sentryTest('should capture a LCP vital with element details.', async ({ browserN
if (shouldSkipTracingTest() || browserName !== 'chromium') {
sentryTest.skip();
}

page.route('**', route => route.continue());
page.route('**/path/to/image.png', async (route: Route) => {
return route.fulfill({ path: `${__dirname}/assets/sentry-logo-600x179.png` });
Expand All @@ -19,9 +18,16 @@ sentryTest('should capture a LCP vital with element details.', async ({ browserN
const [eventData] = await Promise.all([
getFirstSentryEnvelopeRequest<Event>(page),
page.goto(url),
page.locator('button').click(),
page.waitForLoadState('networkidle'),
]);

// Clicking the button before image loads will result in the button being the LCP
await page.waitForFunction(() => {
const images = Array.from(document.querySelectorAll('img'));
return images.every(img => img.naturalWidth > 0);
}),
await page.locator('button').click();

expect(eventData.measurements).toBeDefined();
expect(eventData.measurements?.lcp?.value).toBeDefined();

Expand Down
Loading