Skip to content

Commit 51470d5

Browse files
stabilize tests
1 parent e0ad796 commit 51470d5

File tree

21 files changed

+73
-26
lines changed

21 files changed

+73
-26
lines changed

e2e/e2e-utils/src/fixture.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,35 @@
11
import { test as base, expect } from '@playwright/test'
22

33
export interface TestFixtureOptions {
4+
/**
5+
* List of error message patterns to ignore in console output.
6+
* Supports both strings (substring match) and RegExp patterns.
7+
*
8+
* @example
9+
* test.use({
10+
* whitelistErrors: [
11+
* 'Failed to load resource: net::ERR_NAME_NOT_RESOLVED',
12+
* /Failed to load resource/,
13+
* ],
14+
* })
15+
*/
416
whitelistErrors: Array<RegExp | string>
517
}
618
export const test = base.extend<TestFixtureOptions>({
7-
whitelistErrors: [[], { option: true }],
19+
whitelistErrors: [
20+
async ({}, use) => {
21+
await use([])
22+
},
23+
{ option: true },
24+
],
825
page: async ({ page, whitelistErrors }, use) => {
926
const errorMessages: Array<string> = []
27+
// Ensure whitelistErrors is always an array (defensive fallback)
28+
const errors = Array.isArray(whitelistErrors) ? whitelistErrors : []
1029
page.on('console', (m) => {
1130
if (m.type() === 'error') {
1231
const text = m.text()
13-
for (const whitelistError of whitelistErrors) {
32+
for (const whitelistError of errors) {
1433
if (
1534
(typeof whitelistError === 'string' &&
1635
text.includes(whitelistError)) ||

e2e/react-start/basic/tests/navigation.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { test } from '@tanstack/router-e2e-utils'
44

55
test.use({
66
whitelistErrors: [
7-
/Failed to load resource: the server responded with a status of 404/,
7+
'Failed to load resource: the server responded with a status of 404',
88
],
99
})
1010
test('Navigating to post', async ({ page }) => {

e2e/react-start/basic/tests/not-found.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const combinate = (combinateImport as any).default as typeof combinateImport
88

99
test.use({
1010
whitelistErrors: [
11-
/Failed to load resource: the server responded with a status of 404/,
11+
'Failed to load resource: the server responded with a status of 404',
1212
'NotFound error during hydration for routeId',
1313
],
1414
})

e2e/react-start/basic/tests/open-redirect-prevention.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { test } from '@tanstack/router-e2e-utils'
33

44
test.use({
55
whitelistErrors: [
6-
/Failed to load resource: the server responded with a status of 404/,
6+
'Failed to load resource: the server responded with a status of 404',
77
],
88
})
99

e2e/react-start/basic/tests/params.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test.beforeEach(async ({ page }) => {
88

99
test.use({
1010
whitelistErrors: [
11-
/Failed to load resource: the server responded with a status of 404/,
11+
'Failed to load resource: the server responded with a status of 404',
1212
],
1313
})
1414
test.describe('Unicode route rendering', () => {

e2e/react-start/css-modules/playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { defineConfig, devices } from '@playwright/test'
22
import { getTestServerPort } from '@tanstack/router-e2e-utils'
33
import packageJson from './package.json' with { type: 'json' }
44

5-
const isDev = process.env.MODE === 'dev'
5+
const isDev = process.env.MODE !== 'prod'
66
const viteConfig = process.env.VITE_CONFIG // 'nitro' | 'basepath' | 'cloudflare' | undefined
77
const PORT = await getTestServerPort(
88
viteConfig ? `${packageJson.name}-${viteConfig}` : packageJson.name,

e2e/react-start/css-modules/tests/css.spec.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import { expect, request } from '@playwright/test'
22
import { test } from '@tanstack/router-e2e-utils'
33

4+
// Whitelist errors that can occur in CI:
5+
// - net::ERR_NAME_NOT_RESOLVED: transient network issues
6+
// - 504 (Outdated Optimize Dep): Vite dependency optimization reload
7+
const whitelistErrors = [
8+
'Failed to load resource: net::ERR_NAME_NOT_RESOLVED',
9+
'Failed to load resource: the server responded with a status of 504',
10+
]
11+
412
test.describe('CSS styles in SSR (dev mode)', () => {
5-
// Whitelist network errors that can occur in CI due to transient network issues
6-
test.use({
7-
whitelistErrors: [/Failed to load resource: net::ERR_NAME_NOT_RESOLVED/],
8-
})
13+
test.use({ whitelistErrors })
14+
915
// Warmup: trigger Vite's dependency optimization before running tests
1016
// This prevents "504 (Outdated Optimize Dep)" errors during actual tests
1117
test.beforeAll(async ({ baseURL }) => {
@@ -33,7 +39,7 @@ test.describe('CSS styles in SSR (dev mode)', () => {
3339
}
3440

3541
test.describe('with JavaScript disabled', () => {
36-
test.use({ javaScriptEnabled: false })
42+
test.use({ javaScriptEnabled: false, whitelistErrors })
3743

3844
test('global CSS is applied on initial page load', async ({
3945
page,

e2e/react-start/serialization-adapters/tests/app.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async function checkNestedData(page: Page) {
4141
}
4242
test.use({
4343
whitelistErrors: [
44-
/Failed to load resource: the server responded with a status of 499/,
44+
'Failed to load resource: the server responded with a status of 499',
4545
],
4646
})
4747
test.describe('SSR serialization adapters', () => {

e2e/react-start/server-functions/tests/server-functions.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ test.describe('server function sets cookies', () => {
370370
test.describe('server functions with async validation', () => {
371371
test.use({
372372
whitelistErrors: [
373-
/Failed to load resource: the server responded with a status of 500/,
373+
'Failed to load resource: the server responded with a status of 500',
374374
],
375375
})
376376

@@ -739,7 +739,7 @@ test('redirect via server function with middleware does not cause serialization
739739

740740
test.describe('unhandled exception in middleware (issue #5266)', () => {
741741
// Whitelist the expected 500 error since this test verifies error handling
742-
test.use({ whitelistErrors: [/500/] })
742+
test.use({ whitelistErrors: ['500'] })
743743

744744
test('does not crash server and shows error component', async ({ page }) => {
745745
// This test verifies that when a middleware throws an unhandled exception,

e2e/solid-start/basic/tests/navigation.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { test } from '@tanstack/router-e2e-utils'
33

44
test.use({
55
whitelistErrors: [
6-
/Failed to load resource: the server responded with a status of 404/,
6+
'Failed to load resource: the server responded with a status of 404',
77
],
88
})
99
test('Navigating to post', async ({ page }) => {

0 commit comments

Comments
 (0)