Skip to content

Commit bf41f68

Browse files
committed
fix: address Playwright 1.56.0 test failures
- Update userAgent to match Chromium 141 in playwright-config.ts - Filter out favicon resource spans in react-create-*-router tests - Add retry logic for flaky navigation in browser-integration-tests - Handle error status code navigation in astro-4/5 SSR error tests
1 parent 97fb766 commit bf41f68

File tree

7 files changed

+32
-9
lines changed

7 files changed

+32
-9
lines changed

dev-packages/browser-integration-tests/suites/sessions/initial-scope/test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ sentryTest('should start a new session on pageload.', async ({ getLocalTestUrl,
1818
sentryTest('should start a new session with navigation.', async ({ getLocalTestUrl, page }) => {
1919
const url = await getLocalTestUrl({ testDir: __dirname });
2020

21+
// Route must be set up before any navigation to avoid race conditions
2122
await page.route('**/foo', (route: Route) => route.continue({ url }));
2223

2324
const initSession = await getFirstSentryEnvelopeRequest<SessionContext>(page, url);
2425

25-
await page.click('#navigate');
26+
await page.locator('#navigate').click();
2627

2728
const newSession = await getFirstSentryEnvelopeRequest<SessionContext>(page, url);
2829

dev-packages/browser-integration-tests/utils/helpers.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,13 @@ export const countEnvelopes = async (
149149
});
150150

151151
if (options?.url) {
152-
await page.goto(options.url);
152+
// Retry navigation once if it fails due to route handler timing issues
153+
try {
154+
await page.goto(options.url);
155+
} catch (e) {
156+
// Retry once for flaky navigation errors (e.g., route handler not ready in time)
157+
await page.goto(options.url);
158+
}
153159
}
154160

155161
return countPromise;
@@ -404,7 +410,13 @@ async function getMultipleRequests<T>(
404410
});
405411

406412
if (options?.url) {
407-
await page.goto(options.url);
413+
// Retry navigation once if it fails due to route handler timing issues
414+
try {
415+
await page.goto(options.url);
416+
} catch (e) {
417+
// Retry once for flaky navigation errors (e.g., route handler not ready in time)
418+
await page.goto(options.url);
419+
}
408420
}
409421

410422
return requests;

dev-packages/e2e-tests/test-applications/astro-4/tests/errors.server.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ test.describe('server-side errors', () => {
1111
return transactionEvent.transaction === 'GET /ssr-error';
1212
});
1313

14-
await page.goto('/ssr-error');
14+
// This page returns an error status code, so we need to catch the navigation error
15+
await page.goto('/ssr-error').catch(() => {
16+
// Expected to fail with net::ERR_HTTP_RESPONSE_CODE_FAILURE in newer Chromium versions
17+
});
1518

1619
const errorEvent = await errorEventPromise;
1720
const transactionEvent = await transactionEventPromise;

dev-packages/e2e-tests/test-applications/astro-5/tests/errors.server.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ test.describe('server-side errors', () => {
1111
return transactionEvent.transaction === 'GET /ssr-error';
1212
});
1313

14-
await page.goto('/ssr-error');
14+
// This page returns an error status code, so we need to catch the navigation error
15+
await page.goto('/ssr-error').catch(() => {
16+
// Expected to fail with net::ERR_HTTP_RESPONSE_CODE_FAILURE in newer Chromium versions
17+
});
1518

1619
const errorEvent = await errorEventPromise;
1720
const transactionEvent = await transactionEventPromise;

dev-packages/e2e-tests/test-applications/react-create-browser-router/tests/transactions.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ test('Captures a navigation transaction', async ({ page }) => {
8686
}),
8787
);
8888

89-
expect(transactionEvent.spans).toEqual([]);
89+
// Filter out favicon spans which may or may not be present depending on the browser version
90+
const spans = (transactionEvent.spans || []).filter(span => !span.description?.includes('favicon'));
91+
expect(spans).toEqual([]);
9092
});
9193

9294
test('Captures a lazy pageload transaction', async ({ page }) => {

dev-packages/e2e-tests/test-applications/react-create-hash-router/tests/transactions.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ test('Captures a navigation transaction', async ({ page }) => {
150150
}),
151151
);
152152

153-
expect(transactionEvent.spans).toEqual([]);
153+
// Filter out favicon spans which may or may not be present depending on the browser version
154+
const spans = (transactionEvent.spans || []).filter(span => !span.description?.includes('favicon'));
155+
expect(spans).toEqual([]);
154156
});
155157

156158
test('Captures a parameterized path pageload transaction', async ({ page }) => {

dev-packages/test-utils/src/playwright-config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ export function getPlaywrightConfig(
5454
{
5555
name: 'chromium',
5656
use: {
57-
// This comes from `devices["Desktop Chrome"]
57+
// This comes from `devices["Desktop Chrome"]` in Playwright 1.56.0
5858
// We inline this instead of importing this,
5959
// because playwright otherwise complains that it was imported twice :(
6060
userAgent:
61-
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.6422.26 Safari/537.36',
61+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.37 Safari/537.36',
6262
viewport: { width: 1280, height: 720 },
6363
deviceScaleFactor: 1,
6464
isMobile: false,

0 commit comments

Comments
 (0)