-
Notifications
You must be signed in to change notification settings - Fork 30.5k
Add instant navigation testing API tests without cache components #89876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: canary
Are you sure you want to change the base?
Conversation
The Instant Navigation Testing API lets e2e tests assert on the prefetched UI state before dynamic data streams in. This simulates what happens on a slow network or slow database: the CDN instantly serves a cached static shell, but dynamic data takes an indefinite amount of time to arrive. Previously, MPA navigations (page reload, plain anchor links) within an instant test scope served the static shell without hydration data, so the page couldn't hydrate. This adds proper hydration support: on initial page load, the static shell renders and hydration proceeds normally, but dynamic data is held back until the test scope ends.
The Instant Navigation Testing API already uses a cookie to persist lock state across MPA navigations (page reloads, plain anchor links), since window globals don't survive navigation. Rather than maintaining two parallel mechanisms — a window global for SPA and a cookie for MPA — this makes the cookie the single source of truth for all cases. Playwright sets/clears the cookie directly via the browser context, and the client reacts to changes through the CookieStore API's change event. This removes the window.__EXPERIMENTAL_NEXT_TESTING__ global and the page.evaluate() calls that went with it.
Adds a companion test suite that verifies the Instant Navigation
Testing API works with the legacy prefetch model (no Cache Components /
PPR). Without Cache Components, default prefetch renders up to the
first loading.tsx boundary, and prefetch={true} eagerly fetches the
full page.
Tests cover: loading shell rendered instantly during navigation, full
prefetch content rendered instantly, nested instant scope error, and
normal navigation after scope exits.
MPA tests are intentionally excluded — without PPR there is no static
shell concept for MPA navigations, so those tests have no analog here.
Failing test suitesCommit: 63fc988 | About building and testing Next.js
Expand output● runtime prefetching › passed to a public cache › can completely prefetch a page that uses cookies and no uncached IO ● runtime prefetching › passed to a public cache › can completely prefetch a page that uses cookies and no uncached IO ● runtime prefetching › passed to a public cache › can completely prefetch a page that uses cookies and no uncached IO ● runtime prefetching › passed to a public cache › can completely prefetch a page that uses cookies and no uncached IO
Expand output● app-dir static-generation-status › should render the page using notFound with status 404 ● app-dir static-generation-status › should render the page using redirect with status 307 ● app-dir static-generation-status › should render the client page using redirect with status 307 ● app-dir static-generation-status › should respond with 308 status code if permanent flag is set ● app-dir static-generation-status › should render the non existed route redirect with status 404 |
Based on:
Adds a companion test suite that verifies the Instant Navigation Testing API works with the legacy prefetch model (no Cache Components / PPR). Without Cache Components, default prefetch renders up to the first loading.tsx boundary, and prefetch={true} eagerly fetches the full page.
Tests cover: loading shell rendered instantly during navigation, full prefetch content rendered instantly, nested instant scope error, and normal navigation after scope exits.
MPA tests are intentionally excluded — without PPR there is no static shell concept for MPA navigations, so those tests have no analog here.