prefix stringlengths 512 512 | suffix stringlengths 256 256 | middle stringlengths 14 229 | meta dict |
|---|---|---|---|
rom 'next/server'
import { ReactNode, Suspense } from 'react'
// A cache fill in the Dynamic stage (after `connection()`) should not be
// subject to the dev fill timeout — and the probe-watchdog is skipped for
// the same reason. Both are gated on `outerWorkUnitStore.cacheSignal` /
// the Dynamic-stage check in `gene... | , 12_000))
return <p id="cached">cached</p>
}
async function Dynamic(): Promise<ReactNode> {
await connection()
return <Cached />
}
export default function Page() {
return (
<Suspense fallback="Loading...">
<Dynamic />
</Suspense> |
await new Promise((resolve) => setTimeout(resolve | {
"filepath": "test/e2e/app-dir/use-cache-deadlock-probe/app/dynamic/page.tsx",
"language": "tsx",
"file_size": 852,
"cut_index": 535,
"middle_length": 52
} |
pped,
} = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
if (skipped) {
return
}
if (isDev) {
// TODO-APP: re-enable after reworking the error overlay.
describe.skip('Missing required tags', () => {
it('should error on page load', async () => {
const browser = a... | const browser = await next.browser('/has-tags', {
waitHydration: false,
})
await browser.elementByCss('a').click()
await waitForRedbox(browser)
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
| "Please make sure to include the following tags in your root layout: <html>, <body>.
Missing required root layout tags: html, body"
`)
})
it('should error on page navigation', async () => {
| {
"filepath": "test/e2e/app-dir/root-layout/root-layout.test.ts",
"language": "typescript",
"file_size": 8495,
"cut_index": 716,
"middle_length": 229
} |
-without-exports', () => {
const { next } = nextTestSetup({
files: __dirname,
})
describe('"type": "commonjs" in package.json', () => {
it('should render without errors: import cjs', async () => {
const $ = await next.render$('/import-cjs')
expect($('p').text()).toContain('lib-cjs: esm')
... | it('should render without errors: import esm', async () => {
const $ = await next.render$('/import-esm')
expect($('p').text()).toContain('lib-esm: esm')
})
it('should render without errors: require esm', async () => {
const $ | scribe('"type": "module" in package.json', () => {
| {
"filepath": "test/e2e/app-dir/client-module-with-package-type/index.test.ts",
"language": "typescript",
"file_size": 996,
"cut_index": 582,
"middle_length": 52
} |
from 'e2e-utils'
import { waitForNoRedbox, retry } from 'next-test-utils'
describe('app-dir - action-in-pages-router', () => {
const { next, isNextStart } = nextTestSetup({
files: __dirname,
})
it('should not error on fake server action in pages router', async () => {
const browser = await next.browser(... | art) {
// Disabling for turbopack because the chunk path are different
if (!process.env.IS_TURBOPACK_TEST) {
it('should not contain server action in page bundle', async () => {
const pageBundle = await next.readFile('.next/server/page | > item.message)
.join('')
// This is a fake server action, a simple function so it can still work
expect(browserLogText).toContain('action:foo')
await waitForNoRedbox(browser)
})
})
if (isNextSt | {
"filepath": "test/e2e/app-dir/action-in-pages-router/action-in-pages-router.test.ts",
"language": "typescript",
"file_size": 1651,
"cut_index": 537,
"middle_length": 229
} |
import { nextTestSetup } from 'e2e-utils'
import { check } from 'next-test-utils'
describe('app dir - emotion-js', () => {
const { next, skipped } = nextTestSetup({
files: __dirname,
skipDeployment: true,
dependencies: {
'@emotion/react': 'latest',
'@emotion/cache': 'latest',
},
})
i... |
const el2 = browser.elementByCss('p')
expect(await el2.text()).toBe('Red')
await check(
async () =>
await browser.eval(
`window.getComputedStyle(document.querySelector('p')).color`
),
'rgb(255, 0, 0)'
| ntByCss('h1')
expect(await el.text()).toBe('Blue')
await check(
async () =>
await browser.eval(
`window.getComputedStyle(document.querySelector('h1')).color`
),
'rgb(0, 0, 255)'
) | {
"filepath": "test/e2e/app-dir/emotion-js/index.test.ts",
"language": "typescript",
"file_size": 1008,
"cut_index": 512,
"middle_length": 229
} |
dy.on('end', resolve)
})
return result
}
describe('app dir - external dependency', () => {
const { next, skipped } = nextTestSetup({
files: __dirname,
dependencies: {
swr: '2.2.5',
undici: '6.21.0',
},
packageJson: {
scripts: {
build: 'next build',
dev: 'next dev... |
const result = await resolveStreamResponse(response)
expect(result).toContain('Server: index.default')
expect(result).toContain('Server subpath: subpath.default')
expect(result).toContain('Client: index.default')
expect(resul | eployment: true,
})
if (skipped) {
return
}
it('should be able to opt-out 3rd party packages being bundled in server components', async () => {
await next.fetch('/react-server/optout').then(async (response) => { | {
"filepath": "test/e2e/app-dir/app-external/app-external.test.ts",
"language": "typescript",
"file_size": 11644,
"cut_index": 921,
"middle_length": 229
} |
_cacheLife, cacheLife } from 'next/cache'
export default async function Page() {
const stable = await stableLife()
const unstable1 = await unstableLife1()
const unstable2 = await unstableLife2()
return (
<>
<div>
This page calls a "use cache" function that uses the unstable_cacheLife
... | {
'use cache'
unstable_cacheLife('minutes')
return Math.random()
}
async function unstableLife2() {
'use cache'
unstable_cacheLife('minutes')
return Math.random()
}
async function stableLife() {
'use cache'
cacheLife('minutes')
return | </div>
</>
)
}
async function unstableLife1() | {
"filepath": "test/e2e/app-dir/cache-components-errors/fixtures/unstable-deprecations/app/life/page.tsx",
"language": "tsx",
"file_size": 853,
"cut_index": 529,
"middle_length": 52
} |
a realistic migration hazard. The documented "preload"
// pattern (see the "Preloading data" section of the
// caching-without-cache-components guide in the Next.js docs) wraps the loader
// in `React.cache`, so its store is tied to the ALS snapshot — `'use cache'`
// bodies run in a clean snapshot and miss, re-executi... | ed fetch in the outer scope returns a
// hanging promise that intentionally never resolves.
// - In dev, the outer fetch is parked on the Dynamic stage, which can't
// advance until the cache fills. The cache awaits the outer fetch via the
// | e map lives above ALS, so a
// `'use cache'` body joining it reuses the outer-scope promise (request scope
// or prerender scope) — a promise that was never meant to resolve for the
// cache:
// - During prerendering, an uncach | {
"filepath": "test/e2e/app-dir/use-cache-deadlock-probe/app/shared.ts",
"language": "typescript",
"file_size": 1661,
"cut_index": 537,
"middle_length": 229
} |
ort { cookies } from 'next/headers'
import { Suspense } from 'react'
import { getData, preload } from '../shared'
const sharedUrl =
'https://next-data-api-endpoint.vercel.app/api/random?page=runtime'
async function getCachedData(): Promise<string> {
'use cache'
// Joins the outer fetch via the module-scoped de... | n Runtime() {
await cookies()
// Simulate another part of the tree (e.g. a sibling component or a shared
// data loader) kicking off the same fetch in outer scope before `Cached`
// runs.
preload(sharedUrl)
return <Cached />
}
export default | hen the
// invocation is wrapped in a try/catch.
try {
const data = await getCachedData()
return <p id="result">{data}</p>
} catch (error) {
return <p id="result">Error: {error.message}</p>
}
}
async functio | {
"filepath": "test/e2e/app-dir/use-cache-deadlock-probe/app/runtime/page.tsx",
"language": "tsx",
"file_size": 1107,
"cut_index": 515,
"middle_length": 229
} |
ployment: true,
env: {
NEXT_TEST_LOG_VALIDATION: '1',
},
})
if (skipped) return
if (isNextStart && !isTurbopack) {
it.skip('TODO: snapshot tests for webpack', () => {})
return
}
if (isNextStart) {
beforeAll(async () => {
await next.build({ args: ['--experimental-build-mode', ... | arning'. Implicit validation fires on bare
// pages in dev only — build does not validate unless a segment
// explicitly escalates with `level: 'experimental-error'`. Per-segment overrides
// (`level`, `true`, `false`) layer on top of this.
//
// | string) => {
return await next.build({
args: [
'--experimental-build-mode',
'generate',
'--debug-build-paths',
`app${pathname}/page.tsx`,
],
})
}
// Validation level is 'w | {
"filepath": "test/e2e/app-dir/instant-validation-level-warning/instant-validation-level-warning.test.ts",
"language": "typescript",
"file_size": 9547,
"cut_index": 921,
"middle_length": 229
} |
om 'next/headers'
import { refresh } from 'next/cache'
import { redirect } from 'next/navigation'
export async function addTodoEntry(entry: string) {
// simulate some latency
await new Promise((resolve) => setTimeout(resolve, 500))
const cookieStore = await cookies()
const existing = cookieStore.get('todo-ent... | ookieStore.get('todo-entries')?.value || '[]'
return JSON.parse(existing) as string[]
}
export async function addEntryAndRefresh(formData: FormData) {
const entry = formData.get('entry') as string
await addTodoEntry(entry)
refresh()
redirect(' | t cookieStore = await cookies()
const existing = c | {
"filepath": "test/e2e/app-dir/refresh/app/redirect-and-refresh/actions.ts",
"language": "typescript",
"file_size": 885,
"cut_index": 547,
"middle_length": 52
} |
import { Suspense } from 'react'
import Link from 'next/link'
export default async function Page() {
return (
<main>
<section>
<p>
This page has has a slow to fill cache. When not bypassing the dev
cache the initial load should be slow while the cache warms up. You
won... | pense fallback={<p>Loading from cache...</p>}>
<CachedData />
</Suspense>
</section>
<Link href="/other">/Other</Link>
</main>
)
}
async function CachedData() {
'use cache'
await new Promise((r) => setTimeout(r, 20 | Suspend When bypassing caches in
dev with "disable cache" the request should instantly show a fallback
UI and show the final content after the delay.
</p>
</section>
<section>
<Sus | {
"filepath": "test/e2e/app-dir/cache-components-errors/fixtures/dev-cache-bypass/app/page.tsx",
"language": "tsx",
"file_size": 1026,
"cut_index": 512,
"middle_length": 229
} |
e-events', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should not call onLoad multiple times', async () => {
const imageRequests = []
const browser = await next.browser('/fulfilled', {
beforePageLoad(page) {
page.on('request', (request) => {
if (request.r... | logs.length
})
expect(imageRequests).toEqual([expect.stringContaining('test')])
imageRequests.length = 0
await browser.locator(':text("Show Client image")').click()
await retry(async () => {
const logs = await browser.log()
| owser.log()
expect(
logs.slice(logsIdx).filter(({ source }) => source === 'error')
).toEqual([
{
source: 'error',
message: 'hydrated image load',
},
])
logsIdx = | {
"filepath": "test/e2e/app-dir/next-image-events/next-image-events.test.ts",
"language": "typescript",
"file_size": 4478,
"cut_index": 614,
"middle_length": 229
} |
utils'
import { getClientReferenceManifest } from 'next-test-utils'
describe('client-reference-chunking', () => {
const { next } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
it('should use the same chunks for client references across routes', async () => {
const browser = await next.... | let issueManifest = getClientReferenceManifest(next, '/issue/page')
// These two routes have the same client component references, so these should be exactly the
// same (especially the `chunks` field)
expect(rootManifest.clientModules).to | anifest = getClientReferenceManifest(next, '/page')
| {
"filepath": "test/e2e/app-dir/client-reference-chunking/client-reference-chunking.test.ts",
"language": "typescript",
"file_size": 898,
"cut_index": 547,
"middle_length": 52
} |
rver'
import { Suspense } from 'react'
export default async function Page({ params }) {
return (
<>
<p>
This page accesses params synchronously. This does not trigger dynamic,
and the build should succeed. In dev mode, we do log an error for the
sync access though.
</p>
... | ' '}
<span id="param">{String(params.slug)}</span>
</div>
)
}
// This component ensures that we're creating a partially prerendered page, so
// that we also test that there are no sync params defined during the
// resume.
async function Dynami | this component read the `slug` param synchronously:{ | {
"filepath": "test/e2e/app-dir/cache-components-errors/fixtures/default/app/sync-server-params/[slug]/page.tsx",
"language": "tsx",
"file_size": 899,
"cut_index": 547,
"middle_length": 52
} |
next/headers'
import { Suspense } from 'react'
import { getData, preload } from '../shared'
const sharedUrl =
'https://next-data-api-endpoint.vercel.app/api/random?page=private-cookies'
// A `'use cache: private'` body that legitimately reads `cookies()` AND
// joins the module-scoped hanging promise from `shared.t... | napshot
// forwarding regresses, this fixture catches it before any "no-snapshot"
// fallback path.
async function getCachedData(): Promise<string> {
'use cache: private'
// Read a cookie — exercises the worker's reconstructed `cookies` object.
cons | hrowing).
// 2. Run the body in a fresh module scope so `getData(sharedUrl)` returns
// a fresh fetch instead of joining the outer scope's hanging promise.
//
// Both pieces have to work for this test to pass; if request-s | {
"filepath": "test/e2e/app-dir/use-cache-deadlock-probe/app/private-cookies/page.tsx",
"language": "tsx",
"file_size": 1827,
"cut_index": 537,
"middle_length": 229
} |
pect from 'expect'
describe('cache-components', () => {
const { next, isNextDev, skipped } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
if (skipped) {
return
}
it('should not have route specific errors', async () => {
expect(next.cliOutput).not.toMatch('Error: Route "/')
... | ).text()).toBe('at buildtime')
expect($('#page').text()).toBe('at buildtime')
expect($('#value').text()).toMatch(/^\d+$/)
}
})
it('should prerender pages with cached `Date()` calls', async () => {
let $ = await next.render$('/date/ | now/cached', {})
if (isNextDev) {
expect($('#layout').text()).toBe('at runtime')
expect($('#page').text()).toBe('at runtime')
expect($('#value').text()).toMatch(/^\d+$/)
} else {
expect($('#layout' | {
"filepath": "test/e2e/app-dir/cache-components/cache-components.date.test.ts",
"language": "typescript",
"file_size": 2966,
"cut_index": 563,
"middle_length": 229
} |
pense } from 'react'
import { cookies } from 'next/headers'
import { getSentinelValue } from '../../getSentinelValue'
export default async function Page() {
return (
<>
<p>This page calls `cookies()` in a child component.</p>
<p>
With PPR this page can be partially static because the dynami... | SentinelValue()}</div>
</>
)
}
async function ComponentThatReadsCookies() {
let sentinelCookie
try {
const cookie = (await cookies()).get('x-sentinel')
if (cookie) {
sentinelCookie = cookie.value
} else {
sentinelCookie = | ing...">
<ComponentThatReadsCookies />
</Suspense>
<Suspense fallback="loading too...">
<OtherComponent />
<div id="inner">{getSentinelValue()}</div>
</Suspense>
<div id="page">{get | {
"filepath": "test/e2e/app-dir/cache-components/app/cases/dynamic_api_cookies/page.tsx",
"language": "tsx",
"file_size": 1346,
"cut_index": 524,
"middle_length": 229
} |
'react'
import { getSentinelValue } from '../../getSentinelValue'
export default async function Page() {
await 1
return (
<>
<p>
This page renders two components. The first calls a simulated IO
function wrapped in `"use cache""`. The second calls the simulated IO
function without... | />
</Suspense>
<Suspense fallback="loading too...">
<ComponentTwo />
<div id="inner">{getSentinelValue()}</div>
</Suspense>
<div id="page">{getSentinelValue()}</div>
</>
)
}
async function ComponentOne() {
r | hed
IO result and a loading state for the boundary surrounding the uncached
IO result.
</p>
<p>Without PPR this page should be dynamic.</p>
<Suspense fallback="loading...">
<ComponentOne | {
"filepath": "test/e2e/app-dir/cache-components/app/cases/use_cache_mixed/page.tsx",
"language": "tsx",
"file_size": 1521,
"cut_index": 537,
"middle_length": 229
} |
'react'
import { unstable_cache as cache } from 'next/cache'
import { getSentinelValue } from '../../getSentinelValue'
export default async function Page() {
await 1
return (
<>
<p>
This page renders two components. The first calls a simulated IO
function wrapped in `unstable_cache`. The... | <Suspense fallback="loading...">
<ComponentOne />
</Suspense>
<Suspense fallback="loading too...">
<ComponentTwo />
<div id="inner">{getSentinelValue()}</div>
</Suspense>
<div id="page">{getSentinelValue()} | his page should have a static shell that includes the cached
IO result and a loading state for the boundary surrounding the uncached
IO result.
</p>
<p>Without PPR this page should be dynamic.</p>
| {
"filepath": "test/e2e/app-dir/cache-components/app/cases/io_mixed/page.tsx",
"language": "tsx",
"file_size": 1525,
"cut_index": 537,
"middle_length": 229
} |
port { Suspense } from 'react'
export async function generateStaticParams() {
const set = new Set()
set.add(await fetchRandom('a'))
set.add(await fetchRandom('a'))
return Array.from(set).map((value) => {
return {
slug: ('' + value).slice(2),
}
})
}
export default async function Layout({ child... | {(await params).slug}</h1>
<section>{children}</section>
</>
)
}
const fetchRandom = async (entropy: string) => {
const response = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random?b=' + entropy
)
return response.tex | <>
<h1> | {
"filepath": "test/e2e/app-dir/cache-components/app/params/generate-static-params/[slug]/layout.tsx",
"language": "tsx",
"file_size": 790,
"cut_index": 514,
"middle_length": 14
} |
./../../../../../getSentinelValue'
export default async function Page({
params,
children,
}: {
params: Promise<{ lowcard: string; highcard: string }>
children: React.ReactNode
}) {
return (
<section>
<p>
This Layout does key checking of the params prop in a server component
</p>
... | {'' + Reflect.has(await params, 'highcard')}
</span>
</div>
<div>
page foo:{' '}
<span id="param-has-foo">{'' + Reflect.has(await params, 'foo')}</span>
</div>
<span id="page">{getSentinelValue()}</span>
| '}
<span id="param-has-highcard">
| {
"filepath": "test/e2e/app-dir/cache-components/app/params/semantics/[lowcard]/[highcard]/layout-has/server/layout.tsx",
"language": "tsx",
"file_size": 889,
"cut_index": 547,
"middle_length": 52
} |
/getSentinelValue'
export default function Page({
params,
children,
}: {
params: Promise<{ lowcard: string; highcard: string }>
children: React.ReactNode
}) {
return (
<section>
<p>
This Layout does key checking of the params prop in a client component
</p>
<div>
page lo... | arams), 'highcard')}
</span>
</div>
<div>
page foo:{' '}
<span id="param-has-foo">{'' + Reflect.has(use(params), 'foo')}</span>
</div>
<span id="page">{getSentinelValue()}</span>
{children}
</sectio | ram-has-highcard">
{'' + Reflect.has(use(p | {
"filepath": "test/e2e/app-dir/cache-components/app/params/semantics/[lowcard]/[highcard]/layout-has/client/layout.tsx",
"language": "tsx",
"file_size": 923,
"cut_index": 606,
"middle_length": 52
} |
rt { getSentinelValue } from '../../../../../../getSentinelValue'
export default async function Page({
params,
}: {
params: Promise<{ lowcard: string; highcard: string }>
}) {
return (
<section>
<p>
This Page does key checking of the params prop in a server component
</p>
<div>
... | ct.has(await params, 'highcard')}
</span>
</div>
<div>
page foo:{' '}
<span id="param-has-foo">{'' + Reflect.has(await params, 'foo')}</span>
</div>
<span id="page">{getSentinelValue()}</span>
</section>
| <span id="param-has-highcard">
{'' + Refle | {
"filepath": "test/e2e/app-dir/cache-components/app/params/semantics/[lowcard]/[highcard]/page-has/server/page.tsx",
"language": "tsx",
"file_size": 830,
"cut_index": 516,
"middle_length": 52
} |
ort { use } from 'react'
import { getSentinelValue } from '../../../../../../getSentinelValue'
export default function Page({
params,
}: {
params: Promise<{ lowcard: string; highcard: string }>
}) {
return (
<section>
<p>
This Page does key checking of the params prop in a client component
... | >
{'' + Reflect.has(use(params), 'highcard')}
</span>
</div>
<div>
page foo:{' '}
<span id="param-has-foo">{'' + Reflect.has(use(params), 'foo')}</span>
</div>
<span id="page">{getSentinelValue()}</ | highcard:{' '}
<span id="param-has-highcard" | {
"filepath": "test/e2e/app-dir/cache-components/app/params/semantics/[lowcard]/[highcard]/page-has/client/page.tsx",
"language": "tsx",
"file_size": 864,
"cut_index": 529,
"middle_length": 52
} |
e } from '../../../../../../getSentinelValue'
export default async function Page({
params,
children,
}: {
params: Promise<{ lowcard: string; highcard: string }>
children: React.ReactNode
}) {
const copied = { ...(await params) }
return (
<section>
<p>
This Layout spreads params in a serve... | ghcard">{copied.highcard}</span>
</div>
<div>
param key count:{' '}
<span id="param-key-count">{Object.keys(copied).length}</span>
</div>
<span id="page">{getSentinelValue()}</span>
{children}
</section>
| aram-copied-hi | {
"filepath": "test/e2e/app-dir/cache-components/app/params/semantics/[lowcard]/[highcard]/layout-spread/server/layout.tsx",
"language": "tsx",
"file_size": 810,
"cut_index": 536,
"middle_length": 14
} |
use } from 'react'
import { getSentinelValue } from '../../../../../../getSentinelValue'
export default function Page({
params,
children,
}: {
params: Promise<{ lowcard: string; highcard: string }>
children: React.ReactNode
}) {
const copied = { ...use(params) }
return (
<section>
<p>
Th... | ard">{copied.highcard}</span>
</div>
<div>
param key count:{' '}
<span id="param-key-count">{Object.keys(copied).length}</span>
</div>
<span id="page">{getSentinelValue()}</span>
{children}
</section>
)
} |
page highcard: <span id="param-copied-highc | {
"filepath": "test/e2e/app-dir/cache-components/app/params/semantics/[lowcard]/[highcard]/layout-spread/client/layout.tsx",
"language": "tsx",
"file_size": 844,
"cut_index": 535,
"middle_length": 52
} |
SentinelValue } from '../../../../../../../../getSentinelValue'
export default async function Page({
params,
}: {
params: Promise<{ dyn: string; then: string; value: string; status: string }>
}) {
const copied = { ...(await params) }
return (
<section>
<p>
This Page accesses params that have ... | it params).then)}</span>
</li>
<li>
value:{' '}
<span id="param-value">{getValueAsString((await params).value)}</span>
</li>
<li>
status:{' '}
<span id="param-status">
{get | </p>
<ul>
<li>
dyn:{' '}
<span id="param-dyn">{getValueAsString((await params).dyn)}</span>
</li>
<li>
then:{' '}
<span id="param-then">{getValueAsString((awa | {
"filepath": "test/e2e/app-dir/cache-components/app/params/shadowing/[dyn]/[then]/[value]/[status]/page/server/page.tsx",
"language": "tsx",
"file_size": 1362,
"cut_index": 524,
"middle_length": 229
} |
import { use } from 'react'
import { getSentinelValue } from '../../../../../../../../getSentinelValue'
export default function Page({
params,
}: {
params: Promise<{ dyn: string; then: string; value: string; status: string }>
}) {
const copied = { ...use(params) }
return (
<section>
<p>
Th... | lueAsString(use(params).then)}</span>
</li>
<li>
value:{' '}
<span id="param-value">{getValueAsString(use(params).value)}</span>
</li>
<li>
status:{' '}
<span id="param-status">{getVal | and all params if you await
</p>
<ul>
<li>
dyn: <span id="param-dyn">{getValueAsString(use(params).dyn)}</span>
</li>
<li>
then:{' '}
<span id="param-then">{getVa | {
"filepath": "test/e2e/app-dir/cache-components/app/params/shadowing/[dyn]/[then]/[value]/[status]/page/client/page.tsx",
"language": "tsx",
"file_size": 1345,
"cut_index": 524,
"middle_length": 229
} |
SentinelValue } from '../../../../../../../../getSentinelValue'
export default async function Page({
params,
children,
}: {
params: Promise<{ dyn: string; then: string; value: string; status: string }>
children: React.ReactNode
}) {
const copied = { ...(await params) }
return (
<section>
<p>
... | pan id="param-then">{getValueAsString((await params).then)}</span>
</li>
<li>
value:{' '}
<span id="param-value">{getValueAsString((await params).value)}</span>
</li>
<li>
status:{' '}
| directly and all params if you await
</p>
<ul>
<li>
dyn:{' '}
<span id="param-dyn">{getValueAsString((await params).dyn)}</span>
</li>
<li>
then:{' '}
<s | {
"filepath": "test/e2e/app-dir/cache-components/app/params/shadowing/[dyn]/[then]/[value]/[status]/layout/server/layout.tsx",
"language": "tsx",
"file_size": 1421,
"cut_index": 524,
"middle_length": 229
} |
import { use } from 'react'
import { getSentinelValue } from '../../../../../../../../getSentinelValue'
export default function Layout({
params,
children,
}: {
params: Promise<{ dyn: string; then: string; value: string; status: string }>
children: React.ReactNode
}) {
const copied = { ...use(params) }
r... | {' '}
<span id="param-then">{getValueAsString(use(params).then)}</span>
</li>
<li>
value:{' '}
<span id="param-value">{getValueAsString(use(params).value)}</span>
</li>
<li>
status:{' | access non colliding param names directly and all params if you await
</p>
<ul>
<li>
dyn: <span id="param-dyn">{getValueAsString(use(params).dyn)}</span>
</li>
<li>
then: | {
"filepath": "test/e2e/app-dir/cache-components/app/params/shadowing/[dyn]/[then]/[value]/[status]/layout/client/layout.tsx",
"language": "tsx",
"file_size": 1406,
"cut_index": 524,
"middle_length": 229
} |
{ Suspense } from 'react'
import { getSentinelValue } from '../../../getSentinelValue'
type AnySearchParams = { [key: string]: string | string[] | undefined }
export default async function Page({
searchParams,
}: {
searchParams: Promise<AnySearchParams>
}) {
return (
<>
<p>
This page awaits ... | ense>
<ComponentTwo />
</Suspense>
</>
)
}
async function Component({
searchParams,
}: {
searchParams: Promise<AnySearchParams>
}) {
const params = await searchParams
return (
<>
<div>
This component accessed | tic page</p>
<p>Without PPR we expect the page to be dynamic</p>
<Suspense fallback="outer loading...">
<Suspense fallback="inner loading...">
<Component searchParams={searchParams} />
</Susp | {
"filepath": "test/e2e/app-dir/cache-components/app/search/server/await/page.tsx",
"language": "tsx",
"file_size": 1201,
"cut_index": 518,
"middle_length": 229
} |
{ getSentinelValue } from '../../../getSentinelValue'
import { Suspense, use } from 'react'
type AnySearchParams = { [key: string]: string | string[] | undefined }
export default async function Page({
searchParams,
}: {
searchParams: Promise<AnySearchParams>
}) {
return (
<>
<p>
This page `u... |
)
}
function Component({
searchParams,
}: {
searchParams: Promise<AnySearchParams>
}) {
const params = use(searchParams)
return (
<>
<div>
This component accessed `searchParams.sentinel`: "
<span id="value">{params.sen | be dynamic</p>
<Suspense fallback="outer loading...">
<Suspense fallback="inner loading...">
<Component searchParams={searchParams} />
</Suspense>
<ComponentTwo />
</Suspense>
</> | {
"filepath": "test/e2e/app-dir/cache-components/app/search/server/use/page.tsx",
"language": "tsx",
"file_size": 1138,
"cut_index": 518,
"middle_length": 229
} |
lient'
import { Suspense, use } from 'react'
import { getSentinelValue } from '../../../getSentinelValue'
type AnySearchParams = { [key: string]: string | string[] | undefined }
export default function Page({
searchParams,
}: {
searchParams: Promise<AnySearchParams>
}) {
return (
<>
<p>
This... | </Suspense>
<ComponentTwo />
</Suspense>
</>
)
}
function Component({
searchParams,
}: {
searchParams: Promise<AnySearchParams>
}) {
const params = use(searchParams)
return (
<>
<div>
This component ac | partially static page</p>
<p>Without PPR we expect the page to be dynamic</p>
<Suspense fallback="outer loading...">
<Suspense fallback="inner loading...">
<Component searchParams={searchParams} />
| {
"filepath": "test/e2e/app-dir/cache-components/app/search/client/use/page.tsx",
"language": "tsx",
"file_size": 1208,
"cut_index": 518,
"middle_length": 229
} |
lValue } from '../../../getSentinelValue'
/**
* This test case is constructed to demonstrate how using the async form of cookies can lead to a better
* prerender with cache components when PPR is on. There is no difference when PPR is off. When PPR is on the second component
* can finish rendering before the prerend... | >
<ComponentTwo />
<div id="page">{getSentinelValue()}</div>
</>
)
}
async function Component() {
await connection()
return (
<div>
cookie <span id="foo">foo</span>
</div>
)
}
function ComponentTwo() {
return <p>fo | "loading...">
<Component />
</Suspense | {
"filepath": "test/e2e/app-dir/cache-components/app/connection/static-behavior/boundary/page.tsx",
"language": "tsx",
"file_size": 925,
"cut_index": 606,
"middle_length": 52
} |
{ Suspense } from 'react'
import { connection } from 'next/server'
import { getSentinelValue } from '../../../getSentinelValue'
export default async function Page() {
const pendingConnection = connection()
return (
<section>
<h1>Deep Connection Reader</h1>
<p>
This component was passed th... | <div id="fallback">{getSentinelValue()}</div>
</>
}
>
<DeepConnectionReader pendingConnection={pendingConnection} />
</Suspense>
</section>
)
}
async function DeepConnectionReader({
pendingConnection,
} | trigger a
dynamic point at the callsite and the suspense boundary would also be
blocked for over one second
</p>
<Suspense
fallback={
<>
<p>loading connection...</p>
| {
"filepath": "test/e2e/app-dir/cache-components/app/connection/static-behavior/pass-deeply/page.tsx",
"language": "tsx",
"file_size": 1209,
"cut_index": 518,
"middle_length": 229
} |
ies
expression: string
}) {
return (
<>
<ForOf cookies={cookies} expression={expression} />
<Spread cookies={cookies} expression={expression} />
<Size cookies={cookies} expression={expression} />
<GetAndGetAll cookies={cookies} expression={expression} />
<Has cookies={cookies} expr... | cookie] of cookies) {
if (cookieName.startsWith('x-sentinel')) {
output.push(
<div key={cookieName} id={'for-of-' + cookieName}>
<pre>{print(cookie)}</pre>
</div>
)
}
}
return (
<section>
<h2>for | />
<ToString cookies={cookies} expression={expression} />
</>
)
}
function ForOf({
cookies,
expression,
}: {
cookies: ReadonlyRequestCookies
expression: string
}) {
let output = []
for (let [cookieName, | {
"filepath": "test/e2e/app-dir/cache-components/app/cookies/exercise/components.tsx",
"language": "tsx",
"file_size": 5772,
"cut_index": 716,
"middle_length": 229
} |
ort { Suspense } from 'react'
import { cookies } from 'next/headers'
import { getSentinelValue } from '../../getSentinelValue'
/**
* This test case is constructed to demonstrate how using the async form of cookies can lead to a better
* prerender with cache components when PPR is on. There is no difference when PPR ... | nelValue()}</div>
</Suspense>
)
}
async function Component() {
const cookie = (await cookies()).get('x-sentinel')
if (cookie && cookie.value) {
return (
<div>
cookie <span id="x-sentinel">{cookie.value}</span>
</div>
| */
export default async function Page() {
return (
<Suspense fallback="loading...">
<Suspense fallback="inner loading...">
<Component />
</Suspense>
<ComponentTwo />
<div id="page">{getSenti | {
"filepath": "test/e2e/app-dir/cache-components/app/cookies/static-behavior/page.tsx",
"language": "tsx",
"file_size": 1109,
"cut_index": 515,
"middle_length": 229
} |
'react'
import { cookies } from 'next/headers'
import { getSentinelValue } from '../../../getSentinelValue'
export default async function Page() {
const pendingCookies = cookies()
return (
<section>
<h1>Deep Cookie Reader</h1>
<p>
This component was passed the cookies promise returned by `... | spense boundary would also be
blocked for over one second
</p>
<Suspense
fallback={
<>
<p>loading cookie data...</p>
<div id="fallback">{getSentinelValue()}</div>
</>
}
> | vealing the cookie value even though cookies was called
at the page root.
</p>
<p>
If cacheComponents is turned off the `cookies()` call would trigger a
dynamic point at the callsite and the su | {
"filepath": "test/e2e/app-dir/cache-components/app/cookies/static-behavior/pass-deeply/page.tsx",
"language": "tsx",
"file_size": 1757,
"cut_index": 537,
"middle_length": 229
} |
aders={headers} expression={expression} />
<Delete headers={headers} expression={expression} />
<Get headers={headers} expression={expression} />
<Has headers={headers} expression={expression} />
<SetExercise headers={headers} expression={expression} />
<GetSetCookie headers={headers} expr... | on={expression} />
</>
)
}
function Append({
headers,
expression,
}: {
headers: Headers
expression: string
}) {
let result: string
try {
headers.append('x-sentinel', ' world')
result = 'no error'
} catch (e) {
result = e.me | ession={expression}
xSentinelValues={xSentinelValues}
/>
<Entries headers={headers} expression={expression} />
<ForOf headers={headers} expression={expression} />
<Spread headers={headers} expressi | {
"filepath": "test/e2e/app-dir/cache-components/app/headers/exercise/components.tsx",
"language": "tsx",
"file_size": 6932,
"cut_index": 716,
"middle_length": 229
} |
om '../../getSentinelValue'
import { AllComponents } from './components'
export default async function Page() {
const allHeaders = await headers()
const xSentinelValues = new Set<string>()
for (let [headerName, headerValue] of allHeaders.entries()) {
if (headerName.startsWith('x-sentinel')) {
xSentine... | y exists to ensure the behavior between sync and async
access is consistent for the time where you are permitted to do either
</p>
<AllComponents
headers={allHeaders}
xSentinelValues={xSentinelValues}
expression= | to consume headers() and this
test partiall | {
"filepath": "test/e2e/app-dir/cache-components/app/headers/exercise/page.tsx",
"language": "tsx",
"file_size": 983,
"cut_index": 582,
"middle_length": 52
} |
{ Suspense } from 'react'
import { headers } from 'next/headers'
import { getSentinelValue } from '../../getSentinelValue'
/**
* This test case is constructed to demonstrate how using the async form of cookies can lead to a better
* prerender with cache components when PPR is on. There is no difference when PPR is ... | Value()}</div>
</Suspense>
)
}
async function Component() {
const hasHeader = (await headers()).has('x-sentinel')
if (hasHeader) {
return (
<div>
header{' '}
<span id="x-sentinel">{(await headers()).get('x-sentinel')}</ |
export default async function Page() {
return (
<Suspense fallback="loading...">
<Suspense fallback="inner loading...">
<Component />
</Suspense>
<ComponentTwo />
<div id="page">{getSentinel | {
"filepath": "test/e2e/app-dir/cache-components/app/headers/static-behavior/page.tsx",
"language": "tsx",
"file_size": 1135,
"cut_index": 518,
"middle_length": 229
} |
'react'
import { headers } from 'next/headers'
import { getSentinelValue } from '../../../getSentinelValue'
export default async function Page() {
const pendingHeaders = headers()
return (
<section>
<h1>Deep Header Reader</h1>
<p>
This component was passed the headers promise returned by `... | spense boundary would also be
blocked for over one second
</p>
<Suspense
fallback={
<>
<p>loading header data...</p>
<div id="fallback">{getSentinelValue()}</div>
</>
}
> | vealing the header value even though headers was called
at the page root.
</p>
<p>
If cacheComponents is turned off the `headers()` call would trigger a
dynamic point at the callsite and the su | {
"filepath": "test/e2e/app-dir/cache-components/app/headers/static-behavior/pass-deeply/page.tsx",
"language": "tsx",
"file_size": 1749,
"cut_index": 537,
"middle_length": 229
} |
export default async function Page() {
const first = await getRandomIntBetween(1)
const second = await getRandomIntBetween(2)
return (
<div>
<dl>
<dt>[first] require('node:crypto').randomInt(min, max)</dt>
<dd id="first">{first}</dd>
<dt>[second] require('node:crypto').randomIn... | want to exercise the case where the function arguments are length 3
// but the third arg is still not a callback so it runs sync
return crypto.randomInt(0, 2 ** 48 - 1, undefined) as undefined as number
} else {
return crypto.randomInt(0, 2 | mber) {
'use cache'
if (nonce === 2) {
// We | {
"filepath": "test/e2e/app-dir/cache-components/app/node-crypto/random-int/between/cached/page.tsx",
"language": "tsx",
"file_size": 931,
"cut_index": 606,
"middle_length": 52
} |
xport default async function Page() {
const first = await getGeneratedKeyPair(1)
const second = await getGeneratedKeyPair(2)
return (
<div>
<dl>
<dt>
[first] require('node:crypto').generateKeyPairSync(type, options)
</dt>
<dd id="first">{first.publicKey}</dd>
<d... | ction getGeneratedKeyPair(_nonce: number) {
'use cache'
return crypto.generateKeyPairSync('rsa', {
modulusLength: 512,
publicKeyEncoding: {
type: 'spki',
format: 'pem',
},
privateKeyEncoding: {
type: 'pkcs8',
for | elValue />
</span>
</div>
)
}
async fun | {
"filepath": "test/e2e/app-dir/cache-components/app/node-crypto/generate-key-pair-sync/cached/page.tsx",
"language": "tsx",
"file_size": 940,
"cut_index": 606,
"middle_length": 52
} |
mport { nextTestSetup } from 'e2e-utils'
describe('app-dir - server components externals', () => {
const { next, isTurbopack, skipped } = nextTestSetup({
// This test is skipped when deployed because it relies on manually patched `node_modules`
skipDeployment: true,
files: __dirname,
})
if (skipped)... | )
})
it('uses externals for predefined list in server-external-packages.json', async () => {
const $ = await next.render$('/predefined')
const text = $('#directory').text()
expect(text).toBe(path.join(next.testDir, 'node_modules', 'sqli | = $('#subdirectory').text()
expect(text).toBe(
path.join(next.testDir, 'node_modules', 'external-package')
)
expect(subpath).toBe(
path.join(next.testDir, 'node_modules', 'external-package', 'subpath')
| {
"filepath": "test/e2e/app-dir/server-components-externals/index.test.ts",
"language": "typescript",
"file_size": 1747,
"cut_index": 537,
"middle_length": 229
} |
Start, isNextDev } = nextTestSetup({
files: path.join(__dirname, 'bundled'),
})
if (isNextStart) {
it('does not cause any routes to become (partially) dynamic', async () => {
const prerenderManifest = JSON.parse(
await next.readFile('.next/prerender-manifest.json')
)
// For the p... | if ('code' in err && err.code === 'ENOENT') {
// the route was prerendered, but we didn't find a HTML file for it.
// this means it must be a GET route handler, not a page
return true
} else {
| lename = route.replace(/^\//, '').replace(/^$/, 'index')
try {
return next
.readFileSync(`.next/server/app/${filename}.html`)
.endsWith('</html>')
} catch (err) {
| {
"filepath": "test/e2e/app-dir/cache-components-dynamic-imports/cache-components-dynamic-imports.test.ts",
"language": "typescript",
"file_size": 6189,
"cut_index": 716,
"middle_length": 229
} |
xtTestSetup({
files: __dirname,
skipDeployment: true,
})
if (skipped) {
return
}
it('should handle ssr: false in pages when appDir is enabled', async () => {
const $ = await next.render$('/legacy/no-ssr')
expect($.html()).not.toContain('navigator')
const browser = await next.browser('... | y
expect(serverContent).toContain('next-dynamic lazy')
// should support `dynamic` in both server and client components
expect(serverContent).toContain('next-dynamic dynamic on server')
expect(serverContent).toContain('next-dynamic dynamic |
const $ = await next.render$('/dynamic')
// filter out the script
const selector = 'body div'
const serverContent = $(selector).text()
// should load chunks generated via async import correctly with React.laz | {
"filepath": "test/e2e/app-dir/dynamic/dynamic.test.ts",
"language": "typescript",
"file_size": 6471,
"cut_index": 716,
"middle_length": 229
} |
Dev, skipped } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
if (skipped) {
return
}
it('should partially prerender pages that use headers', async () => {
let $ = await next.render$('/headers/static-behavior', {})
if (isNextDev) {
expect($('#layout').text()).toBe('at r... | () => {
const $ = await next.render$('/headers/static-behavior/pass-deeply')
if (isNextDev) {
expect($('#layout').text()).toBe('at runtime')
expect($('#fallback').text()).toBe('at runtime')
expect($('#page').text()).toBe('at runt | ($('#page').text()).toBe('at buildtime')
expect($('#x-sentinel').text()).toBe('hello')
}
})
it('should be able to pass headers as a promise to another component and trigger an intermediate Suspense boundary', async | {
"filepath": "test/e2e/app-dir/cache-components/cache-components.headers.test.ts",
"language": "typescript",
"file_size": 4126,
"cut_index": 614,
"middle_length": 229
} |
$ = await next.render$('/params/semantics/one/run/layout-access/server')
if (isNextDev) {
expect($('#layout').text()).toBe('at runtime')
expect($('#lowcard').text()).toBe('at runtime')
expect($('#highcard').text()).toBe('at runtime')
expect($('#page').text()).toBe('at runt... | highcard children')
expect($('#page').text()).toBe('at runtime')
expect($('#param-lowcard').text()).toBe('one')
expect($('#param-highcard').text()).toBe('run')
expect(getLines('Route "/params')).toEqual([])
}
$ | expect($('#layout').text()).toBe('at buildtime')
expect($('#lowcard').text()).toBe('at buildtime')
expect($('#highcard').text()).toBe('at buildtime')
expect($('#highcard-fallback').text()).toBe('loading | {
"filepath": "test/e2e/app-dir/cache-components/cache-components.params.test.ts",
"language": "typescript",
"file_size": 33952,
"cut_index": 2151,
"middle_length": 229
} |
{
return
}
let cliIndex = 0
beforeEach(() => {
cliIndex = next.cliOutput.length
})
function getLines(containing: string): Array<string> {
const warnings = next.cliOutput
.slice(cliIndex)
.split('\n')
.filter((l) => l.includes(containing))
cliIndex = next.cliOutput.length
... | expect(json.type).toEqual('headers')
str = await next.render('/routes/dynamic-stream', {})
json = JSON.parse(str)
expect(json.value).toEqual('at runtime')
expect(json.message).toEqual('dynamic stream')
str = await next.render('/r | rse(str)
expect(json.value).toEqual('at runtime')
expect(json.type).toEqual('cookies')
str = await next.render('/routes/dynamic-headers', {})
json = JSON.parse(str)
expect(json.value).toEqual('at runtime')
| {
"filepath": "test/e2e/app-dir/cache-components/cache-components.routes.test.ts",
"language": "typescript",
"file_size": 8663,
"cut_index": 716,
"middle_length": 229
} |
from 'e2e-utils'
import { waitForNoRedbox, retry } from 'next-test-utils'
describe('cache-components', () => {
const { next, isNextDev } = nextTestSetup({
files: __dirname,
})
it('should not fail decoding server action arguments', async () => {
const browser = await next.browser('/server-action')
ex... | er.elementByCss('p').text()).toBe('initial')
if (isNextDev) {
await waitForNoRedbox(browser)
}
await browser.elementByCss('button').click()
await retry(async () => {
expect(await browser.elementByCss('p').text()).toBe(
| ).toBe('result')
})
})
it('should not have cache components errors when encoding bound args for inline server actions', async () => {
const browser = await next.browser('/server-action-inline')
expect(await brows | {
"filepath": "test/e2e/app-dir/cache-components/cache-components.server-action.test.ts",
"language": "typescript",
"file_size": 1550,
"cut_index": 537,
"middle_length": 229
} |
from 'e2e-utils'
describe('cache-components', () => {
const { next, isNextDev, skipped } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
if (skipped) {
return
}
it('should not have route specific errors', async () => {
expect(next.cliOutput).not.toMatch('Error: Route "/')
e... | ond').text())
} else {
expect($('#layout').text()).toBe('at buildtime')
expect($('#page').text()).toBe('at buildtime')
expect($('#first').text()).not.toEqual($('#second').text())
}
})
it('should prerender pages with cached `c | render$('/web-crypto/get-random-values/cached', {})
if (isNextDev) {
expect($('#layout').text()).toBe('at runtime')
expect($('#page').text()).toBe('at runtime')
expect($('#first').text()).not.toEqual($('#sec | {
"filepath": "test/e2e/app-dir/cache-components/cache-components.web-crypto.test.ts",
"language": "typescript",
"file_size": 1525,
"cut_index": 537,
"middle_length": 229
} |
t } from 'next/server'
import { getSentinelValue } from '../../getSentinelValue'
export async function GET(request: NextRequest) {
const fetcheda = await fetchRandomCached('a')
const fetchedb = await fetchRandomUncached('b')
return new Response(
JSON.stringify({
value: getSentinelValue(),
random... | ropy,
{ cache: 'force-cache' }
)
return response.text()
}
const fetchRandomUncached = async (entropy: string) => {
const response = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random?b=' + entropy
)
return response.text() | ndom?b=' + ent | {
"filepath": "test/e2e/app-dir/cache-components/app/routes/fetch-mixed/route.ts",
"language": "typescript",
"file_size": 809,
"cut_index": 536,
"middle_length": 14
} |
ort { getSentinelValue } from '../../getSentinelValue'
export default async function Page() {
await 1
return (
<>
<p>
This page renders two components. Both call a simulated IO function
wrapped in `"use cache"`.
</p>
<p>Niether component is wrapped in a Suspense boundary</p>
... | nentTwo() {
return (
<>
<div>message 2: {await getCachedMessage('hello cached fast', 0)}</div>
<div>message 3: {await getCachedMessage('hello cached slow', 20)}</div>
</>
)
}
async function getCachedMessage(echo, delay) {
'use ca | tOne />
<ComponentTwo />
<div id="page">{getSentinelValue()}</div>
</>
)
}
async function ComponentOne() {
return <div>message 1: {await getCachedMessage('hello cached fast', 2)}</div>
}
async function Compo | {
"filepath": "test/e2e/app-dir/cache-components/app/cases/use_cache_cached/page.tsx",
"language": "tsx",
"file_size": 1070,
"cut_index": 515,
"middle_length": 229
} |
spense, use } from 'react'
import { getSentinelValue } from '../../getSentinelValue'
export default function Page({ searchParams }: { searchParams: Promise<any> }) {
return (
<>
<p>
This page reads `searchParams.foo` in a client component context with a
parent Suspense boundary.
</p>... | llback>loading too...</Fallback>}>
<ComponentTwo />
</Suspense>
<div id="page">{getSentinelValue()}</div>
</>
)
}
function ComponentOne({ searchParams }: { searchParams: Promise<any> }) {
let sentinelSearch
const sp = use(sea | ynamic because a dynamic API was used.
</p>
<Suspense fallback={<div id="fallback-component-one-">loading...</div>}>
<ComponentOne searchParams={searchParams} />
</Suspense>
<Suspense fallback={<Fa | {
"filepath": "test/e2e/app-dir/cache-components/app/cases/dynamic_api_search_params_client/page.tsx",
"language": "tsx",
"file_size": 1643,
"cut_index": 537,
"middle_length": 229
} |
pense } from 'react'
import { unstable_noStore as noStore } from 'next/cache'
import { getSentinelValue } from '../../getSentinelValue'
export default async function Page() {
// We wait for metadata to finish before rendering this component which will trigger
// a synchronous abort
await new Promise((r) => pro... | fallback="loading...">
<ComponentThatCallsNoStore />
</Suspense>
<Suspense fallback="loading too...">
<OtherComponent />
<div id="inner">{getSentinelValue()}</div>
</Suspense>
<div id="page">{getSentinelValue | his page can be partially static because the dynamic API usage
is inside a suspense boundary.
</p>
<p>
Without PPR this page is fully dynamic because a dynamic API was used.
</p>
<Suspense | {
"filepath": "test/e2e/app-dir/cache-components/app/cases/dynamic_api_no_store/page.tsx",
"language": "tsx",
"file_size": 1343,
"cut_index": 524,
"middle_length": 229
} |
pense } from 'react'
import { headers } from 'next/headers'
import { getSentinelValue } from '../../getSentinelValue'
export default async function Page() {
return (
<>
<p>This page calls `headers()` in a child component.</p>
<p>
With PPR this page can be partially static because the dynami... | SentinelValue()}</div>
</>
)
}
async function ComponentThatReadsHeaders() {
let sentinelHeader
try {
sentinelHeader = (await headers()).get('x-sentinel')
if (!sentinelHeader) {
sentinelHeader = '~not-found~'
}
} catch (e) {
| ing...">
<ComponentThatReadsHeaders />
</Suspense>
<Suspense fallback="loading too...">
<OtherComponent />
<div id="inner">{getSentinelValue()}</div>
</Suspense>
<div id="page">{get | {
"filepath": "test/e2e/app-dir/cache-components/app/cases/dynamic_api_headers/page.tsx",
"language": "tsx",
"file_size": 1308,
"cut_index": 524,
"middle_length": 229
} |
'react'
import { getSentinelValue } from '../../getSentinelValue'
export default async function Page() {
await 1
return (
<>
<p>
This page fetches using cache inside one component and without cache
inside another component.
</p>
<p>Each component is wrapped in a Suspense boun... | <div id="inner">{getSentinelValue()}</div>
</Suspense>
<div id="page">{getSentinelValue()}</div>
</>
)
}
async function ComponentOne() {
return <div>message 1: {await fetchRandomCached('a')}</div>
}
async function ComponentTwo() | tch result.
</p>
<p>Without PPR this page should be dynamic.</p>
<Suspense fallback="loading...">
<ComponentOne />
</Suspense>
<Suspense fallback="loading too...">
<ComponentTwo />
| {
"filepath": "test/e2e/app-dir/cache-components/app/cases/fetch_mixed/page.tsx",
"language": "tsx",
"file_size": 1575,
"cut_index": 537,
"middle_length": 229
} |
tResponse } from 'next/server'
import type { NextRequest } from 'next/server'
export function proxy(request: NextRequest) {
const pathname = request.nextUrl.pathname
// Rewrite /rewritten/[slug] to /actual/[slug]
// This creates a mismatch between URL and route structure that should
// mark the route as havin... | destination pages are fully static, so if we incorrectly use a cached
// pattern, we'd show the wrong content.
if (pathname === '/search-rewrite') {
const v = request.nextUrl.searchParams.get('v')
const url = request.nextUrl.clone()
url.pat | }`
return NextResponse.rewrite(url)
}
// Rewrite /search-rewrite?v=alpha to /rewrite-alpha
// Rewrite /search-rewrite?v=beta to /rewrite-beta
// This tests that search param rewrites are correctly detected.
// The | {
"filepath": "test/e2e/app-dir/optimistic-routing/proxy.ts",
"language": "typescript",
"file_size": 1253,
"cut_index": 524,
"middle_length": 229
} |
eState } from 'react'
import { useParams, usePathname, useSearchParams } from 'next/navigation'
type RenderedRouteEntry = {
url: string
params: Record<string, string | string[] | undefined>
}
/**
* Accumulates every [url, params] pair rendered throughout the app's lifetime.
* Uses the setState-in-render pattern... | const entry: RenderedRouteEntry = { url, params }
const entryJson = JSON.stringify(entry)
const [history, setHistory] = useState<string[]>([entryJson])
const [prevEntry, setPrevEntry] = useState(entryJson)
// setState-in-render pattern: update st | enderedRouteHistory() {
const params = useParams()
const pathname = usePathname()
const searchParams = useSearchParams()
const search = searchParams.toString()
const url = search ? `${pathname}?${search}` : pathname
| {
"filepath": "test/e2e/app-dir/optimistic-routing/components/rendered-route-history.tsx",
"language": "tsx",
"file_size": 1920,
"cut_index": 537,
"middle_length": 229
} |
n (
<div>
<h1>Optimistic Routing Test</h1>
<p>
This test verifies that route prediction works correctly. When a route
pattern is learned from one URL, navigating to a different URL with the
same pattern should show the loading state instantly.
</p>
<h2>Basic Dynamic ... | cordion>
</li>
</ul>
<h2>Nested Dynamic Route</h2>
<ul>
<li>
<LinkAccordion href="/products/electronics/phone-1">
Electronics - Phone 1
</LinkAccordion>
</li>
<li>
| lse}>
Blog Post 2 (prefetch disabled)
</LinkAccordion>
</li>
<li>
<LinkAccordion href="/blog/post-3" prefetch={false}>
Blog Post 3 (prefetch disabled)
</LinkAc | {
"filepath": "test/e2e/app-dir/optimistic-routing/app/page.tsx",
"language": "tsx",
"file_size": 4802,
"cut_index": 614,
"middle_length": 229
} |
tTestSetup } from 'e2e-utils'
describe('cache-components', () => {
const { next, isNextDev, skipped } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
if (skipped) {
return
}
it('should partially prerender pages that use connection', async () => {
let $ = await next.render$('/co... | on as a promise to another component and trigger an intermediate Suspense boundary', async () => {
const $ = await next.render$('/connection/static-behavior/pass-deeply')
if (isNextDev) {
expect($('#layout').text()).toBe('at runtime')
/ | ()).toBe('foo')
} else {
expect($('#layout').text()).toBe('at buildtime')
expect($('#page').text()).toBe('at buildtime')
expect($('#foo').text()).toBe('foo')
}
})
it('should be able to pass connecti | {
"filepath": "test/e2e/app-dir/cache-components/cache-components.connection.test.ts",
"language": "typescript",
"file_size": 1457,
"cut_index": 524,
"middle_length": 229
} |
from 'e2e-utils'
describe('cache-components', () => {
const { next, isNextDev, skipped } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
if (skipped) {
return
}
let cliIndex = 0
beforeEach(() => {
cliIndex = next.cliOutput.length
})
function getLines(containing: string): ... | .text()).toBe('at runtime')
expect($('#page').text()).toBe('at runtime')
expect($('#draft-mode').text()).toBe('false')
expect(getLines('Route "/draftmode')).toEqual([])
} else {
expect($('#layout').text()).toBe('at buildtime')
| ings
}
it('should fully prerender pages that use draftMode', async () => {
expect(getLines('Route "/draftmode')).toEqual([])
let $ = await next.render$('/draftmode', {})
if (isNextDev) {
expect($('#layout') | {
"filepath": "test/e2e/app-dir/cache-components/cache-components.draft-mode.test.ts",
"language": "typescript",
"file_size": 1813,
"cut_index": 537,
"middle_length": 229
} |
{
return
}
it('should not have route specific errors', async () => {
expect(next.cliOutput).not.toMatch('Error: Route "/')
expect(next.cliOutput).not.toMatch('Error occurred prerendering page')
})
it("should prerender pages with cached `require('node:crypto').getRandomValues(...)` calls", async ()... | xt()).not.toEqual($('#second').text())
}
})
it("should prerender pages with cached `require('node:crypto').randomUUID()` calls", async () => {
let $ = await next.render$('/node-crypto/random-uuid/cached', {})
if (isNextDev) {
expect( | ('at runtime')
expect($('#first').text()).not.toEqual($('#second').text())
} else {
expect($('#layout').text()).toBe('at buildtime')
expect($('#page').text()).toBe('at buildtime')
expect($('#first').te | {
"filepath": "test/e2e/app-dir/cache-components/cache-components.node-crypto.test.ts",
"language": "typescript",
"file_size": 5613,
"cut_index": 716,
"middle_length": 229
} |
('cache-components', () => {
const { next, isNextDev, skipped } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
if (skipped) {
return
}
it('should partially prerender pages that await searchParams in a server component', async () => {
let $ = await next.render$('/search/server/a... | toBe('hello')
expect($('#page').text()).toBe('at runtime')
}
})
it('should partially prerender pages that `use` searchParams in a server component', async () => {
let $ = await next.render$('/search/server/use?sentinel=hello')
if (is | )
} else {
expect($('#layout').text()).toBe('at buildtime')
expect($('main').text()).toContain('inner loading...')
expect($('main').text()).not.toContain('outer loading...')
expect($('#value').text()). | {
"filepath": "test/e2e/app-dir/cache-components/cache-components.search.test.ts",
"language": "typescript",
"file_size": 2602,
"cut_index": 563,
"middle_length": 229
} |
await next.browser('/cases/not-found')
const cliOutput = next.cliOutput.slice(cliOutputLength)
expect(cliOutput).not.toMatch('Error: NEXT_HTTP_ERROR_FALLBACK;404')
expect(cliOutput).not.toMatch('unhandledRejection')
})
} else {
it('should not warn about potential memory leak for even list... | ')
expect($('#page').text()).toBe('at buildtime')
}
$ = await next.render$('/cases/static_async', {})
if (isNextDev) {
expect($('#layout').text()).toBe('at runtime')
expect($('#page').text()).toBe('at runtime')
} else {
| wait next.render$('/cases/static', {})
if (isNextDev) {
expect($('#layout').text()).toBe('at runtime')
expect($('#page').text()).toBe('at runtime')
} else {
expect($('#layout').text()).toBe('at buildtime | {
"filepath": "test/e2e/app-dir/cache-components/cache-components.test.ts",
"language": "typescript",
"file_size": 19000,
"cut_index": 1331,
"middle_length": 229
} |
ache'
import { getSentinelValue } from '../../getSentinelValue'
export default async function Page({
searchParams: _unused,
}: {
searchParams: Promise<Record<string, string | string[] | undefined>>
}) {
return (
<>
<p>
This page renders two components. Both call a simulated IO function. The
... | ComponentOne() {
return <div>message 1: {await getMessage('hello cached fast', 2)}</div>
}
async function ComponentTwo() {
return (
<>
<div>message 2: {await getMessage('hello cached fast', 0)}</div>
<div>message 3: {await getMessage( | ll IO is cached.
</p>
<p>Without PPR this page should be static because all IO is cached.</p>
<ComponentOne />
<ComponentTwo />
<div id="page">{getSentinelValue()}</div>
</>
)
}
async function | {
"filepath": "test/e2e/app-dir/cache-components/app/cases/full_cached/page.tsx",
"language": "tsx",
"file_size": 1156,
"cut_index": 518,
"middle_length": 229
} |
{ unstable_cache as cache } from 'next/cache'
import { getSentinelValue } from '../../getSentinelValue'
export default async function Page() {
await 1
return (
<>
<p>
This page renders two components. Both call a simulated IO function
wrapped in `unstable_cache`.
</p>
<p>Nie... | 'hello cached fast', 2)}</div>
}
async function ComponentTwo() {
return (
<>
<div>message 2: {await getCachedMessage('hello cached fast', 0)}</div>
<div>message 3: {await getCachedMessage('hello cached slow', 20)}</div>
</>
)
}
as | e static because all IO is cached.</p>
<ComponentOne />
<ComponentTwo />
<div id="page">{getSentinelValue()}</div>
</>
)
}
async function ComponentOne() {
return <div>message 1: {await getCachedMessage( | {
"filepath": "test/e2e/app-dir/cache-components/app/cases/io_cached/page.tsx",
"language": "tsx",
"file_size": 1151,
"cut_index": 518,
"middle_length": 229
} |
ort { getSentinelValue } from '../../getSentinelValue'
export default async function Page() {
await 1
return (
<>
<p>
This page renders two components each performing one or more cached
fetches. There is no uncached IO in this example
</p>
<p>Niether component is wrapped in a ... | etchRandomCached('b')}</div>
<div>message 2: {await fetchRandomCached('c')}</div>
</>
)
}
const fetchRandomCached = async (entropy: string) => {
const response = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random?b=' + en | id="page">{getSentinelValue()}</div>
</>
)
}
async function ComponentOne() {
return <div>message 1: {await fetchRandomCached('a')}</div>
}
async function ComponentTwo() {
return (
<>
<div>message 2: {await f | {
"filepath": "test/e2e/app-dir/cache-components/app/cases/fetch_cached/page.tsx",
"language": "tsx",
"file_size": 1067,
"cut_index": 515,
"middle_length": 229
} |
client'
import Link, { type LinkProps } from 'next/link'
import { useState } from 'react'
export function LinkAccordion({
href,
children,
prefetch,
}: {
href: LinkProps['href']
children: React.ReactNode
prefetch?: LinkProps['prefetch']
}) {
// This component controls when prefetching happens by hiding ... | hange={() => setIsVisible(!isVisible)}
data-link-accordion={href}
/>
{isVisible ? (
<Link href={href} prefetch={prefetch}>
{children}
</Link>
) : (
`${children} (link is hidden)`
)}
</>
| e="checkbox"
checked={isVisible}
onC | {
"filepath": "test/e2e/app-dir/optimistic-routing/components/link-accordion.tsx",
"language": "tsx",
"file_size": 830,
"cut_index": 516,
"middle_length": 52
} |
from 'e2e-utils'
describe('client-reference-side-effects', () => {
const { next, isTurbopack } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
it('side effect behavior when only importing', async () => {
const browser = await next.browser('/imported')
expect(await browser.elementBy... | ffect_reexport).toBeUndefined()
expect(client_sideeffect_only).toBeUndefined()
})
it('side effect behavior when rendering', async () => {
const browser = await next.browser('/rendered')
const body = await browser.elementByCss('body').text |
)
let client_sideeffect_only = await browser.eval(
'window.client_sideeffect_only'
)
// No client references are rendered, so nothing is executed.
expect(client).toBeUndefined()
expect(client_sidee | {
"filepath": "test/e2e/app-dir/client-reference-side-effects/client-reference-side-effects.test.ts",
"language": "typescript",
"file_size": 1711,
"cut_index": 537,
"middle_length": 229
} |
Dev, skipped } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
if (skipped) {
return
}
it('should partially prerender pages that use cookies', async () => {
let $ = await next.render$('/cookies/static-behavior', {})
if (isNextDev) {
expect($('#layout').text()).toBe('at r... | () => {
const $ = await next.render$('/cookies/static-behavior/pass-deeply')
if (isNextDev) {
expect($('#layout').text()).toBe('at runtime')
expect($('#fallback').text()).toBe('at runtime')
expect($('#page').text()).toBe('at runt | ($('#page').text()).toBe('at buildtime')
expect($('#x-sentinel').text()).toBe('hello')
}
})
it('should be able to pass cookies as a promise to another component and trigger an intermediate Suspense boundary', async | {
"filepath": "test/e2e/app-dir/cache-components/cache-components.cookies.test.ts",
"language": "typescript",
"file_size": 3467,
"cut_index": 614,
"middle_length": 229
} |
} from 'next/server'
import { NextResponse } from 'next/server'
export function middleware(request: NextRequest) {
if (
request.nextUrl.pathname.startsWith('/headers/') ||
request.nextUrl.pathname.endsWith('dynamic_api_headers')
) {
// Clone the request headers and set a new header `x-hello-from-middl... | nst response = NextResponse.next()
if (
request.nextUrl.pathname.startsWith('/cookies/') ||
request.nextUrl.pathname.endsWith('dynamic_api_cookies')
) {
response.cookies.set('x-sentinel', 'hello', {
httpOnly: true,
sameSite: 's | ders.set(
'x-sentinel-rand',
((Math.random() * 100000) | 0).toString(16)
)
return NextResponse.next({
request: {
// New request headers
headers: requestHeaders,
},
})
}
co | {
"filepath": "test/e2e/app-dir/cache-components/middleware.ts",
"language": "typescript",
"file_size": 1546,
"cut_index": 537,
"middle_length": 229
} |
./../getSentinelValue'
export default async function Page() {
await 1
return (
<>
<p>
This page renders a deep tree of deeply async components that still
resolve within microtasks.
</p>
<p>With PPR this page should be entirely static.</p>
<p>Without PPR this page should ... | ar>
</Foo>
<div id="page">{getSentinelValue()}</div>
</>
)
}
async function Foo({ children }) {
await 1
await 1
return <ul>Foo: {children}</ul>
}
async function Bar({ children }) {
let length = 7
for (let i = 0; i < length; i+ | </Bar>
<Bar>3</Bar>
<Bar>4</B | {
"filepath": "test/e2e/app-dir/cache-components/app/cases/microtask_deep_tree/page.tsx",
"language": "tsx",
"file_size": 912,
"cut_index": 547,
"middle_length": 52
} |
xport default async function Page() {
await 1
return (
<>
<p>
This page renders a component that requires async IO. It is simulated
using setTimeout(f, 1000).
</p>
<p>
This component simulated IO component is rendered inside a Suspense
boundary
</p>
... | ">
<ComponentWithIO />
<div id="inner">{getSentinelValue()}</div>
</Suspense>
<div id="page">{getSentinelValue()}</div>
</>
)
}
async function ComponentWithIO() {
await new Promise<void>((r) => setTimeout(r, 1000))
re | be dynamic.</p>
<Suspense fallback="loading... | {
"filepath": "test/e2e/app-dir/cache-components/app/cases/task/page.tsx",
"language": "tsx",
"file_size": 937,
"cut_index": 606,
"middle_length": 52
} |
mport { Suspense } from 'react'
import { connection } from 'next/server'
import { LinkAccordion } from '../../components/link-accordion'
async function HubContent() {
await connection()
return <div id="hub-content">Hub</div>
}
// Hub page used by rewrite-detection tests as a navigation target instead of
// `brows... | prefetch={false}>
Rewritten Second
</LinkAccordion>
</li>
<li>
<LinkAccordion href="/search-rewrite?v=beta" prefetch={false}>
Search Rewrite Beta (v=beta → content=beta)
</LinkAccordion | y `act` scope.
export default function HubPage() {
return (
<div>
<Suspense fallback="Loading hub...">
<HubContent />
</Suspense>
<ul>
<li>
<LinkAccordion href="/rewritten/second" | {
"filepath": "test/e2e/app-dir/optimistic-routing/app/hub/page.tsx",
"language": "tsx",
"file_size": 1045,
"cut_index": 513,
"middle_length": 229
} |
'react'
import { getSentinelValue } from '../../getSentinelValue'
export default async function Page({
searchParams,
}: {
searchParams: Promise<any>
}) {
return (
<>
<p>
This page reads `searchParams.foo` in a client component context with a
parent Suspense boundary.
</p>
<... | uspense>
<div id="page">{getSentinelValue()}</div>
</>
)
}
async function ComponentOne({ searchParams }: { searchParams: Promise<any> }) {
let sentinelSearch
const sp = await searchParams
try {
if (sp.sentinel) {
sentinelSearch | ecause a dynamic API was used.
</p>
<Suspense fallback="loading...">
<ComponentOne searchParams={searchParams} />
</Suspense>
<Suspense fallback="loading too...">
<ComponentTwo />
</S | {
"filepath": "test/e2e/app-dir/cache-components/app/cases/dynamic_api_search_params_server/page.tsx",
"language": "tsx",
"file_size": 1526,
"cut_index": 537,
"middle_length": 229
} |
from 'e2e-utils'
describe('cache-components', () => {
const { next, isNextDev, skipped } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
if (skipped) {
return
}
it('should not have route specific errors', async () => {
expect(next.cliOutput).not.toMatch('Error: Route "/')
... |
if (isNextDev) {
expect($('#layout').text()).toBe('at runtime')
expect($('#page').text()).toBe('at runtime')
} else {
expect($('#layout').text()).toBe('at buildtime')
expect($('#page').text()).toBe('at buildtime')
}
} | m/cached', {}) | {
"filepath": "test/e2e/app-dir/cache-components/cache-components.random.test.ts",
"language": "typescript",
"file_size": 811,
"cut_index": 536,
"middle_length": 14
} |
n }: { children: React.ReactNode }) {
return (
<html>
<body>
<nav>
<div>
<ul>
<li>
<Link id="go-to-index" href="/">
Index
</Link>
</li>
<li>
<Link id="go-to-dynamic" href... | /li>
<li>
<Link id="go-to-dynamic-404" href="/dynamic/404">
Dynamic not found page
</Link>
</li>
</ul>
</div>
</nav>
{children}
</body | t found page
</Link>
< | {
"filepath": "test/e2e/app-dir/error-boundary-navigation/app/layout.tsx",
"language": "tsx",
"file_size": 934,
"cut_index": 606,
"middle_length": 52
} |
etup({
files: __dirname,
skipDeployment: true,
})
if (skipped) {
return
}
function getLogFilePath(): string {
const logFilePath = path.join(
next.testDir,
next.distDir,
'logs',
'next-development.log'
)
return logFilePath
}
function hasLogFile(): boolean {
... | t DevTools"
.split('\n')
.filter((line) => {
if (!line.trim()) return false
// Parse JSON and filter out the noise logs
try {
const log = JSON.parse(line)
if (
/Download th | rn fs.readFileSync(logPath, 'utf8')
}
return ''
}
let previousLogContent = ''
function normalizeLogContent(content: string): string {
return (
content
// Strip lines containing "Download the Reac | {
"filepath": "test/e2e/app-dir/log-file/log-file.test.ts",
"language": "typescript",
"file_size": 7578,
"cut_index": 716,
"middle_length": 229
} |
rom 'internal-pkg'
import { runInternalSourceMapped } from 'internal-pkg/sourcemapped'
import { runInternalIgnored } from 'internal-pkg/ignored'
import { runExternal } from 'external-pkg'
import { runExternalSourceMapped } from 'external-pkg/sourcemapped'
function logError() {
const error = new Error('rsc-error-log-... | rnal(function runWithExternal() {
runExternalSourceMapped(function runWithExternalSourceMapped() {
runInternalIgnored(function runWithInternalIgnored() {
logError()
})
})
})
})
})
return null
}
|
runExte | {
"filepath": "test/e2e/app-dir/server-source-maps/fixtures/default/app/rsc-error-log-ignore-listed/page.js",
"language": "javascript",
"file_size": 806,
"cut_index": 536,
"middle_length": 14
} |
source: '/config-rewrite-before',
destination: '/config-rewrite-after',
},
]
},
async redirects() {
return [
{
source: '/config-redirect-before',
destination: '/config-redirect-after',
permanent: true,
},
{
source: '/config-redirect-catchall-be... | /id497799835?l=en-GB&mt=12',
permanent: true,
},
{
source: '/config-redirect-itms-apps-no-slashes',
destination:
'itms-apps:apps.apple.com/de/app/xcode/id497799835?l=en-GB&mt=12',
permanent: true,
| :
'itms-apps://apps.apple.com/de/app/xcode | {
"filepath": "test/e2e/app-dir/rewrites-redirects/next.config.js",
"language": "javascript",
"file_size": 931,
"cut_index": 606,
"middle_length": 52
} |
= nextTestSetup({
files: __dirname,
dependencies: {
typescript: 'latest',
'@types/react': 'latest',
'@types/node': 'latest',
},
})
// TODO: investigate test failures on deploy
if ((global as any).isNextDeploy) {
it('should skip for deploy', () => {})
return
}
/**
* A... | aitForElementByCss('.page_middleware-rewrite-after')
const url = new URL(await browser.url())
expect(url.pathname).toEndWith('-before')
})
it('should redirect from middleware correctly', async () => {
const browser = await next.b | (testType) => {
it('should rewrite from middleware correctly', async () => {
const browser = await next.browser('/')
await browser
.elementById(`${testType}-middleware-rewrite`)
.click()
.w | {
"filepath": "test/e2e/app-dir/rewrites-redirects/rewrites-redirects.test.ts",
"language": "typescript",
"file_size": 3657,
"cut_index": 614,
"middle_length": 229
} |
import Link from 'next/link'
import { useRouter } from 'next/navigation'
const Test = ({ page, href }: { page: string; href?: string }) => {
const router = useRouter()
href ??= `/${page}-before`
return (
<>
<Link id={`link-${page}`} href={href}>
Link to /{page}-before
</Link>
<bu... | rewrite" />
<Test page="middleware-redirect" />
<Test page="config-rewrite" />
<Test page="config-redirect" />
<Test
page="config-redirect-catchall"
href="/config-redirect-catchall-before/thing"
/>
</>
)
| e="middleware- | {
"filepath": "test/e2e/app-dir/rewrites-redirects/app/page.tsx",
"language": "tsx",
"file_size": 796,
"cut_index": 524,
"middle_length": 14
} |
from 'e2e-utils'
import path from 'path'
describe('ppr-missing-root-params (single)', () => {
const { next, isNextDev, skipped } = nextTestSetup({
files: path.join(__dirname, 'fixtures/single'),
skipStart: true,
skipDeployment: true,
})
if (skipped) return
beforeAll(async () => {
try {
a... | skipped } = nextTestSetup({
files: path.join(__dirname, 'fixtures/multiple'),
skipStart: true,
skipDeployment: true,
})
if (skipped) return
beforeAll(async () => {
try {
await next.start()
} catch {}
})
it('should res | `Error: A required root parameter (lang) was not provided in generateStaticParams for /[lang], please provide at least one value.`
)
})
})
describe('ppr-missing-root-params (multiple)', () => {
const { next, isNextDev, | {
"filepath": "test/e2e/app-dir/ppr-missing-root-params/ppr-missing-root-params.test.ts",
"language": "typescript",
"file_size": 1972,
"cut_index": 537,
"middle_length": 229
} |
('app dir - layout params', () => {
const { next } = nextTestSetup({
files: __dirname,
})
describe('basic params', () => {
it('check layout without params get no params', async () => {
const $ = await next.render$('/base/something/another')
const ids = ['#root-layout', '#lvl1-layout']
i... | c () => {
const $ = await next.render$('/base/something/another')
expect($('#lvl3-layout > div').length).toBe(2)
expect($('#lvl3-param1').text()).toBe('"something"')
expect($('#lvl3-param2').text()).toBe('"another"')
})
})
| nst $ = await next.render$('/base/something/another')
expect($('#lvl2-layout > div').length).toBe(1)
expect($('#lvl2-param1').text()).toBe('"something"')
})
it('check topmost layout renders all params', asyn | {
"filepath": "test/e2e/app-dir/layout-params/layout-params.test.ts",
"language": "typescript",
"file_size": 2030,
"cut_index": 563,
"middle_length": 229
} |
e('/without-io/world')
expect(await browser.elementById('slug').text()).toBe('Hello /world')
const headers = response.headers()
// If we didn't use the fallback shell, then we didn't postpone the
// response, and therefore shouldn't have sent the postponed header.
expect(headers['x-nextj... | ched-io/with-static-params/with-suspense/params-in-page/bar'
)
const lastModified = await browser
.elementById('last-modified')
.text()
expect(lastModified).toInclude('Page /bar')
| describe('and the params accessed in the cached page', () => {
it('resumes a postponed fallback shell', async () => {
const { browser, response } = await next.browserWithResponse(
'/with-ca | {
"filepath": "test/e2e/app-dir/fallback-shells/fallback-shells.test.ts",
"language": "typescript",
"file_size": 16878,
"cut_index": 921,
"middle_length": 229
} |
check } from 'next-test-utils'
describe('app-invalid-revalidate', () => {
const { next, isNextDev, skipped } = nextTestSetup({
files: __dirname,
skipStart: true,
skipDeployment: true,
})
if (skipped) {
return
}
it('should error properly for invalid revalidate at layout', async () => {
a... | " on "\/", must be a non-negative number or false/)
} finally {
await next.patchFile('app/layout.tsx', origText)
}
})
it('should error properly for invalid revalidate at page', async () => {
await next.stop().catch(() => {})
cons | ', 'export')
)
await next.start().catch(() => {})
await check(async () => {
if (isNextDev) {
await next.fetch('/')
}
return next.cliOutput
}, /Invalid revalidate value "1 | {
"filepath": "test/e2e/app-dir/app-invalid-revalidate/app-invalid-revalidate.test.ts",
"language": "typescript",
"file_size": 2815,
"cut_index": 563,
"middle_length": 229
} |
s/promises')
/**
* A persistent cache handler that does NOT drop entries at revalidate time.
* This allows the framework's SWR code path to trigger, unlike the default
* in-memory handler which expires entries at revalidate time.
*/
/** @type {Map<string, import('next/dist/server/lib/cache-handlers/types').CacheE... | che.
await setTimeout(200)
const entry = store.get(cacheKey)
if (!entry) {
console.log('PersistentCacheHandler::get', cacheKey, softTags, '-> miss')
return undefined
}
const [returnStream, savedStream] = entry.value.tee()
| const cacheHandler = {
async get(cacheKey, softTags) {
const pendingPromise = pendingSets.get(cacheKey)
if (pendingPromise) {
await pendingPromise
}
// Simulate some latency when fetching from a remote ca | {
"filepath": "test/e2e/app-dir/use-cache-swr/handler.js",
"language": "javascript",
"file_size": 2256,
"cut_index": 563,
"middle_length": 229
} |
rue,
})
if (skipped) return
let outputIndex: number
beforeEach(() => {
outputIndex = next.cliOutput.length
})
it('should serve stale data and then pre-warmed data on subsequent request', async () => {
const browser = await next.browser('/')
const initialOuter = await browser.elementById('out... | s the stale entry,
// the framework serves it to the client, and kicks off a background regen.
await browser.refresh()
const afterStale = await browser.elementById('outer-data').text()
// The stale data should be the same as the initial da | eset output index so the regen set we poll for below can't be satisfied
// by the initial cold-fill set from the first fetch.
outputIndex = next.cliOutput.length
// This request should trigger SWR: the handler return | {
"filepath": "test/e2e/app-dir/use-cache-swr/use-cache-swr.test.ts",
"language": "typescript",
"file_size": 8003,
"cut_index": 716,
"middle_length": 229
} |
fetchCache of force-no-store when force-dynamic is used', async () => {
const $ = await next.render$('/force-dynamic-fetch-cache/no-fetch-cache')
const initData = $('#data').text()
await retry(async () => {
const $2 = await next.render$(
'/force-dynamic-fetch-cache/no-fetch-cache'
... | che/route')
).json()
expect(newFetchData).toBeTruthy()
expect(newFetchData).not.toEqual(initFetchData)
})
})
it('should infer a fetch cache of "force-cache" when force-dynamic is used on a fetch with revalidate', asyn | (
await next.fetch('/force-dynamic-fetch-cache/no-fetch-cache/route')
).json()
await retry(async () => {
const newFetchData = await (
await next.fetch('/force-dynamic-fetch-cache/no-fetch-ca | {
"filepath": "test/e2e/app-dir/app-static/app-static.test.ts",
"language": "typescript",
"file_size": 192759,
"cut_index": 7068,
"middle_length": 229
} |
fetchCache = 'force-cache'
export default async function Page() {
const dataNoCache = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random?a1',
{
cache: 'no-cache',
}
).then((res) => res.text())
const dataForceCache = await fetch(
'https://next-data-api-endpoint.vercel.app/a... | revalidate: 3,
},
cache: 'force-cache',
}
).then((res) => res.text())
const dataAutoCache = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random?d4'
).then((res) => res.text())
return (
<>
<p>/force-c | {
next: {
revalidate: 3,
},
}
).then((res) => res.text())
const dataRevalidateAndFetchCache = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random?d4',
{
next: {
| {
"filepath": "test/e2e/app-dir/app-static/app/force-cache/page.js",
"language": "javascript",
"file_size": 1445,
"cut_index": 524,
"middle_length": 229
} |
Link from 'next/link'
export const dynamicParams = false
export default async function Page(props) {
const params = await props.params
await fetch('https://example.vercel.sh', {
next: { revalidate: 10 },
})
return (
<>
<p id="page">/blog/[author]</p>
<p id="params">{JSON.stringify(params)... | <br />
<Link href="/blog/seb/second-post" id="author-2-post-1">
/blog/seb/second-post
</Link>
<br />
<Link href="/blog/styfle/first-post" id="author-3-post-1">
/blog/styfle/first-post
</Link>
<br /> |
</Link>
<br />
<Link href="/blog/styfle" id="author-3">
/blog/styfle
</Link>
<br />
<Link href="/blog/tim/first-post" id="author-1-post-1">
/blog/tim/first-post
</Link>
| {
"filepath": "test/e2e/app-dir/app-static/app/blog/[author]/page.js",
"language": "javascript",
"file_size": 1155,
"cut_index": 518,
"middle_length": 229
} |
import { notFound } from 'next/navigation'
export const dynamicParams = true
export default async function Page(props) {
const params = await props.params
if (params.author === 'shu') {
notFound()
}
return (
<>
<p id="page">/blog/[author]/[slug]</p>
<p id="params">{JSON.stringify(params)}... |
}
case 'styfle': {
return [
{
slug: 'first-post',
},
{
slug: 'second-post',
},
]
}
default: {
throw new Error(`unexpected author param received ${params.author}`)
}
| arams)
)
switch (params.author) {
case 'tim': {
return [
{
slug: 'first-post',
},
]
}
case 'seb': {
return [
{
slug: 'second-post',
},
] | {
"filepath": "test/e2e/app-dir/app-static/app/blog/[author]/[slug]/page.js",
"language": "javascript",
"file_size": 1003,
"cut_index": 512,
"middle_length": 229
} |
table_cache } from 'next/cache'
export default async function Page() {
const data = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random?page',
{
next: { revalidate: 360, tags: ['thankyounext'] },
}
).then((res) => res.text())
const data2 = await fetch(
'https://next-data-api... | fetchedRandom,
}
},
['random'],
{
tags: ['thankyounext', 'unstable_cache_tag1'],
revalidate: 10,
}
)()
return (
<>
<p id="page">/variable-revalidate/revalidate-360</p>
<p id="page-data">revalid | (
async () => {
const fetchedRandom = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random'
).then((res) => res.json())
return {
now: Date.now(),
random: Math.random(),
| {
"filepath": "test/e2e/app-dir/app-static/app/variable-revalidate/revalidate-360-isr/page.js",
"language": "javascript",
"file_size": 1310,
"cut_index": 524,
"middle_length": 229
} |
chRetry } from '../../../lib/fetch-retry'
export const revalidate = 0
export default async function Page() {
const data = await fetchRetry(
'https://next-data-api-endpoint.vercel.app/api/random?status=404',
{
next: {
revalidate: 3,
},
}
).then(async (res) => {
return {
st... | status: res.status,
text: await res.text(),
}
})
return (
<>
<p id="page">/variable-revalidate/status-code</p>
<p id="page-data">{JSON.stringify(data)}</p>
<p id="page-data2">{JSON.stringify(data2)}</p>
</>
)
} | return {
| {
"filepath": "test/e2e/app-dir/app-static/app/variable-revalidate/status-code/page.js",
"language": "javascript",
"file_size": 795,
"cut_index": 524,
"middle_length": 14
} |
y'
export const dynamic = 'force-dynamic'
export default async function Page() {
const data = await fetchRetry(
'https://next-data-api-endpoint.vercel.app/api/random',
{
method: 'POST',
next: {
revalidate: 10,
},
}
).then((res) => res.text())
const dataWithBody1 = await fe... | controller.enqueue(JSON.stringify({ another: 'one' }))
controller.close()
},
}),
duplex: 'half',
next: {
revalidate: 10,
},
}
).then((res) => res.text())
const dataWithBody3 = await fetch |
}
).then((res) => res.text())
const dataWithBody2 = await fetchRetry(
'https://next-data-api-endpoint.vercel.app/api/random',
{
method: 'POST',
body: new ReadableStream({
start(controller) {
| {
"filepath": "test/e2e/app-dir/app-static/app/variable-revalidate/post-method/page.js",
"language": "javascript",
"file_size": 2224,
"cut_index": 563,
"middle_length": 229
} |
const revalidate = 0
export default async function Page() {
const data = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random?page',
{
next: { revalidate: 360, tags: ['thankyounext'] },
}
).then((res) => res.text())
const data2 = await fetch(
'https://next-data-api-endpoint.... | ndpoint.vercel.app/api/random',
{
cache: 'no-store',
}
).then((res) => res.json())
const fetchedRandomRevalidateZero = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random',
{
n | c () => {
const fetchedRandom = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random'
).then((res) => res.json())
const fetchedRandomNoStore = await fetch(
'https://next-data-api-e | {
"filepath": "test/e2e/app-dir/app-static/app/variable-revalidate/revalidate-360/page.js",
"language": "javascript",
"file_size": 2442,
"cut_index": 563,
"middle_length": 229
} |
y'
export const runtime = 'edge'
export default async function Page() {
const data = await fetchRetry(
'https://next-data-api-endpoint.vercel.app/api/random',
{
method: 'POST',
next: {
revalidate: 10,
},
}
).then((res) => res.text())
const dataWithBody1 = await fetchRetry(... | controller.enqueue(JSON.stringify({ another: 'one' }))
controller.close()
},
}),
duplex: 'half',
next: {
revalidate: 10,
},
}
).then((res) => res.text())
const formData = new FormData()
formData | ).then((res) => res.text())
const dataWithBody2 = await fetchRetry(
'https://next-data-api-endpoint.vercel.app/api/random',
{
method: 'POST',
body: new ReadableStream({
start(controller) {
| {
"filepath": "test/e2e/app-dir/app-static/app/variable-revalidate-edge/post-method/page.js",
"language": "javascript",
"file_size": 2023,
"cut_index": 563,
"middle_length": 229
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.