Skip to content

Commit 11f7375

Browse files
chore: stabilize test
1 parent f7e9c5e commit 11f7375

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

‎e2e/react-start/hmr/tests/app.spec.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,34 @@ function onNextHmrUpdate(page: Page, routeFilename: string): Promise<void> {
111111
})
112112
}
113113

114+
async function waitForRouteLoaderCrumb(
115+
page: Page,
116+
routeId: string,
117+
crumb: string,
118+
) {
119+
await expect
120+
.poll(async () => {
121+
try {
122+
return await page.evaluate(
123+
({ routeId }) => {
124+
const router = (window as any).__TSR_ROUTER__
125+
const loader = router?.routesById?.[routeId]?.options?.loader
126+
127+
if (typeof loader !== 'function') {
128+
return null
129+
}
130+
131+
return loader()?.crumb ?? null
132+
},
133+
{ routeId },
134+
)
135+
} catch {
136+
return null
137+
}
138+
})
139+
.toBe(crumb)
140+
}
141+
114142
async function waitForRouteRemovalReload(page: Page) {
115143
await page.waitForFunction(() => {
116144
const router = (window as any).__TSR_ROUTER__
@@ -344,6 +372,7 @@ test.describe('react-start hmr', () => {
344372
"crumb: 'Child Updated Again'",
345373
)
346374
await hmr2
375+
await waitForRouteLoaderCrumb(page, '/child', 'Child Updated Again')
347376

348377
// Now navigate to /child — should see the LATEST value
349378
await page.getByTestId('child-link').click()

0 commit comments

Comments
 (0)