Skip to content

Commit f0eda8f

Browse files
fix tests
1 parent f63dcc8 commit f0eda8f

2 files changed

Lines changed: 34 additions & 6 deletions

File tree

‎e2e/react-start/import-protection/tests/error-mode.setup.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,9 @@ async function captureDev(cwd: string): Promise<void> {
144144
for (const route of routes) {
145145
try {
146146
await page.goto(`${baseURL}${route}`, {
147-
waitUntil: 'networkidle',
148-
timeout: 15_000,
147+
// Vite dev keeps long-lived connections; 'networkidle' can hang.
148+
waitUntil: 'load',
149+
timeout: 30_000,
149150
})
150151
} catch {
151152
// expected — modules fail with 500 in error mode

‎e2e/react-start/import-protection/tests/violations.setup.ts‎

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ const routes = [
8383
'/barrel-false-positive',
8484
]
8585

86+
const routeReadyTestIds: Record<string, string> = {
87+
'/': 'heading',
88+
'/leaky-server-import': 'leaky-heading',
89+
'/client-only-violations': 'client-only-heading',
90+
'/client-only-jsx': 'client-only-jsx-heading',
91+
'/beforeload-leak': 'beforeload-leak-heading',
92+
'/component-server-leak': 'component-leak-heading',
93+
'/barrel-false-positive': 'barrel-heading',
94+
}
95+
8696
async function navigateAllRoutes(
8797
baseURL: string,
8898
browser: Awaited<ReturnType<typeof chromium.launch>>,
@@ -92,10 +102,27 @@ async function navigateAllRoutes(
92102

93103
for (const route of routes) {
94104
try {
95-
await page.goto(`${baseURL}${route}`, {
96-
waitUntil: 'networkidle',
97-
timeout: 15_000,
98-
})
105+
// Prefer 'networkidle' (ensures route chunks are actually fetched), but
106+
// fall back if it hangs in certain CI environments.
107+
try {
108+
await page.goto(`${baseURL}${route}`, {
109+
waitUntil: 'networkidle',
110+
timeout: 15_000,
111+
})
112+
} catch {
113+
await page.goto(`${baseURL}${route}`, {
114+
waitUntil: 'load',
115+
timeout: 30_000,
116+
})
117+
}
118+
119+
const testId = routeReadyTestIds[route]
120+
if (testId) {
121+
await page.getByTestId(testId).waitFor({ timeout: 10_000 })
122+
}
123+
124+
// Allow any deferred transforms/logging to flush.
125+
await new Promise((r) => setTimeout(r, 750))
99126
} catch {
100127
// ignore navigation errors — we only care about server logs
101128
}

0 commit comments

Comments
 (0)