Skip to content

Commit b440e7c

Browse files
committed
fix: handle error page navigation in nextjs-13 tests
Pages that return HTTP error status codes now fail with net::ERR_HTTP_RESPONSE_CODE_FAILURE in Playwright 1.56/Chromium 141
1 parent bf41f68 commit b440e7c

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

dev-packages/e2e-tests/test-applications/nextjs-13/tests/client/pages-dir-pageload.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ test('should create a pageload transaction with correct name when an error occur
5757
);
5858
});
5959

60-
await page.goto(`/something/error-getServerSideProps`, { waitUntil: 'networkidle' });
60+
// This page returns an error status code, so we need to catch the navigation error
61+
await page.goto(`/something/error-getServerSideProps`, { waitUntil: 'networkidle' }).catch(() => {
62+
// Expected to fail with net::ERR_HTTP_RESPONSE_CODE_FAILURE in newer Chromium versions
63+
});
6164

6265
const transaction = await transactionPromise;
6366

dev-packages/e2e-tests/test-applications/nextjs-13/tests/server/getServerSideProps.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ test('Should report an error event for errors thrown in getServerSideProps', asy
1313
);
1414
});
1515

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

1821
expect(await errorEventPromise).toMatchObject({
1922
contexts: {
@@ -100,7 +103,10 @@ test('Should report an error event for errors thrown in getServerSideProps in pa
100103
);
101104
});
102105

103-
await page.goto('/123/customPageExtension');
106+
// This page returns an error status code, so we need to catch the navigation error
107+
await page.goto('/123/customPageExtension').catch(() => {
108+
// Expected to fail with net::ERR_HTTP_RESPONSE_CODE_FAILURE in newer Chromium versions
109+
});
104110

105111
expect(await errorEventPromise).toMatchObject({
106112
contexts: {

dev-packages/e2e-tests/test-applications/nextjs-13/tests/server/server-component-error.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ test('Should capture an error thrown in a server component', async ({ page }) =>
66
return errorEvent.exception?.values?.[0].value === 'RSC error';
77
});
88

9-
await page.goto('/rsc-error');
9+
// This page returns an error status code, so we need to catch the navigation error
10+
await page.goto('/rsc-error').catch(() => {
11+
// Expected to fail with net::ERR_HTTP_RESPONSE_CODE_FAILURE in newer Chromium versions
12+
});
1013

1114
expect(await errorEventPromise).toMatchObject({
1215
contexts: {

0 commit comments

Comments
 (0)