prefix stringlengths 512 512 | suffix stringlengths 256 256 | middle stringlengths 14 229 | meta dict |
|---|---|---|---|
metadata-streaming', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should only insert metadata once for parallel routes when slots match', async () => {
const browser = await next.browser('/parallel-routes')
expect((await browser.elementsByCss('title')).length).toBe(1)
expec... | await browser.elementByCss('[href="/parallel-routes/test-page"]').click()
await retry(async () => {
expect(await browser.elementByCss('title').text()).toContain(
'Dynamic api'
)
})
expect((await browser.elementsByCss('t | inserted into head or body since it's a race condition,
// where sometimes the metadata can be suspended.
expect($('title').text()).toBe('parallel title')
// validate behavior remains the same on client navigations
| {
"filepath": "test/e2e/app-dir/metadata-streaming-parallel-routes/metadata-streaming-parallel-routes.test.ts",
"language": "typescript",
"file_size": 3135,
"cut_index": 614,
"middle_length": 229
} |
rom 'next/server'
import Link from 'next/link'
// skip rendering children
export default function Layout({ bar, foo }) {
return (
<div>
<h1>Parallel Routes Layout - No Children</h1>
<Link href="/parallel-routes-no-children/first" id="to-no-children-first">
{`to /parallel-routes-no-children/f... | {foo}</div>
<div id="bar-slot">{bar}</div>
</div>
)
}
export async function generateMetadata() {
await connection()
await new Promise((resolve) => setTimeout(resolve, 300))
return {
title: 'parallel-routes-default layout title',
}
| </Link>
<br />
<div id="foo-slot"> | {
"filepath": "test/e2e/app-dir/metadata-streaming-parallel-routes/app/parallel-routes-no-children/layout.tsx",
"language": "tsx",
"file_size": 845,
"cut_index": 535,
"middle_length": 52
} |
utils'
describe('parallel-routes-and-interception-basepath', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should show parallel intercepted slot with basepath', async () => {
const browser = await next.browser('/base')
await browser.elementByCss('#link-to-nested').click()
con... | route via direct link with basepath when parallel intercepted slot exist', async () => {
const browser = await next.browser('/base/nested')
const nestedPageFull = await browser
.elementByCss('#nested-page-full')
.text()
expect(nest | Be('Nested Page Slot')
})
it('should show normal | {
"filepath": "test/e2e/app-dir/parallel-routes-and-interception-basepath/parallel-routes-and-interception-basepath.test.ts",
"language": "typescript",
"file_size": 900,
"cut_index": 547,
"middle_length": 52
} |
mport { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
describe('parallel-routes-catchall-specificity', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should match the catch-all route when navigating from a page with a similar path depth as the previously matched... | await retry(async () => {
expect(await browser.elementByCss('h1').text()).toBe('Profile')
})
await browser.back()
await browser.elementByCss('[href="/trending"]').click()
await retry(async () => {
expect(await browser.element | e're matching @modal/(...comments)/[productId]
expect(await browser.elementByCss('h1').text()).toBe('Modal')
await browser.elementByCss('[href="/u/foobar/l"]').click()
// we're now matching @modal/[...catchAll]
| {
"filepath": "test/e2e/app-dir/parallel-routes-catchall-specificity/parallel-routes-catchall-specificity.test.ts",
"language": "typescript",
"file_size": 1050,
"cut_index": 513,
"middle_length": 229
} |
t.readFile('.next/server/app/api/hello.json.meta')
).toBeTruthy()
}
expect(
JSON.parse(await next.render(basePath + '/api/hello.json'))
).toEqual({
pathname: '/api/hello.json',
})
})
it('does not statically generate with dynamic usage', async () => {
if (is... | ynamic',
query: {},
})
})
})
describe('works with generateStaticParams correctly', () => {
it.each([
'/static/first/data.json',
'/static/second/data.json',
'/static/three/data.json',
])('responds correctly o | next
.readFile('.next/server/app/api/dynamic.meta')
.catch(() => '')
).toBeFalsy()
}
expect(JSON.parse(await next.render(basePath + '/api/dynamic'))).toEqual({
pathname: '/api/d | {
"filepath": "test/e2e/app-dir/app-routes/app-custom-routes.test.ts",
"language": "typescript",
"file_size": 22443,
"cut_index": 1331,
"middle_length": 229
} |
ver/web/spec-extension/adapters/headers'
import type { ReadonlyRequestCookies } from 'next/dist/server/web/spec-extension/adapters/request-cookies'
import type { Headers as NodeFetchHeaders } from 'node-fetch'
const KEY = 'x-request-meta'
/**
* Adds a new header to the headers object and serializes it. To be used in... | return {
...headers,
[KEY]: JSON.stringify(meta),
}
}
/**
* Adds a cookie to the headers with the provided request metadata. Existing
* cookies will be merged, but it will not merge request metadata that already
* exists on an existing cookie | ders on the response to merge with
* @returns the merged headers with the request meta added
*/
export function withRequestMeta(
meta: Record<string, any>,
headers: Record<string, string> = {}
): Record<string, string> {
| {
"filepath": "test/e2e/app-dir/app-routes/helpers.ts",
"language": "typescript",
"file_size": 2519,
"cut_index": 563,
"middle_length": 229
} |
type NextRequest } from 'next/server'
import { withRequestMeta } from '../helpers'
const helloHandler = async (
request: NextRequest,
{ params }: { params?: Promise<Record<string, string | string[]>> }
): Promise<Response> => {
const { pathname } = request.nextUrl
if (typeof WebSocket === 'undefined') {
... | pathname,
}),
})
}
export const GET = helloHandler
export const HEAD = helloHandler
export const OPTIONS = helloHandler
export const POST = helloHandler
export const PUT = helloHandler
export const DELETE = helloHandler
export const PATCH = hell | od: request.method,
params: resolvedParams,
| {
"filepath": "test/e2e/app-dir/app-routes/handlers/hello.ts",
"language": "typescript",
"file_size": 837,
"cut_index": 520,
"middle_length": 52
} |
from 'e2e-utils'
describe('parallel-routes-catchall-default', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should match default paths before catch-all', async () => {
let browser = await next.browser('/en/nested')
// we have a top-level catch-all but the /nested dir doesn't hav... | .elementById('nested-children').text()).toBe(
'/[locale]/nested/[foo]/[bar]/default.tsx'
)
// we expect the slot to match since there's a page defined at this segment
expect(await browser.elementById('slot').text()).toBe(
'/[locale | All]]/page.tsx'
)
browser = await next.browser('/en/nested/foo/bar')
// we're now at the /[foo]/[bar] segment, so we expect the matched page to be the default (since there's no page defined)
expect(await browser | {
"filepath": "test/e2e/app-dir/parallel-routes-catchall-default/parallel-routes-catchall-default.test.ts",
"language": "typescript",
"file_size": 1646,
"cut_index": 537,
"middle_length": 229
} |
=>
await browser.eval('document.documentElement.scrollTop')
const getLeftScroll = async (browser: Playwright) =>
await browser.eval('document.documentElement.scrollLeft')
const waitForScrollToComplete = async (
browser: Playwright,
options: { x: number; y: number }
) => {
await retry(async ... | await waitForScrollToComplete(browser, options)
}
describe('vertical scroll', () => {
it('should scroll to top of document when navigating between to pages without layout', async () => {
const browser = await next.browser('/0/0/100/10000/p | x })
})
await assertNoConsoleErrors(browser)
}
const scrollTo = async (
browser: Playwright,
options: { x: number; y: number }
) => {
await browser.eval(`window.scrollTo(${options.x}, ${options.y})`)
| {
"filepath": "test/e2e/app-dir/router-autoscroll/router-autoscroll.test.ts",
"language": "typescript",
"file_size": 10495,
"cut_index": 921,
"middle_length": 229
} |
import { useRouter } from 'next/navigation'
export default function Layout({ children }: { children: React.ReactNode }) {
const router = useRouter()
// We export these so that we can access them from tests
useEffect(() => {
// @ts-ignore
window.router = router
// @ts-ignore
window.React = React
... | <div
style={{
position: 'fixed',
top: 0,
left: 0,
}}
>
<Link id="to-vertical-page" href="1" />
</div>
{children}
</body>
</html>
| margin: 0,
}}
>
| {
"filepath": "test/e2e/app-dir/router-autoscroll/app/layout.tsx",
"language": "tsx",
"file_size": 933,
"cut_index": 606,
"middle_length": 52
} |
n (
<>
{
// Repeat 500 elements
Array.from({ length: 500 }, (_, i) => (
<div key={i}>{i}</div>
))
}
<div>
<Link href="/loading-scroll" id="to-loading-scroll">
To loading scroll
</Link>
</div>
<div>
<Link href="/invisib... | Link>
</div>
<div>
<Link href="/sticky-first-element" id="to-sticky-first-element">
To sticky first element
</Link>
</div>
<div>
<Link href="/new-metadata">To new metadata</Link>
</div>
| lement">
To fixed first element
</ | {
"filepath": "test/e2e/app-dir/router-autoscroll/app/page.tsx",
"language": "tsx",
"file_size": 974,
"cut_index": 582,
"middle_length": 52
} |
readFixtureText,
} from './utils'
describe('metadata-files-static-output-parallel-route', () => {
if (process.env.__NEXT_CACHE_COMPONENTS) {
// Cache Components build fails when metadata files are inside a dynamic route.
//
// Route "/dynamic/[id]": Next.js encountered uncached or runtime data in `gener... | onst instant = false` to allow a blocking route
//
// Learn more: https://nextjs.org/docs/messages/next-prerender-dynamic-metadata
// Error occurred prerendering page "/dynamic/[id]". Read more: https://nextjs.org/docs/messages/prerender-error
| d of `generateMetadata()`
// - Cache the metadata with `"use cache"` in `generateMetadata()`
// - Add a dynamic data access (e.g. `await connection()`) to the page to render it at request time
// - Set `export c | {
"filepath": "test/e2e/app-dir/metadata-static-file/metadata-static-file-parallel-route.test.ts",
"language": "typescript",
"file_size": 4659,
"cut_index": 614,
"middle_length": 229
} |
readFixtureText,
} from './utils'
describe('metadata-files-static-output-static-route', () => {
if (process.env.__NEXT_CACHE_COMPONENTS) {
// Cache Components build fails when metadata files are inside a dynamic route.
//
// Route "/dynamic/[id]": Next.js encountered uncached or runtime data in `generat... | st instant = false` to allow a blocking route
//
// Learn more: https://nextjs.org/docs/messages/next-prerender-dynamic-metadata
// Error occurred prerendering page "/dynamic/[id]". Read more: https://nextjs.org/docs/messages/prerender-error
| of `generateMetadata()`
// - Cache the metadata with `"use cache"` in `generateMetadata()`
// - Add a dynamic data access (e.g. `await connection()`) to the page to render it at request time
// - Set `export con | {
"filepath": "test/e2e/app-dir/metadata-static-file/metadata-static-file-static-route.test.ts",
"language": "typescript",
"file_size": 4525,
"cut_index": 614,
"middle_length": 229
} |
ype error.
import { promises as fs } from 'fs'
import path from 'path'
import type { Playwright } from 'e2e-utils'
// Fixture files live in this directory (`test/e2e/app-dir/metadata-static-file`),
// so we read them from the repo on the test runner. Using `next.readFile` would
// hit the deployed filesystem, which is... | urn elements
.filter((el) => {
if (el.href.includes('/_next/static')) {
return false
}
return [
'/favicon.ico',
'/manifest.json',
'/manifest.webmanifest',
// Below may have su | vePath: string) {
return fs.readFile(path.join(__dirname, relativePath), 'utf8')
}
async function getMetadataLinks(browser: Playwright) {
const links = await browser.locator('link').evaluateAll((elements: any[]) => {
ret | {
"filepath": "test/e2e/app-dir/metadata-static-file/utils.ts",
"language": "typescript",
"file_size": 2867,
"cut_index": 563,
"middle_length": 229
} |
retry } from 'next-test-utils'
import { type Collector, connectCollector } from './collector'
const COLLECTOR_PORT = 9876
describe('otel-parent-span-propagation', () => {
const { next, skipped } = nextTestSetup({
files: __dirname,
skipDeployment: true,
dependencies: require('./package.json').dependencie... | on, when external OTEL instrumentation (e.g. Datadog,
// @opentelemetry/instrumentation-http) creates a parent HTTP server span,
// our fix also propagates http.route to that parent span so APM tools
// derive the resource name correctly (e.g. "GET / | (async () => {
collector = await connectCollector({ port: COLLECTOR_PORT })
})
afterEach(async () => {
await collector.shutdown()
})
// Verifies that http.route is set on the handleRequest span.
// In producti | {
"filepath": "test/e2e/app-dir/otel-parent-span-propagation/otel-parent-span-propagation.test.ts",
"language": "typescript",
"file_size": 2444,
"cut_index": 563,
"middle_length": 229
} |
* eslint-env jest */
import path from 'path'
import { nextTestSetup, FileRef } from 'e2e-utils'
describe('app dir - middleware with middleware in src dir', () => {
const { next } = nextTestSetup({
files: {
'src/app': new FileRef(path.join(__dirname, 'app')),
'next.config.js': new FileRef(path.join(__... | r = await next.browser('/')
await browser.addCookie({
name: 'test-cookie',
value: 'test-cookie-response',
})
await browser.refresh()
const html = await browser.eval('document.documentElement.innerHTML')
expect(html).toCont | request) {
const cookie = (await cookies()).get('test-cookie')
return NextResponse.json({ cookie })
}
`,
},
})
it('works without crashing when using RequestStore', async () => {
const browse | {
"filepath": "test/e2e/app-dir/app-middleware/app-middleware-in-src-dir.test.ts",
"language": "typescript",
"file_size": 1034,
"cut_index": 513,
"middle_length": 229
} |
ync () => {
expect(next.cliOutput).toContain(
'The "middleware" file convention is deprecated. Please use "proxy" instead.'
)
})
})
it('should filter correctly after middleware rewrite', async () => {
const browser = await next.browser('/start')
await browser.eval('window.beforeNav... | dge',
toJson: (res: Response) => res.json(),
},
{
title: 'next/headers',
path: '/headers',
toJson: async (res: Response) => {
const $ = cheerio.load(await res.text())
return JSON.parse($('#headers').text())
| )
describe.each([
{
title: 'Serverless Functions',
path: '/api/dump-headers-serverless',
toJson: (res: Response) => res.json(),
},
{
title: 'Edge Functions',
path: '/api/dump-headers-e | {
"filepath": "test/e2e/app-dir/app-middleware/app-middleware.test.ts",
"language": "typescript",
"file_size": 9979,
"cut_index": 921,
"middle_length": 229
} |
import { check } from 'next-test-utils'
import { join } from 'path'
describe('app-dir action useActionState', () => {
const { next } = nextTestSetup({
files: __dirname,
overrideFiles: process.env.TEST_NODE_MIDDLEWARE
? {
'middleware.js': new FileRef(join(__dirname, 'middleware-node.js')),
... | }, 'initial-state:test')
})
it('should support submitting form state without JS', async () => {
const browser = await next.browser('/client/form-state', {
disableJavaScript: true,
})
await browser.eval(`document.getElementById('nam | m-state')
await browser.eval(`document.getElementById('name-input').value = 'test'`)
await browser.elementByCss('#submit-form').click()
await check(() => {
return browser.elementByCss('#form-state').text()
| {
"filepath": "test/e2e/app-dir/actions/app-action-form-state.test.ts",
"language": "typescript",
"file_size": 2516,
"cut_index": 563,
"middle_length": 229
} |
'
describe('Configuration', () => {
const { next } = nextTestSetup({ files: __dirname })
async function get$(path: string) {
const html = await next.render(path)
return cheerio.load(html)
}
it('should disable X-Powered-By header support', async () => {
const res = await next.fetch('/')
const ... | xpect($('#messageInAPackage').text()).toBe('OK')
})
it('should have env variables available on the client', async () => {
const browser = await next.browser('/next-config')
const envValue = await browser.elementByCss('#env').text()
expect( | const $ = await get$('/module-only-content')
e | {
"filepath": "test/development/config/config.test.ts",
"language": "typescript",
"file_size": 948,
"cut_index": 582,
"middle_length": 52
} |
document components error', () => {
const { next } = nextTestSetup({
files: __dirname,
})
async function checkMissing(missing: string[], docContent: string) {
const outputIndex = next.cliOutput.length
await next.patchFile('pages/_document.js', docContent)
await next.render('/').catch(() => {})
... | ript } from 'next/document'
class MyDocument extends Document {
render() {
return (
<html>
<Head />
<body>
<Main />
<NextScript />
</body>
| g.join(', '))
})
await next.deleteFile('pages/_document.js')
}
it('should detect missing Html component', async () => {
await checkMissing(
['<Html />'],
`
import Document, { Head, Main, NextSc | {
"filepath": "test/development/missing-document-component-error/missing-document-component-error.test.ts",
"language": "typescript",
"file_size": 3086,
"cut_index": 614,
"middle_length": 229
} |
retry } from 'next-test-utils'
import path from 'path'
const reactDependencies = {
react: '19.3.0-canary-fef12a01-20260413',
'react-dom': '19.3.0-canary-fef12a01-20260413',
}
// This test only applies to Turbopack
;(!process.env.IS_TURBOPACK_TEST ? describe.skip : describe)(
'turbopack unsupported features log'... | ut).not.toContain(
'You are using configuration and/or tools that are not yet'
)
})
})
describe('empty config', () => {
const { next } = nextTestSetup({
files: path.join(__dirname, 'fixtures/empty-config'),
| )
it('should not warn by default', async () => {
const html = await next.render('/')
expect(html).toContain('hello world')
expect(next.cliOutput).toContain('(Turbopack)')
expect(next.cliOutp | {
"filepath": "test/development/turbopack-unsupported-log/turbopack-unsupported-log.test.ts",
"language": "typescript",
"file_size": 2159,
"cut_index": 563,
"middle_length": 229
} |
renderViaHTTP } from 'next-test-utils'
describe('Prerender crawler handling', () => {
const { next } = nextTestSetup({
files: {
'pages/index.js': `
export default function Page() {
return <p>index page</p>
}
`,
'pages/blog/[slug].js': `
import {useRouter} fro... | params }) {
return {
props: {
slug: params.slug
}
}
}
export async function getStaticPaths() {
return {
paths: ['/blog/first'],
fallback: | }
return (
<>
<p id='page'>slug page</p>
<p id='slug'>{slug}</p>
</>
)
}
export async function getStaticProps({ | {
"filepath": "test/e2e/prerender-crawler.test.ts",
"language": "typescript",
"file_size": 2985,
"cut_index": 563,
"middle_length": 229
} |
t/data/${next.buildId}/blog/post-4.json`,
initialExpireSeconds: 31536000,
initialRevalidateSeconds: 10,
srcRoute: '/blog/[post]',
},
'/blog/post-1/comment-1': {
allowHeader,
dataRoute: `/_next/data/${next.buildId}/blog/post-1/comment-1.json`,
initialExpireSeconds: 31536000,
... | g/post.1.json`,
initialExpireSeconds: 31536000,
initialRevalidateSeconds: 10,
srcRoute: '/blog/[post]',
},
'/catchall-explicit/another/value': {
allowHeader,
dataRoute: `/_next/data/${next.buildId}/catchall-explicit/an | comment-2.json`,
initialExpireSeconds: 31536000,
initialRevalidateSeconds: 2,
srcRoute: '/blog/[post]/[comment]',
},
'/blog/post.1': {
allowHeader,
dataRoute: `/_next/data/${next.buildId}/blo | {
"filepath": "test/e2e/prerender.test.ts",
"language": "typescript",
"file_size": 94609,
"cut_index": 3790,
"middle_length": 229
} |
from 'e2e-utils'
import { retry } from 'next-test-utils'
describe('Scroll Back Restoration Support', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
react: '19.3.0-canary-fef12a01-20260413',
'react-dom': '19.3.0-canary-fef12a01-20260413',
},
// Vercel deployment... | ect(scrollRestoration).toBe('manual')
const scrollX = Math.floor(await browser.eval(() => window.scrollX))
const scrollY = Math.floor(await browser.eval(() => window.scrollY))
expect(scrollX).not.toBe(0)
expect(scrollY).not.toBe(0)
a | await next.browser('/')
await browser.eval(() =>
document.querySelector('#to-another').scrollIntoView()
)
const scrollRestoration = await browser.eval(
() => window.history.scrollRestoration
)
exp | {
"filepath": "test/e2e/scroll-back-restoration/scroll-back-restoration.test.ts",
"language": "typescript",
"file_size": 1727,
"cut_index": 537,
"middle_length": 229
} |
str) {
return (
str &&
str.replace(/^ +(?:at|in) ([\S]+)[^\n]*/gm, function (m, name) {
const dot = name.lastIndexOf('.')
if (dot !== -1) {
name = name.slice(dot + 1)
}
return ' at ' + name + (/\d/.test(m) ? ' (**)' : '')
})
)
}
describe.each(['default', 'babelrc'] as... |
variant === 'babelrc'
? __dirname
: {
app: new FileRef(join(__dirname, 'app')),
pages: new FileRef(join(__dirname, 'pages')),
'next.config.js': new FileRef(join(__dirname, 'next.config. | {
'reference-library': 'file:./reference-library',
}
: {
'reference-library': 'link:./reference-library',
}
const { next, isNextDev, isTurbopack } = nextTestSetup({
files: | {
"filepath": "test/e2e/react-compiler/react-compiler.test.ts",
"language": "typescript",
"file_size": 6485,
"cut_index": 716,
"middle_length": 229
} |
mport { nextTestSetup } from 'e2e-utils'
import { renderViaHTTP } from 'next-test-utils'
describe('browserslist-extends', () => {
const { next } = nextTestSetup({
files: {
'pages/index.js': `
import styles from './index.module.css'
export default function Page() {
return... | onfig-google': '^3.0.1',
},
packageJson: {
browserslist: ['extends browserslist-config-google'],
},
})
it('should work', async () => {
const html = await renderViaHTTP(next.url, '/')
expect(html).toContain('hello world')
}) | browserslist-c | {
"filepath": "test/e2e/browserslist-extends/index.test.ts",
"language": "typescript",
"file_size": 787,
"cut_index": 513,
"middle_length": 14
} |
readFixtureText,
} from './utils'
describe('metadata-files-static-output-intercepting-route', () => {
if (process.env.__NEXT_CACHE_COMPONENTS) {
// Cache Components build fails when metadata files are inside a dynamic route.
//
// Route "/dynamic/[id]": Next.js encountered uncached or runtime data in `g... | rt const instant = false` to allow a blocking route
//
// Learn more: https://nextjs.org/docs/messages/next-prerender-dynamic-metadata
// Error occurred prerendering page "/dynamic/[id]". Read more: https://nextjs.org/docs/messages/prerender-er | stead of `generateMetadata()`
// - Cache the metadata with `"use cache"` in `generateMetadata()`
// - Add a dynamic data access (e.g. `await connection()`) to the page to render it at request time
// - Set `expo | {
"filepath": "test/e2e/app-dir/metadata-static-file/metadata-static-file-intercepting-route.test.ts",
"language": "typescript",
"file_size": 5062,
"cut_index": 614,
"middle_length": 229
} |
ver as HttpServer } from 'node:http'
import { SavedSpan } from './constants'
export interface Collector {
getSpans: () => SavedSpan[]
shutdown: () => Promise<void>
}
export async function connectCollector({
port,
}: {
port: number
}): Promise<Collector> {
const spans: SavedSpan[] = []
const server = new ... | ewSpans = JSON.parse(body.toString('utf-8')) as SavedSpan[]
spans.push(...newSpans)
res.statusCode = 202
res.end()
})
await new Promise<void>((resolve, reject) => {
server.listen(port, (err?: Error) => {
if (err) {
reject |
const acc: Buffer[] = []
req.on('data', (chunk: Buffer) => {
acc.push(chunk)
})
req.on('end', () => {
resolve(Buffer.concat(acc))
})
req.on('error', reject)
})
const n | {
"filepath": "test/e2e/app-dir/otel-parent-span-propagation/collector.ts",
"language": "typescript",
"file_size": 1374,
"cut_index": 524,
"middle_length": 229
} |
('app-dir assetPrefix with basePath handling', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should redirect route when requesting it directly', async () => {
const res = await next.fetch('/custom-base-path/a/', {
redirect: 'manual',
})
expect(res.status).toBe(308)
e... | ase-path/a')
expect(await browser.waitForElementByCss('#a-page').text()).toBe('A page')
})
it('should redirect route when clicking link', async () => {
const browser = await next.browser('/custom-base-path')
await browser
.elementByC | base-path')
expect($('#to-a-trailing-slash').attr('href')).toBe('/custom-base-path/a')
})
it('should redirect route when requesting it directly by browser', async () => {
const browser = await next.browser('/custom-b | {
"filepath": "test/e2e/app-dir/asset-prefix-with-basepath/asset-prefix-with-basepath.test.ts",
"language": "typescript",
"file_size": 2463,
"cut_index": 563,
"middle_length": 229
} |
ndling - next export', () => {
const { next, isNextStart, skipped } = nextTestSetup({
files: __dirname,
skipStart: true,
skipDeployment: true,
dependencies: {
nanoid: '4.0.1',
'server-only': 'latest',
},
})
if (skipped) return
if (!isNextStart) {
it('skip test for developmen... | also not supported with export
await next.remove('app/interception-routes')
try {
await next.start()
} catch {}
})
it('should error when use export output for server actions', async () => {
expect(next.cliOutput).toContain(
| }
`
)
// interception routes are | {
"filepath": "test/e2e/app-dir/actions/app-action-export.test.ts",
"language": "typescript",
"file_size": 960,
"cut_index": 582,
"middle_length": 52
} |
ort { nextTestSetup } from 'e2e-utils'
import { retry, waitForRedbox, getRedboxSource } from 'next-test-utils'
// Webpack specific config test.
;(process.env.IS_TURBOPACK_TEST ? describe.skip : describe)(
'devtool set in development mode in next config',
() => {
const { next } = nextTestSetup({
files: __... | "pages/index.js (5:11) @ Index.useEffect
3 | export default function Index(props) {
4 | useEffect(() => {
> 5 | throw new Error('this should render')
| ^
6 | }, [])
| ack devtool to /)
})
const browser = await next.browser('/')
await waitForRedbox(browser)
if (process.platform !== 'win32') {
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
| {
"filepath": "test/development/config-devtool-dev/config-devtool-dev.test.ts",
"language": "typescript",
"file_size": 1117,
"cut_index": 515,
"middle_length": 229
} |
from 'e2e-utils'
import { waitForRedbox, getRedboxSource } from 'next-test-utils'
describe('app dir - css', () => {
const { next, skipped } = nextTestSetup({
files: __dirname,
dependencies: {
sass: 'latest',
},
})
if (skipped) {
return
}
describe('sass support', () => {
;(process.... | lineSnapshot(`
"./app/global.scss.css (45:1)
Parsing CSS source code failed
43 | }
44 |
> 45 | input.defaultCheckbox::before path {
| ^
46 | fill: currentColor;
| await next.browser('/sass-error')
await waitForRedbox(browser)
const source = await getRedboxSource(browser)
// css-loader does not report an error for this case
expect(source).toMatchIn | {
"filepath": "test/development/sass-error/index.test.ts",
"language": "typescript",
"file_size": 1861,
"cut_index": 537,
"middle_length": 229
} |
n } from 'path'
import { nextTestSetup, FileRef } from 'e2e-utils'
describe('i18-default-locale-redirect', () => {
const { next } = nextTestSetup({
files: {
pages: new FileRef(join(__dirname, './app/pages')),
'next.config.js': new FileRef(join(__dirname, './app/next.config.js')),
},
})
it('s... | ct(await browser.elementByCss('#new').text()).toBe('New')
expect(requestedDefaultLocalePath).toBe(false)
})
it('should request a path prefixed with non-default locale', async () => {
const browser = await next.browser('/')
let requestedNon | any) => {
if (new URL(request.url(), 'http://n').pathname === '/en/to-new') {
requestedDefaultLocalePath = true
}
})
await browser.elementByCss('#to-new').click().waitForElementByCss('#new')
expe | {
"filepath": "test/e2e/i18n-default-locale-redirect/i18n-default-locale-redirect.test.ts",
"language": "typescript",
"file_size": 1424,
"cut_index": 524,
"middle_length": 229
} |
tTestSetup, type Playwright } from 'e2e-utils'
const getPathname = (url: string) => {
const urlObj = new URL(url)
return urlObj.pathname
}
const createRequestsListener = async (browser: Playwright) => {
// wait for network idle
await browser.waitForIdleNetwork()
let requests = []
browser.on('request', (... | e {
it('should avoid double-fetching when optimistic navigation fails', async () => {
const browser = await next.browser('/foo')
const { getRequests } = await createRequestsListener(browser)
await browser.elementByCss('[href="/foo"]' | requests = []
},
}
}
describe('app-prefetch-false', () => {
const { next, isNextDev } = nextTestSetup({
files: __dirname,
})
if (isNextDev) {
it.skip('should skip test in development mode', () => {})
} els | {
"filepath": "test/e2e/app-dir/app-prefetch-false/app-prefetch-false.test.ts",
"language": "typescript",
"file_size": 1255,
"cut_index": 524,
"middle_length": 229
} |
readFixtureText,
} from './utils'
describe('metadata-files-static-output-root-route', () => {
if (process.env.__NEXT_CACHE_COMPONENTS) {
// Cache Components build fails when metadata files are inside a dynamic route.
//
// Route "/dynamic/[id]": Next.js encountered uncached or runtime data in `generateM... | instant = false` to allow a blocking route
//
// Learn more: https://nextjs.org/docs/messages/next-prerender-dynamic-metadata
// Error occurred prerendering page "/dynamic/[id]". Read more: https://nextjs.org/docs/messages/prerender-error
| `generateMetadata()`
// - Cache the metadata with `"use cache"` in `generateMetadata()`
// - Add a dynamic data access (e.g. `await connection()`) to the page to render it at request time
// - Set `export const | {
"filepath": "test/e2e/app-dir/metadata-static-file/metadata-static-file-root-route.test.ts",
"language": "typescript",
"file_size": 3085,
"cut_index": 614,
"middle_length": 229
} |
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'
import {
SimpleSpanProcessor,
SpanExporter,
ReadableSpan,
BasicTracerProvider,
} from '@opentelemetry/sdk-trace-base'
import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks'
import {
ExportResult,
... | oMicroseconds(span.duration),
attributes: span.attributes,
status: span.status,
})
class TestExporter implements SpanExporter {
constructor(private port: number) {}
async export(
spans: ReadableSpan[],
resultCallback: (result: ExportResul | env.NEXT_RUNTIME,
traceId: span.spanContext().traceId,
parentId: span.parentSpanId,
name: span.name,
id: span.spanContext().spanId,
kind: span.kind,
timestamp: hrTimeToMicroseconds(span.startTime),
duration: hrTimeT | {
"filepath": "test/e2e/app-dir/otel-parent-span-propagation/instrumentation.ts",
"language": "typescript",
"file_size": 2400,
"cut_index": 563,
"middle_length": 229
} |
from 'e2e-utils'
import { check, renderViaHTTP } from 'next-test-utils'
import stripAnsi from 'strip-ansi'
describe('typescript-auto-install', () => {
const { next } = nextTestSetup({
files: {
'pages/index.js': `
export default function Page() {
return <p>hello world</p>
}
`... | detect TypeScript being added and auto setup', async () => {
const browser = await next.browser('/')
const pageContent = await next.readFile('pages/index.js')
await check(
() => browser.eval('document.documentElement.innerHTML'),
| : '',
RUN_ID: '',
BUILD_NUMBER: '',
},
dependencies: {},
})
it('should work', async () => {
const html = await renderViaHTTP(next.url, '/')
expect(html).toContain('hello world')
})
it('should | {
"filepath": "test/development/typescript-auto-install/index.test.ts",
"language": "typescript",
"file_size": 1595,
"cut_index": 537,
"middle_length": 229
} |
nder native module', () => {
const { next } = nextTestSetup({
files: {
pages: new FileRef(path.join(__dirname, 'prerender-native-module/pages')),
'data.sqlite': new FileRef(
path.join(__dirname, 'prerender-native-module/data.sqlite')
),
},
dependencies: {
sqlite: '4.0.22',
... | ld render /blog/first correctly', async () => {
const browser = await next.browser('/blog/first')
expect(await browser.elementByCss('#blog').text()).toBe('blog page')
expect(JSON.parse(await browser.elementByCss('#props').text())).toEqual({
| browser = await next.browser('/')
expect(await browser.elementByCss('#index').text()).toBe('index page')
expect(JSON.parse(await browser.elementByCss('#props').text())).toEqual({
index: true,
})
})
it('shou | {
"filepath": "test/e2e/prerender-native-module.test.ts",
"language": "typescript",
"file_size": 3541,
"cut_index": 614,
"middle_length": 229
} |
{ unstable_cache } from 'next/cache'
import { headers as nextHeaders, draftMode } from 'next/headers'
const getCachedValue = unstable_cache(
async () => Math.random().toString(),
['middleware-cache-probe']
)
/**
* @param {import('next/server').NextRequest} request
*/
export async function middleware(request) {
... | rsFromRequest.get('x-from-client')
) {
throw new Error('Expected headers from client to match')
}
if (request.nextUrl.searchParams.get('draft')) {
;(await draftMode()).enable()
}
const removeHeaders = request.nextUrl.searchParams.get('r | t.set('x-from-middleware', 'hello-from-middleware')
// make sure headers() from `next/headers` is behaving properly
if (
headersFromRequest.get('x-from-client') &&
headersFromNext.get('x-from-client') !==
heade | {
"filepath": "test/e2e/app-dir/app-middleware/middleware.js",
"language": "javascript",
"file_size": 2910,
"cut_index": 563,
"middle_length": 229
} |
import { createSandbox } from 'development-sandbox'
import path from 'path'
import { outdent } from 'outdent'
const middlewarePath = 'middleware.js'
const middlewareWarning = `A middleware can not alter response's body`
describe('middlewares', () => {
const { next } = nextTestSetup({
files: new FileRef(
p... | rt default function middleware() {
return new Response(10);
}
`,
},
{
title: 'returning response with JSON.stringify',
code: outdent`
export default function middleware() {
return new Response(J | utdent`
export default function middleware() {
return new Response('this is not allowed');
}
`,
},
{
title: 'returning response with literal number',
code: outdent`
expo | {
"filepath": "test/development/middleware-warnings/index.test.ts",
"language": "typescript",
"file_size": 2834,
"cut_index": 563,
"middle_length": 229
} |
tTestSetup } from 'e2e-utils'
describe('i18n-disallow-multiple-locales', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it.each([
['/non-existent'],
['/es/non-existent'],
['/first/non-existent'],
['/es/first/non-existent'],
['/first/second/non-existent'],
['/es/first/s... | th: '/first/second/third/fourth',
page: '/[first]/[second]/[third]/[fourth]',
},
])(
'should render properly for fallback: false prerendered $urlPath',
async ({ urlPath, page }) => {
const res = await next.fetch(urlPath)
exp | Be(404)
}
)
it.each([
{ urlPath: '/first', page: '/[first]' },
{ urlPath: '/first/second', page: '/[first]/[second]' },
{ urlPath: '/first/second/third', page: '/[first]/[second]/[third]' },
{
urlPa | {
"filepath": "test/e2e/i18n-fallback-collision/i18n-fallback-collision.test.ts",
"language": "typescript",
"file_size": 1343,
"cut_index": 524,
"middle_length": 229
} |
ype Playwright } from 'e2e-utils'
import { check } from 'next-test-utils'
describe('app a11y features', () => {
const { next, skipped } = nextTestSetup({
files: __dirname,
packageJson: {},
skipDeployment: true,
})
if (skipped) {
return
}
describe('route announcer', () => {
async functio... | ges', async () => {
const browser = await next.browser('/page-with-h1')
await browser.elementById('page-with-title').click()
await check(() => getAnnouncerContent(browser), 'page-with-title')
})
it('should announce h1 changes', a | it('should not announce the initital title', async () => {
const browser = await next.browser('/page-with-h1')
await check(() => getAnnouncerContent(browser), '')
})
it('should announce document.title chan | {
"filepath": "test/e2e/app-dir/app-a11y/index.test.ts",
"language": "typescript",
"file_size": 1549,
"cut_index": 537,
"middle_length": 229
} |
ierContext } from './internal-context'
export interface CacheIdentifier {}
const cacheById = new WeakMap<CacheIdentifier, DataCache>()
export type DataCache = Map<string, Promise<unknown>>
function createDataCache(): DataCache {
return new Map()
}
export function useDataCache() {
const id = use(CacheIdentifierC... | se<T>): Promise<T> {
let promise = cache.get(key) as Promise<T> | undefined
if (!promise) {
console.log('client-data-fetching-lib :: MISS', key)
cache.set(key, (promise = func()))
} else {
console.log('client-data- | rn {
getOrLoad<T>(key: string, func: () => Promi | {
"filepath": "test/e2e/app-dir/instant-validation/client-data-fetching-lib/client.ts",
"language": "typescript",
"file_size": 959,
"cut_index": 582,
"middle_length": 52
} |
{ cacheLife } from 'next/cache'
import Link from 'next/link'
import { setTimeout } from 'timers/promises'
export function DebugLinks({ href }: { href: string }) {
return (
<span>
<span>{href}</span>{' '}
<Link data-link-type="soft" href={href}>
[SPA]
</Link>{' '}
<a data-link-typ... | -render/work-unit-async-storage.external')
const workUnitStore = workUnitAsyncStorage.getStore()!
return (
<div>
workUnitStore.type: {workUnitStore.type}
{(() => {
switch (workUnitStore.type) {
case 'prerender':
| cheLife('minutes')
await setTimeout(1)
}
export function DebugRenderKind() {
const { workUnitAsyncStorage } =
require('next/dist/server/app-render/work-unit-async-storage.external') as typeof import('next/dist/server/app | {
"filepath": "test/e2e/app-dir/instant-validation/app/shared.tsx",
"language": "tsx",
"file_size": 1194,
"cut_index": 518,
"middle_length": 229
} |
{ ReactNode, Suspense } from 'react'
export default function RootLayout({ children }: { children: ReactNode }) {
return (
// We're mostly interested in checking client navigations,
// so to avoid having to give each test case a valid static shell,
// we put a Suspense above the body.
<Suspense fallb... | turn (
<header>
<a href="/">Home</a>{' '}
<Suspense fallback="...">
<div id="root-layout-timestamp">
<Now />
</div>
</Suspense>
</header>
)
}
async function Now() {
await connection()
return Date.n | tml>
</Suspense>
)
}
function Header() {
re | {
"filepath": "test/e2e/app-dir/instant-validation/app/suspense-in-root/layout.tsx",
"language": "tsx",
"file_size": 874,
"cut_index": 559,
"middle_length": 52
} |
nd-params/123" />
</li>
<li>
<DebugLinks href="/suspense-in-root/runtime/valid-no-suspense-around-search-params?foo=bar" />
</li>
<li>
<DebugLinks href="/suspense-in-root/runtime/missing-suspense-around-dynamic" />
</li>
<li>
<DebugLinks href... | <li>
<DebugLinks href="/suspense-in-root/runtime/invalid-sync-io" />
</li>
<li>
<DebugLinks href="/suspense-in-root/runtime/valid-blocking-inside-runtime" />
</li>
<li>
<DebugLinks href=" | <li>
<DebugLinks href="/suspense-in-root/static/invalid-blocking-inside-static" />
</li>
<li>
<DebugLinks href="/suspense-in-root/runtime/invalid-blocking-inside-runtime" />
</li>
| {
"filepath": "test/e2e/app-dir/instant-validation/app/suspense-in-root/page.tsx",
"language": "tsx",
"file_size": 10939,
"cut_index": 921,
"middle_length": 229
} |
'
import { cookies } from 'next/headers'
import { connection } from 'next/server'
import { Suspense } from 'react'
export const unstable_instant = { level: 'experimental-error' }
export const unstable_prefetch = 'force-runtime'
// Note that we're inside a root layout with suspense, so we skip the static shell
export ... | iewport</p>
<p>
We also access dynamic data in the page itself, because a static page
with a dynamic viewport is not allowed.
</p>
<Suspense>
<Dynamic />
</Suspense>
</main>
)
}
async function Dynamic( | <main>
<p>This page has a dynamic generateV | {
"filepath": "test/e2e/app-dir/instant-validation/app/suspense-in-root/head/invalid-dynamic-viewport-in-runtime/page.tsx",
"language": "tsx",
"file_size": 896,
"cut_index": 547,
"middle_length": 52
} |
rom 'next/server'
import { Suspense } from 'react'
export const unstable_instant = { level: 'experimental-error' }
export const unstable_prefetch = 'force-runtime'
export async function generateMetadata(): Promise<Metadata> {
await connection()
return {
title: 'Blocked by connection',
}
}
export default as... | We also access connection in the page itself, because a runtime page
with dynamic metadata is not allowed.
</p>
<Suspense>
<Dynamic />
</Suspense>
</main>
)
}
async function Dynamic() {
await connection()
retur | 't block, so it's fine.
</p>
<p>
| {
"filepath": "test/e2e/app-dir/instant-validation/app/suspense-in-root/head/valid-dynamic-metadata-in-runtime/page.tsx",
"language": "tsx",
"file_size": 923,
"cut_index": 606,
"middle_length": 52
} |
import { cookies } from 'next/headers'
// This would be valid if it used a runtime prefetch (because then it wouldn't block navigation),
// but it's static, so it's invalid. As an extra sanity check, we put a runtime prefetch on the
// layout above, and that should not make this error go away.
export const unstable_in... | s a runtime generateViewport</p>
<p>
We also access runtime data in the page itself, because a fully static
page with a runtime vieport is not allowed.
</p>
<Suspense>
<Runtime />
</Suspense>
</main>
)
| Page() {
return (
<main>
<p>This page ha | {
"filepath": "test/e2e/app-dir/instant-validation/app/suspense-in-root/head/invalid-runtime-viewport-in-static/page.tsx",
"language": "tsx",
"file_size": 954,
"cut_index": 582,
"middle_length": 52
} |
le_instant = {
level: 'experimental-error',
unstable_samples: [{ cookies: [], searchParams: { foo: 'bar' } }],
}
export const unstable_prefetch = 'force-runtime'
export default async function Page({
searchParams,
}: {
searchParams: Promise<Record<string, string | string[]>>
}) {
const search = await searchPa... | nt does:</p>
<Suspense fallback={<div>Loading...</div>}>
<Dynamic />
</Suspense>
</div>
</main>
)
}
async function Dynamic() {
await connection()
return <div id="dynamic-content">Dynamic content from page</div>
}
| </div>
<div>
<p>But dynamic conte | {
"filepath": "test/e2e/app-dir/instant-validation/app/suspense-in-root/runtime/valid-no-suspense-around-search-params/page.tsx",
"language": "tsx",
"file_size": 914,
"cut_index": 606,
"middle_length": 52
} |
{ Suspense } from 'react'
export const unstable_instant = {
level: 'experimental-error',
unstable_samples: [{ cookies: [], params: { param: '123' } }],
}
export const unstable_prefetch = 'force-runtime'
export default async function Page({
params,
}: {
params: Promise<{ param: string }>
}) {
const { param ... | nt does:</p>
<Suspense fallback={<div>Loading...</div>}>
<Dynamic />
</Suspense>
</div>
</main>
)
}
async function Dynamic() {
await connection()
return <div id="dynamic-content">Dynamic content from page</div>
}
| </div>
<div>
<p>But dynamic conte | {
"filepath": "test/e2e/app-dir/instant-validation/app/suspense-in-root/runtime/valid-no-suspense-around-params/[param]/page.tsx",
"language": "tsx",
"file_size": 867,
"cut_index": 559,
"middle_length": 52
} |
kies } from 'next/headers'
export const unstable_instant = { level: 'experimental-error' }
export const unstable_prefetch = 'force-runtime'
// This page HAS runtime prefetch enabled. cookies() is passed as a promise
// input to a public "use cache" function. The cache doesn't read the cookies
// in its body — they're... | would
// resolve later, and Date.now() would happen at the Runtime stage where
// canSyncInterrupt returns false — missing the error.
async function cachedFn(cookiePromise: Promise<string>) {
'use cache'
// Intentionally not reading the cookie promise | e.
//
// This test validates that the cache input encoding resolves in the correct
// runtime stage (EarlyRuntime for prefetchable segments). If the cache input
// abort signal incorrectly waited for the Runtime stage, the cache | {
"filepath": "test/e2e/app-dir/instant-validation/app/suspense-in-root/runtime/invalid-sync-io-after-cache-with-cookie-input/page.tsx",
"language": "tsx",
"file_size": 1412,
"cut_index": 524,
"middle_length": 229
} |
} from 'next/headers'
import { Suspense } from 'react'
// This layout does NOT have runtime prefetch — it's a static segment.
// The RuntimeContent component accesses cookies() then Date.now().
// In a static prefetch the render would never get past cookies() so the
// sync IO is unreachable. In a runtime prefetch, co... | sync IO after cookies: {now}</p>
}
export default function StaticLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<div>
<Suspense fallback={<p>Loading...</p>}>
<RuntimeContent />
</Suspense>
<hr />
| onst now = Date.now()
return <p>Static layout with | {
"filepath": "test/e2e/app-dir/instant-validation/app/suspense-in-root/runtime/valid-sync-io-in-static-parent/layout.tsx",
"language": "tsx",
"file_size": 870,
"cut_index": 529,
"middle_length": 52
} |
'next/headers'
import { connection } from 'next/server'
import { Suspense } from 'react'
export const unstable_instant = { level: 'experimental-error' }
export const unstable_prefetch = 'force-runtime'
export default async function Page() {
return (
<main>
<div>
<p>Runtime content doesn't need a s... | </div>
</main>
)
}
async function Runtime() {
await cookies()
return <div id="runtime-content">Runtime content from page</div>
}
async function Dynamic() {
await connection()
return <div id="dynamic-content">Dynamic content from page</di | /Suspense>
| {
"filepath": "test/e2e/app-dir/instant-validation/app/suspense-in-root/runtime/suspense-around-dynamic/page.tsx",
"language": "tsx",
"file_size": 811,
"cut_index": 536,
"middle_length": 14
} |
t { Suspense, type ReactNode } from 'react'
import { ErrorInSSR } from './client'
import { connection } from 'next/server'
// Make sure that the holes from this layout aren't factored in for validation
// (otherwise, we'd check a navigation into it from the root layout and fail)
export const unstable_instant = false
... | This layout errors in SSR, and the errors is caught by a Suspense
boundary, but it blocks the children slot so it prevents validation.
</p>
<Suspense>
<ErrorInSSR>{children}</ErrorInSSR>
</Suspense>
</div | <p>
| {
"filepath": "test/e2e/app-dir/instant-validation/app/suspense-in-root/static/invalid-client-error-in-parent-blocks-children/layout.tsx",
"language": "tsx",
"file_size": 803,
"cut_index": 517,
"middle_length": 14
} |
omPackage } from 'my-pkg'
import { connection } from 'next/server'
// Make sure that the holes from this layout aren't factored in for validation
// (otherwise, we'd check a navigation into it from the root layout and fail)
export const unstable_instant = false
export default async function Layout({ children }: { chi... | blocks the children slot so it prevents validation.
The error is thrown in a component from node_modules, which means that
the component is ignore-listed away.
</p>
<Suspense>
<ErrorInSSRFromPackage>{children} | s is caught by a Suspense
boundary, but it | {
"filepath": "test/e2e/app-dir/instant-validation/app/suspense-in-root/static/invalid-error-in-node-modules-blocks-children/layout.tsx",
"language": "tsx",
"file_size": 962,
"cut_index": 582,
"middle_length": 52
} |
ype { ReactNode } from 'react'
import { LazyClientWrapperWithNoSSR } from './lazy-client'
import { connection } from 'next/server'
// Make sure that the holes from this layout aren't factored in for validation
// (otherwise, we'd check a navigation into it from the root layout and fail)
export const unstable_instant =... | ent wrapped in next/dynamic with ssr:
false around the children slot. This blocks the children slot so it
prevents validation.
</p>
<LazyClientWrapperWithNoSSR>{children}</LazyClientWrapperWithNoSSR>
</div>
</> | >
<p>
This layout renders a compon | {
"filepath": "test/e2e/app-dir/instant-validation/app/suspense-in-root/static/invalid-csr-bailout-blocks-children/layout.tsx",
"language": "tsx",
"file_size": 835,
"cut_index": 520,
"middle_length": 52
} |
import { cookies } from 'next/headers'
import { connection } from 'next/server'
import { Suspense } from 'react'
export const unstable_instant = { level: 'experimental-error' }
export default async function Page() {
return (
<main>
<p>
This page wraps all runtime/dynamic components in suspense, so... | </div>
</main>
)
}
async function Runtime() {
await cookies()
return <div id="runtime-content">Runtime content from page</div>
}
async function Dynamic() {
await connection()
return <div id="dynamic-content">Dynamic content from page</div | div>}>
<Runtime />
</Suspense>
</div>
<div>
<p>Dynamic content with a suspense boundary</p>
<Suspense fallback={<div>Loading...</div>}>
<Dynamic />
</Suspense>
| {
"filepath": "test/e2e/app-dir/instant-validation/app/suspense-in-root/static/suspense-around-dynamic/page.tsx",
"language": "tsx",
"file_size": 1001,
"cut_index": 512,
"middle_length": 229
} |
rt { Suspense, type ReactNode } from 'react'
import { ErrorInSSR } from './client'
import { connection } from 'next/server'
// Make sure that the holes from this layout aren't factored in for validation
// (otherwise, we'd check a navigation into it from the root layout and fail)
export const unstable_instant = false
... | error is wrapped in Suspense and
does not block the children slot, so it does not prevent us from
validating the page.
</p>
<Suspense>
<ErrorInSSR />
</Suspense>
{children}
</div>
</>
| <p>
This layout errors in SSR, but the | {
"filepath": "test/e2e/app-dir/instant-validation/app/suspense-in-root/static/valid-client-error-in-parent-does-not-block-validation/layout.tsx",
"language": "tsx",
"file_size": 830,
"cut_index": 516,
"middle_length": 52
} |
ort { cookies } from 'next/headers'
import { connection } from 'next/server'
export const unstable_instant = { level: 'experimental-error' }
export default async function Page() {
return (
<main>
<p>
This page doesn't wrap runtime/dynamic components in suspense, but it
has a loading.tsx ab... | y report an error.
</p>
<div>
<Runtime />
</div>
<div>
<Dynamic />
</div>
</main>
)
}
async function Runtime() {
await cookies()
return <div id="runtime-content">Runtime content from page</div>
}
as | e loading.tsx
Suspense would already be revealed. In a more advanced system we would
analyze siblings of the route group to determine if such a navigation is
actually possible, but for now we conservativel | {
"filepath": "test/e2e/app-dir/instant-validation/app/suspense-in-root/static/invalid-loading-above-route-group/(group)/page.tsx",
"language": "tsx",
"file_size": 1115,
"cut_index": 515,
"middle_length": 229
} |
files: __dirname,
skipDeployment: true,
})
if (skipped) return
// Recursively read all .js files in a directory
function getAllServerFiles(dir: string): string[] {
const results: string[] = []
try {
const entries = fs.readdirSync(dir, { withFileTypes: true })
for (const entry of en... | t.testDir, '.next/server')
const files = getAllServerFiles(serverDir)
const contents = await Promise.all(
files.map((f) => fs.promises.readFile(f, 'utf8'))
)
return contents.join('\n')
}
// Verify that each page renders correctly | js')) {
results.push(fullPath)
}
}
} catch {
// directory doesn't exist
}
return results
}
async function getAllServerContent(): Promise<string> {
const serverDir = path.join(nex | {
"filepath": "test/e2e/app-dir/dynamic-import-tree-shaking/dynamic-import-tree-shaking.test.ts",
"language": "typescript",
"file_size": 8590,
"cut_index": 716,
"middle_length": 229
} |
assetPrefix', () => {
const { next } = nextTestSetup({
files: __dirname,
nextConfig: {
assetPrefix: 'https://example.vercel.sh/',
},
})
it('bundles should return 200 on served assetPrefix', async () => {
const $ = await next.render$('/')
let bundles = []
for (const script of $('scr... | }
}
expect(bundles.length).toBeGreaterThan(0)
for (const src of bundles) {
// Remove hostname to check if pathname is still used for serving the bundles
const bundlePathWithoutHost = decodeURI(new URL(src).href)
const | tic/immutable')
) {
bundles.push(src)
| {
"filepath": "test/e2e/app-dir/asset-prefix-absolute/asset-prefix-absolute-no-path.test.ts",
"language": "typescript",
"file_size": 989,
"cut_index": 582,
"middle_length": 52
} |
ort { nextTestSetup } from 'e2e-utils'
describe('app-dir absolute assetPrefix', () => {
const { next } = nextTestSetup({
files: __dirname,
nextConfig: {
assetPrefix: 'https://example.vercel.sh/custom-asset-prefix',
},
})
it('bundles should return 200 on served assetPrefix', async () => {
c... |
}
expect(bundles.length).toBeGreaterThan(0)
for (const src of bundles) {
// Remove hostname to check if pathname is still used for serving the bundles
const bundlePathWithoutHost = decodeURI(new URL(src).href)
const { statu | ps://example.vercel.sh/custom-asset-prefix/_next/static'
) ||
src?.startsWith(
'https://example.vercel.sh/custom-asset-prefix/_next/static/immutable'
)
) {
bundles.push(src)
} | {
"filepath": "test/e2e/app-dir/asset-prefix-absolute/asset-prefix-absolute.test.ts",
"language": "typescript",
"file_size": 1092,
"cut_index": 515,
"middle_length": 229
} |
r$(
'/top-level?foo=foosearch',
{},
{
headers: {
fooheader: 'foo header value',
cookie: 'foocookie=foo cookie value',
},
}
)
if (isNextDev) {
// in dev we expect the entire page to be rendered at runtime
expect($('#layout').text()).toBe('at... | expect($('#layout').text()).toBe('at runtime')
expect($('#page').text()).toBe('at runtime')
}
expect($('#headers .fooheader').text()).toBe('foo header value')
expect($('#cookies .foocookie').text()).toBe('foo cookie value')
expect($ | be rendered at runtime
expect($('#layout').text()).toBe('at buildtime')
expect($('#page').text()).toBe('at runtime')
} else {
// in static generation we expect the entire page to be rendered at runtime
| {
"filepath": "test/e2e/app-dir/dynamic-data/dynamic-data.test.ts",
"language": "typescript",
"file_size": 15856,
"cut_index": 921,
"middle_length": 229
} |
aders'
import { unstable_cache as cache } from 'next/cache'
const cookies = cache(() => nextCookies())
export default async function Page({ searchParams }) {
return (
<div>
<section>
This example uses `cookies()` but is configured with `dynamic = 'error'`
which should cause the page to fai... | value = value.slice(0, 10) + '...'
}
return (
<div key={key}>
<h4>{key}</h4>
<pre className={key}>{value}</pre>
</div>
)
})}
</section>
</div>
| cookie.value
if (key === 'userCache') {
| {
"filepath": "test/e2e/app-dir/dynamic-data/fixtures/cache-scoped/app/cookies/page.js",
"language": "javascript",
"file_size": 871,
"cut_index": 559,
"middle_length": 52
} |
{ headers as nextHeaders } from 'next/headers'
import { unstable_cache as cache } from 'next/cache'
const headers = cache(() => nextHeaders())
export default async function Page() {
return (
<div>
<section>
This example uses `headers()` but is configured with `dynamic = 'error'`
which sho... | if (key === 'cookie') return null
return (
<div key={key}>
<h4>{key}</h4>
<pre className={key}>{value}</pre>
</div>
)
})}
</section>
</div>
)
}
| ]) => {
| {
"filepath": "test/e2e/app-dir/dynamic-data/fixtures/cache-scoped/app/headers/page.js",
"language": "javascript",
"file_size": 788,
"cut_index": 518,
"middle_length": 14
} |
} from 'next/headers'
import { connection } from 'next/server'
import { PageSentinel } from '../getSentinelValue'
export const dynamic = 'force-static'
export default async function Page({ searchParams }) {
await connection()
return (
<div>
<PageSentinel />
<section>
This example uses he... | <div key={key}>
<h4>{key}</h4>
<pre className={key}>{value}</pre>
</div>
)
})}
</section>
<section id="cookies">
<h3>cookies</h3>
{(await cookies()).getAll().map((coo | dynamic data
</section>
<section id="headers">
<h3>headers</h3>
{Array.from((await headers()).entries()).map(([key, value]) => {
if (key === 'cookie') return null
return (
| {
"filepath": "test/e2e/app-dir/dynamic-data/fixtures/main/app/force-static/page.js",
"language": "javascript",
"file_size": 1717,
"cut_index": 537,
"middle_length": 229
} |
use client'
import { PageSentinel } from '../getSentinelValue'
export default async function Page({ searchParams }) {
return (
<div>
<PageSentinel />
<section>
This example uses headers/cookies/searchParams directly in a Page
configured with `dynamic = 'force-dynamic'`. This should c... | <h3>searchParams</h3>
{Object.entries(await searchParams).map(([key, value]) => {
return (
<div key={key}>
<h4>{key}</h4>
<pre className={key}>{value}</pre>
</div>
)
| eaders()` is not available</p>
</section>
<section id="cookies">
<h3>cookies</h3>{' '}
<p>This is a client Page so `cookies()` is not available</p>
</section>
<section id="searchparams">
| {
"filepath": "test/e2e/app-dir/dynamic-data/fixtures/main/app/client-page/page.js",
"language": "javascript",
"file_size": 1040,
"cut_index": 513,
"middle_length": 229
} |
} from 'next/headers'
import { connection } from 'next/server'
import { PageSentinel } from '../getSentinelValue'
export default async function Page({ searchParams }) {
await connection()
return (
<div>
<PageSentinel />
<section>
This example uses headers/cookies/searchParams directly. In... | className={key}>{value}</pre>
</div>
)
})}
</section>
<section id="cookies">
<h3>cookies</h3>
{(await cookies()).getAll().map((cookie) => {
const key = cookie.name
let value = c | <h3>headers</h3>
{Array.from((await headers()).entries()).map(([key, value]) => {
if (key === 'cookie') return null
return (
<div key={key}>
<h4>{key}</h4>
<pre | {
"filepath": "test/e2e/app-dir/dynamic-data/fixtures/main/app/top-level/page.js",
"language": "javascript",
"file_size": 1650,
"cut_index": 537,
"middle_length": 229
} |
} from 'next/headers'
import { connection } from 'next/server'
import { PageSentinel } from '../getSentinelValue'
export const dynamic = 'force-dynamic'
export default async function Page({ searchParams }) {
await connection()
return (
<div>
<PageSentinel />
<section>
This example uses h... | <div key={key}>
<h4>{key}</h4>
<pre className={key}>{value}</pre>
</div>
)
})}
</section>
<section id="cookies">
<h3>cookies</h3>
{(await cookies()).getAll().map((co | amic APIs used
</section>
<section id="headers">
<h3>headers</h3>
{Array.from((await headers()).entries()).map(([key, value]) => {
if (key === 'cookie') return null
return (
| {
"filepath": "test/e2e/app-dir/dynamic-data/fixtures/main/app/force-dynamic/page.js",
"language": "javascript",
"file_size": 1718,
"cut_index": 537,
"middle_length": 229
} |
tal-not-affect-parent', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should not affect parent display', async () => {
const browser = await next.browser('/')
const rect = await browser.eval(
// https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect
... | not take up the space, as the total width of
// the <body> is 300 and as is a space-between, the #div2 will be placed
// at the end of the <body> and the x will be 200.
// Before: <#div1 100> <#div2 100> <nextjs-portal 100>
// After: <#div | the width of #div1.
// If the shadow root does | {
"filepath": "test/e2e/app-dir/dev-overlay/portal-not-affect-parent/portal-not-affect-parent.test.ts",
"language": "typescript",
"file_size": 984,
"cut_index": 582,
"middle_length": 52
} |
s } from 'child_process'
import { isNextDev, isNextStart, nextTestSetup } from 'e2e-utils'
import { findPort, killApp, retry } from 'next-test-utils'
describe('interception-routes-output-export', () => {
const { next } = nextTestSetup({
files: __dirname,
skipStart: true,
// Vercel deployment fails to bui... | let stderr = ''
let child: ChildProcess | undefined
const port = await findPort()
const exit = next.runCommand(['dev', '-p', String(port)], {
onStderr(msg) {
stderr += msg || ''
},
instance: (p) => {
| const { exitCode, cliOutput } = await next.build()
expect(cliOutput).toContain(
'Intercepting routes are not supported with static export.'
)
expect(exitCode).toBe(1)
} else if (isNextDev) {
| {
"filepath": "test/e2e/app-dir/interception-routes-output-export/interception-routes-output-export.test.ts",
"language": "typescript",
"file_size": 1540,
"cut_index": 537,
"middle_length": 229
} |
{ nextTestSetup } from 'e2e-utils'
describe('with-exported-function-config', () => {
const { next, isNextStart } = nextTestSetup({
files: __dirname,
})
it('should have correct values in function config manifest', async () => {
if (isNextStart) {
const functionsConfigManifest = JSON.parse(
... | },
'/app-route-edge': {
maxDuration: 2,
},
'/app-ssr': {
maxDuration: 3,
},
'/app-ssr-edge': {
maxDuration: 4,
},
'/page': {
maxDuratio | Duration: 1,
},
'/app-layout': {
maxDuration: 1,
},
'/app-layout/inner': {
maxDuration: 2,
},
'/app-route': {
maxDuration: 1,
| {
"filepath": "test/e2e/app-dir/with-exported-function-config/with-exported-function-config.test.ts",
"language": "typescript",
"file_size": 1142,
"cut_index": 518,
"middle_length": 229
} |
import { nextTestSetup } from 'e2e-utils'
describe('resuming-head-runtime-search-param', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should not show resumable slots error when using runtime search params', async () => {
const browser = await next.browser('/?foo=bar&test=123')
... | le')
// Check server logs for the specific error message
expect(next.cliOutput).not.toContain(
"Couldn't find all resumable slots by key/index during replaying. The tree doesn't match so React will fallback to client rendering."
)
})
} | it for dynamic content to load (it's rendered inside the first p element)
await browser.waitForElementByCss('p p')
const dynamicText = await browser.elementByCss('p p').text()
expect(dynamicText).toContain('Dynamic Ho | {
"filepath": "test/e2e/app-dir/resuming-head-runtime-search-param/resuming-head-runtime-search-param.test.ts",
"language": "typescript",
"file_size": 999,
"cut_index": 512,
"middle_length": 229
} |
lient'
import { useState } from 'react'
import { streamData } from './actions'
export default function Page() {
const [chunks, setChunks] = useState<string[] | null>(null)
const [isStreaming, setIsStreaming] = useState(false)
const handleClick = async () => {
setChunks(null)
setIsStreaming(true)
c... | der.releaseLock()
setIsStreaming(false)
}
}
return (
<div>
<button disabled={isStreaming} onClick={handleClick} id="stream-button">
{isStreaming ? 'Streaming...' : 'Start Stream'}
</button>
{chunks && (
| = await reader.read()
if (done) {
break
}
const chunk = decoder.decode(value, { stream: true })
setChunks((prev) => (prev ? [...prev, chunk] : [chunk]))
}
} finally {
rea | {
"filepath": "test/e2e/app-dir/actions-streaming/app/readable-stream/page.tsx",
"language": "tsx",
"file_size": 1234,
"cut_index": 518,
"middle_length": 229
} |
['--experimental-build-mode', 'compile'] })
})
afterEach(async () => {
await next.stop()
})
} else {
beforeAll(async () => {
await next.start()
})
}
let currentCliOutputIndex = 0
beforeEach(() => {
currentCliOutputIndex = next.cliOutput.length
})
function getCliOutputSi... | LIDATION_ERRORS_WAIT: Parameters<typeof waitForNoErrorToast>[1] = {
waitInMs: 500,
}
async function expectNoDevValidationErrors(
browser: Playwright,
url: string
): Promise<void> {
await waitForValidation(url, getCliOutputSinceMark)
| = async (pathname: string) => {
const args = [
'--experimental-build-mode',
'generate',
'--debug-build-paths',
`app${pathname}/page.tsx`,
]
return await next.build({ args })
}
const NO_VA | {
"filepath": "test/e2e/app-dir/instant-validation/instant-validation-parallel-slots.test.ts",
"language": "typescript",
"file_size": 33460,
"cut_index": 1331,
"middle_length": 229
} |
tion.
\`cookies()\`, \`headers()\`, \`params\`, or \`searchParams\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience.
Ways to fix this:
- Provide a placeholder with \`<Suspense fallback={... | idation failed for route "/suspense-in-root/static/missing-suspense-around-runtime".
To get a more detailed stack trace and pinpoint the issue, try one of the following:
- Start the app in development mode by running \`next dev\`, then | to allow a blocking route
Learn more: https://nextjs.org/docs/messages/blocking-route
at body (<anonymous>)
at html (<anonymous>)
at a (<anonymous>)
Build-time instant val | {
"filepath": "test/e2e/app-dir/instant-validation/instant-validation.test.ts",
"language": "typescript",
"file_size": 190702,
"cut_index": 7068,
"middle_length": 229
} |
uspense } from 'react'
export default async function Layout({
children,
params,
}: {
children: React.ReactNode
params: Promise<{
layoutPaddingWidth: string
layoutPaddingHeight: string
pageWidth: string
pageHeight: string
}>
}) {
const { layoutPaddingHeight, layoutPaddingWidth, pageWidth, pa... | paddingLeft: Number(layoutPaddingWidth),
paddingRight: Number(layoutPaddingWidth),
background: 'pink',
display: 'flex',
}}
>
<Suspense fallback={<div id="loading">loading...</div>}>
{children}
</Suspens | paddingBottom: Number(layoutPaddingHeight),
| {
"filepath": "test/e2e/app-dir/router-autoscroll/app/[layoutPaddingWidth]/[layoutPaddingHeight]/[pageWidth]/[pageHeight]/[param]/layout.tsx",
"language": "tsx",
"file_size": 857,
"cut_index": 529,
"middle_length": 52
} |
describe('actions-unused-args', () => {
const { next, skipped } = nextTestSetup({
files: __dirname,
// No access to runtime logs when deployed.
skipDeployment: true,
})
if (skipped) {
return
}
it('should not call server actions with unused arguments', async () => {
const browser = awai... | n')
.find((line) => line.includes('Action called'))
// We expect only 1 argument because the click event from the onClick
// handler should be omitted as an unused argument.
expect(actionLog).toBe('Action called with value: 42 (t | ut
.slice(cliOutputLength)
.split('\ | {
"filepath": "test/e2e/app-dir/actions-unused-args/actions-unused-args.test.ts",
"language": "typescript",
"file_size": 945,
"cut_index": 606,
"middle_length": 52
} |
iousLogs = () => {
currentCliOutputIndex = next.cliOutput.length
}
const getLogs = () => {
return next.cliOutput.slice(currentCliOutputIndex)
}
beforeEach(() => {
ignorePreviousLogs()
})
let buildLogs: string
beforeAll(async () => {
if (!isNextDev) {
await next.build()
build... | 'cannot be called in a dynamic page', async () => {
const path = '/request-apis/page-dynamic'
await next.render(path)
await retry(() => {
const logs = getLogs()
expect(logs).not.toContain(`[${path}] headers(): ok`)
| aited calls, like this
//
// export default function Page() {
// const promise = headers()
// after(async () => {
// const headerStore = await promise
// })
// return null
// }
it( | {
"filepath": "test/e2e/app-dir/next-after-app-api-usage/index.test.ts",
"language": "typescript",
"file_size": 10638,
"cut_index": 921,
"middle_length": 229
} |
kies, headers } from 'next/headers'
import { after, connection } from 'next/server'
export function testRequestAPIs(/** @type {string} */ route) {
after(async () => {
try {
await headers()
console.log(`[${route}] headers(): ok`)
} catch (err) {
console.error(`[${route}] headers(): error:`, ... | r:`, err)
}
})
after(() =>
after(async () => {
try {
await cookies()
console.log(`[${route}] nested cookies(): ok`)
} catch (err) {
console.error(`[${route}] nested cookies(): error:`, err)
}
})
| ${route}] nested headers(): error:`, err)
}
})
)
after(async () => {
try {
await cookies()
console.log(`[${route}] cookies(): ok`)
} catch (err) {
console.error(`[${route}] cookies(): erro | {
"filepath": "test/e2e/app-dir/next-after-app-api-usage/app/request-apis/helpers.js",
"language": "javascript",
"file_size": 1457,
"cut_index": 524,
"middle_length": 229
} |
{
const { next } = nextTestSetup({
files: __dirname,
})
it('should match default and dynamic segment paths before catch-all', async () => {
let browser = await next.browser('/en/nested')
// we have a top-level catch-all but the /nested dir doesn't have a default/page until the /[foo]/[bar] segment
... | '/[locale]/nested/[foo]/[bar]/default.tsx'
)
// we expect the slot0 to match since there's a page defined at this segment
expect(await browser.elementById('slot0').text()).toBe(
'/[locale]/nested/[foo]/[bar]/@slot0/page.tsx'
)
| rowser('/en/nested/foo/bar')
// we're now at the /[foo]/[bar] segment, so we expect the matched page to be the default (since there's no page defined)
expect(await browser.elementById('nested-children').text()).toBe(
| {
"filepath": "test/e2e/app-dir/parallel-routes-catchall-dynamic-segment/parallel-routes-catchall-dynamic-segment.test.ts",
"language": "typescript",
"file_size": 3683,
"cut_index": 614,
"middle_length": 229
} |
{ NextResponse } from 'next/server'
export async function middleware(request) {
if (
request.nextUrl.pathname.includes('payment') &&
!request.nextUrl.pathname.includes('whoops')
) {
if (request.nextUrl.searchParams.has('redirect')) {
return NextResponse.redirect(new URL('/payment/whoops', reques... | est.url))
}
}
export const config = {
matcher: [
/*
* Match all request paths except for the ones starting with:
* - api (API routes)
* - _next/static (static files)
* - _next/image (image optimization files)
* - favicon.i | s('whoops')
) {
if (request.nextUrl.searchParams.has('redirect')) {
return NextResponse.redirect(new URL('/anotherRoute/whoops', request.url))
}
return NextResponse.rewrite(new URL('/anotherRoute/whoops', requ | {
"filepath": "test/e2e/app-dir/middleware-rewrite-catchall-priority-with-parallel-route/middleware.js",
"language": "javascript",
"file_size": 1143,
"cut_index": 518,
"middle_length": 229
} |
v jest */
import { nextTestSetup } from 'e2e-utils'
import {
waitForRedbox,
getRedboxDescription,
} from '../../../../lib/next-test-utils'
describe('after() in generateStaticParams - thrown errors', () => {
const { next, skipped, isNextDev } = nextTestSetup({
files: __dirname,
skipStart: true,
skipDe... | y cool error thrown inside after on route "${route}"`
)
})
} else {
it('fails the build if an error is thrown inside after', async () => {
const buildResult = await next.build()
expect(buildResult?.exitCode).toBe(1)
const | await next.start()
const browser = await next.browser('/callback/1')
await waitForRedbox(browser)
const route = '/callback/[myParam]'
expect(await getRedboxDescription(browser)).toContain(
`M | {
"filepath": "test/e2e/app-dir/next-after-app-static/generate-static-params-error/index.test.ts",
"language": "typescript",
"file_size": 1265,
"cut_index": 524,
"middle_length": 229
} |
etup } from 'e2e-utils'
import * as Log from './utils/log'
import { setTimeout } from 'timers/promises'
// This test relies on next.build() so it can't work in dev mode.
const _describe = isNextDev ? describe.skip : describe
_describe('after() in static pages', () => {
const { next, skipped } = nextTestSetup({
... | s
currentCliOutputIndex = 0
}
return next.cliOutput.slice(currentCliOutputIndex)
}
const resetLogs = () => {
currentCliOutputIndex = next.cliOutput.length
}
it('runs after during build', async () => {
const buildResult = awa | entCliOutputIndex = next.cliOutput.length
})
const getLogs = () => {
if (next.cliOutput.length < currentCliOutputIndex) {
// cliOutput shrank since we started the test, so something (like a `sandbox`) reset the log | {
"filepath": "test/e2e/app-dir/next-after-app-static/build-time/build-time.test.ts",
"language": "typescript",
"file_size": 2230,
"cut_index": 563,
"middle_length": 229
} |
('TypeScript type expressions in route segment config', () => {
const { next, isNextStart } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
describe('app directory', () => {
it('should pick up maxDuration declared with `as` type assertion', async () => {
const $ = await next.render... | })
})
describe('pages directory', () => {
it('should pick up maxDuration from config object declared with `as`', async () => {
const $ = await next.render$('/config-as')
expect($('main').text()).toBe('hello')
})
it('should | t')
expect($('main').text()).toBe('hello')
})
it('should pick up maxDuration declared with `satisfies`', async () => {
const $ = await next.render$('/satisfies')
expect($('main').text()).toBe('hello')
| {
"filepath": "test/e2e/app-dir/segment-config-ts/segment-config-ts.test.ts",
"language": "typescript",
"file_size": 2229,
"cut_index": 563,
"middle_length": 229
} |
tTestSetup } from 'e2e-utils'
// CSS data urls are only support in Turbopack
;(process.env.IS_TURBOPACK_TEST ? describe : describe.skip)(
'css-modules-data-urls',
() => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should apply rsc class name from data url correctly', async () => {... | ss('font-weight')
expect(rscElement).toBe('700')
})
it('should apply client class name from data url correctly', async () => {
const browser = await next.browser('/')
const clientElementClass =
(await browser.elementByC | ot.toBe('')
})
it('should apply rsc styles from data url correctly', async () => {
const browser = await next.browser('/')
const rscElement = await browser
.elementByCss('#rsc')
.getComputedC | {
"filepath": "test/e2e/app-dir/css-modules-data-urls/css-modules-data-urls.test.ts",
"language": "typescript",
"file_size": 1397,
"cut_index": 524,
"middle_length": 229
} |
check } from 'next-test-utils'
describe('interception-middleware-rewrite', () => {
const { next, skipped } = nextTestSetup({
files: __dirname,
// TODO: remove after deployment handling is updated
skipDeployment: true,
})
if (skipped) {
return
}
it('should support intercepting routes with a ... | 'not intercepted'
)
await check(() => browser.elementByCss('#modal').text(), 'default')
})
it('should continue to work after using browser back button and following another intercepting route', async () => {
const browser = await nex | owser
.elementByCss('[href="/feed"]')
.click()
.elementByCss('#modal')
.text(),
'intercepted'
)
await check(
() => browser.refresh().elementByCss('#children').text(),
| {
"filepath": "test/e2e/app-dir/interception-middleware-rewrite/interception-middleware-rewrite.test.ts",
"language": "typescript",
"file_size": 2643,
"cut_index": 563,
"middle_length": 229
} |
import { nextTestSetup } from 'e2e-utils'
describe('next-image-src-with-query-without-local-patterns', () => {
const { next, isNextDev, skipped } = nextTestSetup({
files: __dirname,
skipStart: true,
skipDeployment: true,
})
if (skipped) {
return
}
it('should throw error for relative image w... | build()
expect(cliOutput).toContain(
'Image with src "/test.png?v=1" is using a query string which is not configured in images.localPatterns.\nRead more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns'
)
}
| st.png?v=1" is using a query string which is not configured in images.localPatterns.\nRead more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns'
)
} else {
const { cliOutput } = await next. | {
"filepath": "test/e2e/app-dir/next-image-src-with-query-without-local-patterns/next-image-src-with-query-without-local-patterns.test.ts",
"language": "typescript",
"file_size": 1003,
"cut_index": 512,
"middle_length": 229
} |
/lib/next-test-utils'
import { createRedboxSnapshot } from '../../../lib/add-redbox-matchers'
describe('instant validation - server errors', () => {
const { next, skipped, isNextDev, isNextStart, isTurbopack } = nextTestSetup({
files: __dirname,
skipStart: true,
skipDeployment: true,
env: {
NEX... | tart()
})
}
let currentCliOutputIndex = 0
beforeEach(() => {
currentCliOutputIndex = next.cliOutput.length
})
function getCliOutputSinceMark(): string {
if (next.cliOutput.length < currentCliOutputIndex) {
currentCliOutputInde | {
beforeAll(async () => {
await next.build({ args: ['--experimental-build-mode', 'compile'] })
})
afterEach(async () => {
await next.stop()
})
} else {
beforeAll(async () => {
await next.s | {
"filepath": "test/e2e/app-dir/instant-validation/instant-validation-server-errors.test.ts",
"language": "typescript",
"file_size": 8269,
"cut_index": 716,
"middle_length": 229
} |
// Should inject global css for .green selectors
await check(
async () =>
await browser.eval(
`window.getComputedStyle(document.querySelector('.green')).color`
),
'rgb(0, 128, 0)'
)
})
it('should support css modules inside ser... | ss/css-external')
await check(
async () =>
await browser.eval(
`window.getComputedStyle(document.querySelector('main')).paddingTop`
),
'80px'
)
})
})
describe('server | mputedStyle(document.querySelector('#server-cssm')).color`
),
'rgb(0, 128, 0)'
)
})
it('should support external css imports', async () => {
const browser = await next.browser('/c | {
"filepath": "test/e2e/app-dir/app-css/index.test.ts",
"language": "typescript",
"file_size": 30827,
"cut_index": 1331,
"middle_length": 229
} |
from 'e2e-utils'
describe('interception-routes-multiple-catchall', () => {
const { next } = nextTestSetup({
files: __dirname,
})
describe('multi-param catch-all', () => {
it('should intercept when navigating to the same path with route interception', async () => {
const browser = await next.browse... | ByCss('#intercepting-page')
})
it('should intercept when navigating to a multi-param path', async () => {
const browser = await next.browser('/templates/multi/slug')
await browser.elementByCss("[href='/showcase/another/slug']").click() | ept when navigating to a single param path', async () => {
const browser = await next.browser('/templates/multi/slug')
await browser.elementByCss("[href='/showcase/single']").click()
await browser.waitForElement | {
"filepath": "test/e2e/app-dir/interception-routes-multiple-catchall/interception-routes-multiple-catchall.test.ts",
"language": "typescript",
"file_size": 1719,
"cut_index": 537,
"middle_length": 229
} |
ort { isNextDev, nextTestSetup } from 'e2e-utils'
// This test relies on next.build() so it can't work in dev mode.
const _describe = isNextDev ? describe.skip : describe
_describe('after() in static pages - thrown errors', () => {
const { next, skipped } = nextTestSetup({
files: __dirname,
skipStart: true,... | expect(next.cliOutput).toContain(
`My cool error thrown inside after on route "${path}"`
)
}
{
const path = '/page-throws-in-after/promise'
expect(next.cliOutput).toContain(
`Error occurred prerendering page " | ult = await next.build()
expect(buildResult?.exitCode).toBe(1)
{
const path = '/page-throws-in-after/callback'
expect(next.cliOutput).toContain(
`Error occurred prerendering page "${path}"`
)
| {
"filepath": "test/e2e/app-dir/next-after-app-static/build-time-error/build-time-error.test.ts",
"language": "typescript",
"file_size": 1720,
"cut_index": 537,
"middle_length": 229
} |
tTestSetup } from 'e2e-utils'
// TODO(NAR-423): Migrate to Cache Components.
describe.skip('ppr build errors', () => {
;(isNextStart ? describe : describe.skip)('production only', () => {
const { next } = nextTestSetup({
files: __dirname,
skipStart: true,
})
let cliOutput: string
before... | prerendering page "/re-throwing-error".'
)
})
})
describe('outside of a suspense boundary', () => {
it('should fail the build for uncaught errors', async () => {
expect(cliOutput).toContain(
'Error occurred pr | ught prerender errors', async () => {
expect(cliOutput).toContain(
'Error occurred prerendering page "/regular-error-suspense-boundary".'
)
expect(cliOutput).toContain(
'Error occurred | {
"filepath": "test/e2e/app-dir/ppr-errors/ppr-errors.test.ts",
"language": "typescript",
"file_size": 1559,
"cut_index": 537,
"middle_length": 229
} |
estSetup } from 'e2e-utils'
describe('Undefined default export', () => {
const { next, isNextDev } = nextTestSetup({
files: path.join(__dirname),
skipStart: isNextStart,
skipDeployment: true,
})
if (isNextDev) {
it('should error if page component does not have default export', async () => {
... | es not have default export', async () => {
const browser = await next.browser('/specific-path/2')
await expect(browser).toDisplayRedbox(`
{
"code": "E45",
"description": "The default export is not a React Component in | act Component in "/specific-path/1/page"",
"environmentLabel": null,
"label": "Runtime Error",
"source": null,
"stack": [],
}
`)
})
it('should error if layout component do | {
"filepath": "test/e2e/app-dir/undefined-default-export/undefined-default-export.test.ts",
"language": "typescript",
"file_size": 2647,
"cut_index": 563,
"middle_length": 229
} |
import { nextTestSetup } from 'e2e-utils'
import cheerio from 'cheerio'
describe('css-modules-pure-no-check', () => {
const { isNextStart, next } = nextTestSetup({
files: __dirname,
})
it('should apply styles correctly', async () => {
const browser = await next.browser('/')
const elementWithGlobalS... | nk[0].attribs['href']
const res = await next.fetch(cssHref)
const cssCode = await res.text()
expect(cssCode).toInclude(`.global{font-weight:700}`)
expect(cssCode).toInclude(
`::view-transition-old(root){animation-duration: | d a CSS file', async () => {
const html = await next.render('/')
const $html = cheerio.load(html)
const cssLink = $html('link[rel="stylesheet"]')
expect(cssLink.length).toBe(1)
const cssHref = cssLi | {
"filepath": "test/e2e/app-dir/css-modules-pure-no-check/css-modules-pure-no-check.test.ts",
"language": "typescript",
"file_size": 1025,
"cut_index": 512,
"middle_length": 229
} |
mport { nextTestSetup } from 'e2e-utils'
describe('Root Suspense Dynamic Rendering', () => {
const { next, isNextStart } = nextTestSetup({
files: __dirname + '/fixtures/default',
skipDeployment: true,
})
// TODO: remove when there is a test for isNextDev === false
it('placeholder to satisfy at least o... | cted build to succeed for Suspense wrapping dynamic content above HTML',
{ cause: error }
)
}
})
it('should correctly mark route as dynamic', async () => {
// The route should be marked as dynamic (ƒ) not static (○)
| => {
try {
// Should render the page successfully
const $ = await next.render$('/')
expect($('body').text()).toContain('Hello World')
} catch (error) {
throw new Error(
'Expe | {
"filepath": "test/e2e/app-dir/root-suspense-dynamic/root-suspense-dynamic.test.ts",
"language": "typescript",
"file_size": 1061,
"cut_index": 513,
"middle_length": 229
} |
from 'e2e-utils'
describe('app-dir - middleware rewrite with catch-all and parallel routes', () => {
const { next } = nextTestSetup({
files: __dirname,
})
describe('payment route', () => {
it('should rewrite to the specific page instead of the catch-all with parallel route', async () => {
const br... | t text = await browser.elementByCss('#specific-page').text()
expect(text).toBe('payment whoops')
expect(await browser.url()).toBe(next.url + '/payment/whoops')
})
})
describe('anotherRoute', () => {
it('should rewrite to the speci | toBe(next.url + '/payment/test')
})
it('should redirect to the specific page instead of the catch-all with parallel route', async () => {
const browser = await next.browser('/payment/test?redirect=true')
cons | {
"filepath": "test/e2e/app-dir/middleware-rewrite-catchall-priority-with-parallel-route/middleware-rewrite-catchall-priority-with-parallel-route.test.ts",
"language": "typescript",
"file_size": 1751,
"cut_index": 537,
"middle_length": 229
} |
'e2e-utils'
import * as Log from './utils/log'
import { waitForNoRedbox, retry } from '../../../../lib/next-test-utils'
describe('after() in generateStaticParams', () => {
const { next, isNextDev, skipped } = nextTestSetup({
files: __dirname,
skipDeployment: true, // reading CLI logs to observe after
sk... | tIndex)
}
if (isNextDev) {
it('runs after callbacks when visiting a page in dev', async () => {
await next.start()
const browser = await next.browser('/one/a')
expect(await browser.elementByCss('body').text()).toBe('Param: a')
| cliOutput.length < currentCliOutputIndex) {
// cliOutput shrank since we started the test, so something (like a `sandbox`) reset the logs
currentCliOutputIndex = 0
}
return next.cliOutput.slice(currentCliOutpu | {
"filepath": "test/e2e/app-dir/next-after-app-static/generate-static-params/index.test.ts",
"language": "typescript",
"file_size": 2138,
"cut_index": 563,
"middle_length": 229
} |
tTestSetup } from 'e2e-utils'
import { retry, waitFor } from 'next-test-utils'
describe('actions-streaming', () => {
const { next } = nextTestSetup({
files: __dirname,
})
describe('actions returning a ReadableStream', () => {
it('should properly stream the response without buffering', async () => {
... | ect(await browser.elementById('chunks').text()).toInclude(
'Lorem ipsum dolor sit'
)
// Finally, wait for the response to finish streaming.
await waitFor(5000)
await retry(
async () => {
expect(await brows | 'Streaming...'
)
// If we're streaming properly, we should see the first chunks arrive
// quickly.
expect(await browser.elementByCss('h3').text()).toMatch(
/Received \d+ chunks/
)
exp | {
"filepath": "test/e2e/app-dir/actions-streaming/actions-streaming.test.ts",
"language": "typescript",
"file_size": 1265,
"cut_index": 524,
"middle_length": 229
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.