prefix
stringlengths
512
512
suffix
stringlengths
256
256
middle
stringlengths
14
229
meta
dict
tring> subDir?: string turbo?: boolean forcedPort?: string serverReadyPattern?: RegExp patchFileDelay?: number startServerTimeout?: number disableAutoSkewProtection?: boolean } /** * Omit the first argument of a function */ type OmitFirstArgument<F> = F extends ( firstArgument: any, ...args: infer ...
ed installCommand?: InstallCommand public buildCommand?: string public buildArgs?: string[] protected startCommand?: string protected startArgs?: string[] protected dependencies?: PackageJson['dependencies'] = {} protected resolutions?: Package
GE_MANAGER: string = require('../../../package.json').packageManager export class NextInstance { protected files: ResolvedFileConfig protected overrideFiles: ResolvedFileConfig protected nextConfig?: NextConfig protect
{ "filepath": "test/lib/next-modes/base.ts", "language": "typescript", "file_size": 36017, "cut_index": 2151, "middle_length": 229 }
rentSpan: Span) { super.setup(parentSpan) await super.createTestDir({ parentSpan }) } public get cliOutput() { return this._cliOutput || '' } private handleStdio = (childProcess) => { childProcess.stdout.on('data', (chunk) => { const msg = chunk.toString() process.stdout.write(chun...
t(' ') } if (this.buildArgs) { buildArgs.push(...this.buildArgs) } if (args) { buildArgs.push(...args) } if (process.env.NEXT_SKIP_ISOLATE) { // without isolation yarn can't be used and pnpm must be used instead
this._cliOutput += msg this.emit('stderr', [msg]) }) } private getBuildArgs(args?: string[]) { let buildArgs = ['pnpm', 'next', 'build'] if (this.buildCommand) { buildArgs = this.buildCommand.spli
{ "filepath": "test/lib/next-modes/next-dev.ts", "language": "typescript", "file_size": 10359, "cut_index": 921, "middle_length": 229 }
lient Bundles (main)', globs: [ '.next/static/runtime/+(main|webpack)-*', '.next/static/chunks/!(polyfills*)', ], }, { name: 'Legacy Client Bundles (polyfills)', globs: ['.next/static/chunks/+(polyfills)-*'], }, { name: 'Client Pages', globs: [ '.next/static/BUILD_ID/pa...
: async (nextAppDir, fileName) => { if (fileName.startsWith('.next/server/app')) { const manifestJson = await fs.readFile( path.join(nextAppDir, '.next/server/middleware-manifest.json') ) const manifest = JSON.parse(
ge Sizes', globs: ['fetched-pages/!(edge-repeated*)'], }, { name: 'Edge SSR bundle Size', globs: [ '.next/server/pages/edge-ssr.js', '.next/server/app/app-edge-ssr/page.js', ], getRequiredFiles
{ "filepath": "test/.stats-app/stats-config.js", "language": "javascript", "file_size": 4437, "cut_index": 614, "middle_length": 229 }
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex"> <p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut...
me="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0" href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app" target="_blank" rel="n
<div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none"> <a classNa
{ "filepath": "test/.stats-app/app/edge-ssr-repeated/page.js", "language": "javascript", "file_size": 5863, "cut_index": 716, "middle_length": 229 }
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex"> <p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut...
ame="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0" href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app" target="_blank" rel="
<div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none"> <a classN
{ "filepath": "test/.stats-app/app/edge-ssr-repeated-16/page.js", "language": "javascript", "file_size": 5864, "cut_index": 716, "middle_length": 229 }
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex"> <p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut...
ame="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0" href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app" target="_blank" rel="
<div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none"> <a classN
{ "filepath": "test/.stats-app/app/edge-ssr-repeated-17/page.js", "language": "javascript", "file_size": 5864, "cut_index": 716, "middle_length": 229 }
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex"> <p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut...
ame="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0" href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app" target="_blank" rel="
<div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none"> <a classN
{ "filepath": "test/.stats-app/app/edge-ssr-repeated-11/page.js", "language": "javascript", "file_size": 5864, "cut_index": 716, "middle_length": 229 }
from 'e2e-utils' import path from 'path' import fs from 'fs-extra' const testedExamples = [ // Internal features 'active-class-name', 'api-routes-cors', 'api-routes-middleware', 'api-routes-rest', 'basic-css', 'blog', 'blog-starter', 'custom-server', 'hello-world', 'i18n-routing', 'i18n-routing...
describe.each(testedExamples)(`example '%s'`, (example) => { // If there is an issue during a build, jest won't tell us which example caused it // we need to log it ourselfs beforeAll(() => { require('console').log(`Running example '${example}'
', 'with-typescript', 'with-typescript-types', 'with-web-worker', 'with-webassembly', // Library integrations that we can't break 'mdx-pages', 'mdx-remote', 'with-jest', 'with-jest-babel', 'with-turbopack', ]
{ "filepath": "test/examples/examples.test.ts", "language": "typescript", "file_size": 1795, "cut_index": 537, "middle_length": 229 }
quire('fs') const fsp = require('fs/promises') const path = require('path') const { execSync } = require('child_process') const YELLOW = '\x1b[33m' const RESET = '\x1b[0m' /** * Check if the Next.js build is fresh (matches current git HEAD). * Prints warnings to console if build is missing or stale. * @returns {Pr...
Run \`pnpm build\` before running tests.\n${RESET}` ) return } if (!existsSync(buildCommitPath)) { console.warn(`${YELLOW}⚠️ WARNING: Build may be stale!${RESET}`) console.warn( `${YELLOW} Unable to verify build freshness (n
(!existsSync(distPath)) { console.warn(`${YELLOW}⚠️ WARNING: No build found!${RESET}`) console.warn( `${YELLOW} The packages/next/dist directory does not exist.${RESET}` ) console.warn( `${YELLOW}
{ "filepath": "test/lib/check-build-freshness.js", "language": "javascript", "file_size": 1881, "cut_index": 537, "middle_length": 229 }
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex"> <p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut...
ame="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0" href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app" target="_blank" rel="
<div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none"> <a classN
{ "filepath": "test/.stats-app/app/edge-ssr-repeated-13/page.js", "language": "javascript", "file_size": 5864, "cut_index": 716, "middle_length": 229 }
rom 'fs' import type { TraceEvent } from 'next/dist/trace' export interface TraceStructure { events: TraceEvent[] eventsByName: Map<string, TraceEvent[]> eventsById: Map<string, TraceEvent> rootEvents: TraceEvent[] orphanedEvents: TraceEvent[] } /** * Parses a Next.js trace file (e.g. `.next/trace` or `.ne...
trace file and returns a structured representation * with events indexed by name and id, plus root/orphaned classification. */ export function parseTraceFile(tracePath: string): TraceStructure { const allEvents = parseTraceEvents(tracePath) const e
const allEvents: TraceEvent[] = [] for (const line of traceContent.trim().split('\n')) { if (!line.trim()) continue allEvents.push(...(JSON.parse(line) as TraceEvent[])) } return allEvents } /** * Parses a Next.js
{ "filepath": "test/lib/parse-trace-file.ts", "language": "typescript", "file_size": 1747, "cut_index": 537, "middle_length": 229 }
The main use case is for asynchronous e2e tests. It provides a `waitFor` // method that resolves when the log matches some expected asynchronous sequence // of events. This is an alternative to setting up a timer loop. It helps catch // subtle mistakes where the order of events is not expected, or the same // event hap...
.push(value) // Check if we've reached the end of the expected log. If there's a // pending waitFor, and we've reached the last of the expected events, this // will resolve the promise. pingExpectation() } function assert(expectedEven
l. let pendingExpectation: null | { resolve: () => void reject: (error: Error) => void expectedEvents: Array<any> error: Error } = null function log(value: unknown) { // Add to the event log. events
{ "filepath": "test/lib/test-log.ts", "language": "typescript", "file_size": 4458, "cut_index": 614, "middle_length": 229 }
ache-components-errors/utils' export type ValidationEvent = | { type: 'validation_start'; requestId: string; url: string } | { type: 'validation_end'; requestId: string; url: string } export function parseValidationMessages(output: string): ValidationEvent[] { const messageRe = /<VALIDATION_MESSAGE>(.*?)<\/VALI...
= true } = {} ): string { const markerRe = /<VALIDATION_MESSAGE>(.*?)<\/VALIDATION_MESSAGE>/g // Find all marker positions and their content const markers: { index: number endIndex: number data: ValidationEvent }[] = [] let m: RegExp
1])) } catch (err) { throw new Error(`Failed to parse message '${match[1]}'`, { cause: err, }) } } return events } export function extractBuildValidationError( cliOutput: string, { isMinified
{ "filepath": "test/lib/e2e-utils/instant-validation.ts", "language": "typescript", "file_size": 4975, "cut_index": 614, "middle_length": 229 }
ortsImmutableAssets: boolean = false private _writtenHostsLine: string | null = null protected throwIfUnavailable(): void | never { if (this.isStopping !== null) { throw new Error('Next.js is no longer available.', { cause: this.isStopping, }) } if (this.isDestroyed !== null) { ...
public get supportsImmutableAssets() { return process.env.IS_TURBOPACK_TEST ? this._supportsImmutableAssets : false } private async deployUsingCustomScript(): Promise<{ url: string }> { const deployScriptPath = process.env.NEXT_TEST_DEPLOY_S
process } } public get buildId() { // get deployment ID via fetch since we can't access // build artifacts directly return this._buildId } public get deploymentId() { return this._deploymentId }
{ "filepath": "test/lib/next-modes/next-deploy.ts", "language": "typescript", "file_size": 17376, "cut_index": 921, "middle_length": 229 }
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex"> <p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut...
me="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0" href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app" target="_blank" rel="n
<div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none"> <a classNa
{ "filepath": "test/.stats-app/app/edge-ssr-repeated-10/page.js", "language": "javascript", "file_size": 5863, "cut_index": 716, "middle_length": 229 }
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex"> <p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut...
ame="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0" href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app" target="_blank" rel="
<div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none"> <a classN
{ "filepath": "test/.stats-app/app/edge-ssr-repeated-20/page.js", "language": "javascript", "file_size": 5864, "cut_index": 716, "middle_length": 229 }
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex"> <p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut...
ame="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0" href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app" target="_blank" rel="
<div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none"> <a classN
{ "filepath": "test/.stats-app/app/edge-ssr-repeated-24/page.js", "language": "javascript", "file_size": 5864, "cut_index": 716, "middle_length": 229 }
ype { Playwright } from './browsers/playwright' import { NextInstance } from 'e2e-utils' declare global { namespace jest { // eslint-disable-next-line @typescript-eslint/no-unused-vars -- module augmentation needs to match generic params even if unused interface Matchers<R> { /** * Inline snapsh...
intented content in the snapshot should be reported to the Next.js DX team. * `<FIXME-internal-frame>` in the snapshot would be unintended. * `<FIXME-project-root>` in the snapshot would be unintended. * `<FIXME-file-protocol>` in the
instead. * * * If the project root appears in the snapshot, pass in the `NextInstance` * as well to normalize the snapshot e.g. `await expect({ browser, next }).toDisplayRedbox()`. * * Un
{ "filepath": "test/lib/add-redbox-matchers.ts", "language": "typescript", "file_size": 14304, "cut_index": 921, "middle_length": 229 }
hookPropertyMap = new Map([ ['react', reactDir], ['react/package.json', `${reactDir}/package.json`], ['react/jsx-runtime', `${reactDir}/jsx-runtime`], ['react/jsx-dev-runtime', `${reactDir}/jsx-dev-runtime`], ['react-dom', `${reactDomDir}`], ['react-dom/package.json', `${reactDomDir}/package.json`], ['re...
mod._resolveFilename mod._resolveFilename = function (request, parent, isMain, options) { const hookResolved = hookPropertyMap.get(request) if (hookResolved) request = hookResolved return resolveFilename.call(mod, request, parent, isMain, options) }
tDomDir}/server.edge`], ]) const resolveFilename =
{ "filepath": "test/lib/react-channel-require-hook.js", "language": "javascript", "file_size": 914, "cut_index": 606, "middle_length": 52 }
atcherObject = { pathname: string search?: string method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'HEAD' | 'OPTIONS' } export type RequestMatcher = | RequestMatcherObject | ((request: PlaywrightRequest) => Promise<boolean>) export type RequestTracker = ReturnType<typeof createRequestTracker> /** Allows capturi...
): Promise<[result: T, captured: PlaywrightResponse]> { const isMatchingRequest = async (request: PlaywrightRequest) => { if (typeof requestMatcher === 'function') { // This can be async to allow matching on things like `request.allHeade
n `method` and `pathname`. */ async function captureResponse<T>( action: () => Promise<T>, { request: requestMatcher, timeoutMs = 5000, }: { request: RequestMatcher timeoutMs?: number }
{ "filepath": "test/lib/e2e-utils/request-tracker.ts", "language": "typescript", "file_size": 6262, "cut_index": 716, "middle_length": 229 }
te _deploymentId: string | undefined private _supportsImmutableAssets: boolean = false private _cliOutput: string = '' private _prerenderFinishedTimeMS: number | null = null constructor(opts: NextInstanceOpts) { super(opts) if (!opts.disableAutoSkewProtection && shouldUseTurbopack()) { this.env...
async setup(parentSpan: Span) { super.setup(parentSpan) await super.createTestDir({ parentSpan }) } private handleStdio = (childProcess) => { childProcess.stdout.on('data', (chunk) => { const msg = chunk.toString() process.stdo
return this._deploymentId } public get supportsImmutableAssets() { return process.env.IS_TURBOPACK_TEST ? this._supportsImmutableAssets : false } public get cliOutput() { return this._cliOutput } public
{ "filepath": "test/lib/next-modes/next-start.ts", "language": "typescript", "file_size": 9418, "cut_index": 921, "middle_length": 229 }
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex"> <p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut...
ame="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0" href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app" target="_blank" rel="
<div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none"> <a classN
{ "filepath": "test/.stats-app/app/edge-ssr-repeated-18/page.js", "language": "javascript", "file_size": 5864, "cut_index": 716, "middle_length": 229 }
debugPrint = (...args: unknown[]) => { const prettyArgs = args .map((arg) => typeof arg === 'string' ? arg : inspect(arg, { colors: process.stdout.isTTY }) ) .join(' ') const timestamp = new Date().toISOString().split('T')[1] return process.stdout.write(`[${timestamp}] ${prett...
turn new Promise((resolve, reject) => { const instance = spawn( 'node', [...((opts && opts.nodeArgs) || []), '--no-deprecation', scriptPath], { env: { HOSTNAME: '::', ...env }, cwd: opts && opts.cwd, } )
tring[] onStdout?: (data: any) => void onStderr?: (data: any) => void // If true, the promise will reject if the process exits with a non-zero code shouldRejectOnError?: boolean } ): Promise<ChildProcess> { re
{ "filepath": "test/lib/next-test-utils.ts", "language": "typescript", "file_size": 61836, "cut_index": 2151, "middle_length": 229 }
des/next-deploy' import { shouldUseTurbopack } from '../next-test-utils' export type { NextInstance } export type { Playwright } from '../browsers/playwright' const individualTestTimeout = 60 * 1000 // Keep a higher timeout for setup hooks (e.g. initial createNext/startup), // but enforce 60s per test case via wrapp...
__NEXT_E2E_WRAPPED_TEST_FNS__?: WeakMap<Function, Function> } const wrapJestTestFn = <T extends Function>(fn: T): T => { const e2eGlobal = global as E2ETestGlobal const wrappedFns = e2eGlobal.__NEXT_E2E_WRAPPED_TEST_FNS__ ?? (e2eGlobal.__NEX
.env.NEXT_E2E_TEST_TIMEOUT, 10) if (!Number.isNaN(parsedTimeout)) { setupTimeout = parsedTimeout } } jest.setTimeout(setupTimeout) type E2ETestGlobal = typeof globalThis & { __NEXT_E2E_TEST_CONFIG_PATCHED__?: boolean
{ "filepath": "test/lib/e2e-utils/index.ts", "language": "typescript", "file_size": 11125, "cut_index": 921, "middle_length": 229 }
T_TEST_USE_RSPACK === '1' const ROOT_PACKAGE_MANAGER = require('../../package.json').packageManager async function installDependencies(cwd, tmpDir) { const args = [ 'install', '--strict-peer-dependencies=false', '--no-frozen-lockfile', `--config.cacheDir=${tmpDir}`, ] if (PREFER_OFFLINE) { a...
nment variables // so some installs would just fail. // TODO: ideally every test fixture would run with minimumReleaseAgeExclude but // that requires some work in monorepo test suites. npm_config_minimum_release_age: undefined,
t ignores `npm_config_*` env variables. // This isn't set in CI but some local environments set this from the // pnpm-workspace.yaml for unknown reasons. // minimumReleaseAgeExclude is not propagated with enviro
{ "filepath": "test/lib/create-next-install.js", "language": "javascript", "file_size": 9423, "cut_index": 921, "middle_length": 229 }
k from 'next/link' export default function Page() { // NOTE: these links must be kept in sync with `path` variables used in the test return ( <main> <ul> <li> <Link href="/simple">/simple</Link> </li> <li> <Link href="/private-cache">/private-cache</Link> ...
<li> <Link href="/apis/123">/apis/123</Link> </li> <li> <Link href="/sync-io/static">/sync-io/static</Link> </li> <li> <Link href="/sync-io/runtime">/sync-io/runtime</Link> </li>
</li>
{ "filepath": "test/development/app-dir/cache-components-dev-warmup/fixtures/without-prefetch-config/app/page.tsx", "language": "tsx", "file_size": 816, "cut_index": 522, "middle_length": 14 }
('app-dir - owner-stack-invalid-element-type', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should catch invalid element from a browser only component', async () => { const browser = await next.browser('/browser') await expect(browser).toDisplayRedbox(` { "descriptio...
-only.js (8:7) @ BrowserOnly > 8 | <Foo /> | ^", "stack": [ "BrowserOnly app/browser/browser-only.js (8:7)", "Inner app/browser/page.js (11:10)", "Page app/browser/page.js (15:10)", ],
le it's defined in, or you might have mixed up default and named imports. Check the render method of \`BrowserOnly\`.", "environmentLabel": null, "label": "Runtime Error", "source": "app/browser/browser
{ "filepath": "test/development/app-dir/owner-stack-invalid-element-type/owner-stack-invalid-element-type.test.ts", "language": "typescript", "file_size": 2672, "cut_index": 563, "middle_length": 229 }
escribe('hmr-parallel-routes', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should update parallel routes via HMR', async () => { const browser = await next.browser('/') expect(await browser.elementByCss('#bar').text()).toBe('Bar Page') expect(await browser.elementByCss('#foo...
'Bar Page Updated') await next.patchFile('app/@foo/page.tsx', (content) => content.replace('Foo Page', 'Foo Page Updated') ) await waitForNoRedbox(browser) expect(await browser.elementByCss('#foo').text()).toBe('Foo Page Updated')
ect(await browser.elementByCss('#bar').text()).toBe(
{ "filepath": "test/development/app-dir/hmr-parallel-routes/hmr-parallel-routes.test.ts", "language": "typescript", "file_size": 922, "cut_index": 606, "middle_length": 52 }
mport { execSync } from 'node:child_process' import { getCacheDirectory } from 'next/dist/lib/helpers/get-cache-directory' import { nextTestSetup } from 'e2e-utils' import { parseTraceFile } from '../../../lib/parse-trace-file' describe('rage restart trace attributes', () => { // Use a fake upload URL so traceUpload...
StateFilePath = () => join(getCacheDirectory('nextjs-nodejs'), 'dev-state.json') beforeEach(async () => { // Ensure each test starts from a clean stopped state with no prior session. await next.stop('SIGTERM').catch(() => {}) rmSync(getD
extTestSetup({ files: __dirname, skipStart: true, startArgs: ['--experimental-upload-trace', fakeUploadUrl], }) if (!isNextDev) { it('should be skipped in production', () => {}) return } const getDev
{ "filepath": "test/development/app-dir/rage-restart-trace/rage-restart-trace.test.ts", "language": "typescript", "file_size": 4420, "cut_index": 614, "middle_length": 229 }
ck, } from 'next-test-utils' describe('app-dir - owner-stack-react-missing-key-prop', () => { const { isTurbopack, next } = nextTestSetup({ files: __dirname, }) it('should catch invalid element from on rsc component', async () => { const browser = await next.browser('/rsc') await openRedbox(browser)...
"app/rsc/page.tsx (7:9) @ <anonymous> 5 | <div> 6 | {list.map((item, index) => ( > 7 | <span>{item}</span> | ^ 8 | ))} 9 | </div>
hot(` [ "span <anonymous>", "<anonymous> app/rsc/page.tsx (7:9)", "Array.map <anonymous>", "Page app/rsc/page.tsx (6:13)", ] `) expect(source).toMatchInlineSnapshot(`
{ "filepath": "test/development/app-dir/owner-stack-react-missing-key-prop/owner-stack-react-missing-key-prop.test.ts", "language": "typescript", "file_size": 3125, "cut_index": 614, "middle_length": 229 }
{ nextTestSetup } from 'e2e-utils' import { retry } from 'next-test-utils' const cacheComponentsEnabled = process.env.__NEXT_CACHE_COMPONENTS === 'true' describe('dev-output', () => { const { next, isTurbopack } = nextTestSetup({ files: __dirname, }) it('shows Cache Components indicator when enabled', asy...
k') expect(output).toContain('Cache Components') } } else { // When cache components env is not set, should not show the indicator expect(output).toContain('Next.js') if (isTurbopack) { expect(outpu
toContain('Next.js') expect(output).toContain('Turbopack') expect(output).toContain('Cache Components') } else { expect(output).toContain('Next.js') expect(output).toContain('webpac
{ "filepath": "test/development/app-dir/dev-output/dev-output.test.ts", "language": "typescript", "file_size": 1182, "cut_index": 518, "middle_length": 229 }
const nextDevBootstrapOutputIndex = next.cliOutput.length const browser = await next.browser('/request/cookies') const browserLogs = await browser.log() const browserConsoleWarnings = browserLogs .filter((log) => log.source === 'warning') .map((log) => log.message) const terminalOutpu...
}) }) it('warnings on sync draftMode access', async () => { const nextDevBootstrapOutputIndex = next.cliOutput.length const browser = await next.browser('/request/draftMode') const browserLogs = await browser.log() const browserConso
) expect({ browserConsoleWarnings, terminalCookieErrors }).toEqual({ browserConsoleWarnings: [expect.stringContaining('`cookies().get`.')], terminalCookieErrors: [expect.stringContaining('`cookies().get`.')],
{ "filepath": "test/development/app-dir/async-request-warnings/async-request-warnings.test.ts", "language": "typescript", "file_size": 5798, "cut_index": 716, "middle_length": 229 }
from 'e2e-utils' import { retry } from 'next-test-utils' import stripAnsi from 'strip-ansi' // turbopack.ignoreIssue only works with Turbopack ;(process.env.IS_TURBOPACK_TEST ? describe : describe.skip)( 'css-parse-error-recovery', () => { describe('with turbopack.ignoreIssue config', () => { const { nex...
s.status).toBe(200) const html = await res.text() expect(html).toContain('css error page') }) it('should suppress CSS parse error from cli output when ignored', async () => { const outputIndex = next.cliOutput.length
}, ], }, }, }) if (skipped) return it('should render page with ignored CSS parse error', async () => { const res = await next.fetch('/css-error') expect(re
{ "filepath": "test/development/app-dir/css-parse-error-recovery/css-parse-error-recovery.test.ts", "language": "typescript", "file_size": 1938, "cut_index": 537, "middle_length": 229 }
nextTestSetup } from 'e2e-utils' import { retry } from 'next-test-utils' describe('isolated-dev-build', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should create dev artifacts in .next/dev/ directory', async () => { await retry(async () => { expect(await next.hasFile('.next/...
rld') await next.patchFile('app/page.tsx', (content) => { return content.replace('hello world', 'hello updated world') }) await retry(async () => { expect(await browser.elementByCss('p').text()).toBe('hello updated world') })
ait browser.elementByCss('p').text()).toBe('hello wo
{ "filepath": "test/development/app-dir/isolated-dev-build/isolated-dev-build.test.ts", "language": "typescript", "file_size": 836, "cut_index": 520, "middle_length": 52 }
('server-navigation-error', () => { const { next } = nextTestSetup({ files: __dirname, }) describe('pages router', () => { it('should error on navigation API redirect', async () => { const browser = await next.browser('/pages/redirect') await expect(browser).toDisplayRedbox(` { ...
error on navigation API notFound', async () => { const browser = await next.browser('/pages/not-found') await expect(browser).toDisplayRedbox(` { "code": "E1041", "description": "Next.js navigation API is not allowed t
source": "pages/pages/redirect.tsx (4:11) @ Page > 4 | redirect('/') | ^", "stack": [ "Page pages/pages/redirect.tsx (4:11)", ], } `) }) it('should
{ "filepath": "test/development/app-dir/server-navigation-error/server-navigation-error.test.ts", "language": "typescript", "file_size": 2730, "cut_index": 563, "middle_length": 229 }
to restart if (isStarted) { await next.stop() } await next.start() isStarted = true }) it('explicit react-dom/server.browser usage in app code', async () => { const browser = await next.browser( '/exports/app-code/react-dom-server-browser-explicit' ) await waitForNoRedbox(b...
", "renderToString", "resume", "version" ] }" `) } else { expect(await browser.elementByCss('main').text()).toMatchInlineSnapshot(` "{ "default": [ "renderT
"renderToStaticMarkup", "renderToString", "resume", "version" ], "named": [ "default", "renderToReadableStream", "renderToStaticMarkup
{ "filepath": "test/development/app-dir/ssr-in-rsc/ssr-in-rsc.test.ts", "language": "typescript", "file_size": 25243, "cut_index": 1331, "middle_length": 229 }
t detected)', () => { const { next } = nextTestSetup({ files: __dirname, env: { CLAUDECODE: '1' }, }) it('creates AGENTS.md and CLAUDE.md at the project root when neither exists', async () => { // A request is required to synchronize the test with the auto-gen // hook — `✓ Ready in X` is logged b...
xt/dist/docs/') const claudeContent = fs.readFileSync( path.join(next.testDir, 'CLAUDE.md'), 'utf-8' ) expect(claudeContent).toBe('@AGENTS.md\n') }) }) describe('agent-rules auto-generate on next dev (no agent)', () => { const
t.fetch('/') const agentsContent = fs.readFileSync( path.join(next.testDir, 'AGENTS.md'), 'utf-8' ) expect(agentsContent).toContain(AGENT_RULES_MARKER) expect(agentsContent).toContain('node_modules/ne
{ "filepath": "test/development/app-dir/agent-rules-auto-generate/agent-rules-auto-generate.test.ts", "language": "typescript", "file_size": 5117, "cut_index": 716, "middle_length": 229 }
apseCallStackFrames, } from 'next-test-utils' describe('error-ignored-frames', () => { const { isTurbopack, next } = nextTestSetup({ files: __dirname, }) it('should be able to collapse ignored frames in server component', async () => { const browser = await next.browser('/') await waitForRedbox(brow...
tack trace that was ignore-listed. // It'll contain implementation details that may change and // shouldn't break this test. expect(ignoreListedStack).not.toHaveLength(0) }) it('should be able to collapse ignored frames in client component
seCallStackFrames(browser) const expandedStack = await getRedboxCallStack(browser) const ignoreListedStack = expandedStack.filter( (line) => !defaultStack.includes(line) ) // We don't care about the exact s
{ "filepath": "test/development/app-dir/error-overlay/error-ignored-frames/error-ignored-frames.test.ts", "language": "typescript", "file_size": 3658, "cut_index": 614, "middle_length": 229 }
utils' import { retry, waitFor } from 'next-test-utils' describe('duplicate-runtime-error', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should not rerender the overlay for the same runtime error', async () => { const browser = await next.browser('/') const badge = await browser...
the same value after a while without re-rendersw. // Should always display the badge, should not re-render by hiding it again for (let i = 0; i < 40; i++) { const errorProp = await badge.getAttribute('data-error') expect(errorProp).to
errorProp).toBe('true') }) // Still present
{ "filepath": "test/development/app-dir/error-overlay/duplicate-runtime-error/duplicate-runtime-error.test.ts", "language": "typescript", "file_size": 904, "cut_index": 547, "middle_length": 52 }
ort { nextTestSetup } from 'e2e-utils' import { waitForNoRedbox } from 'next-test-utils' describe('app-dir - async-client-component', () => { const { next } = nextTestSetup({ files: __dirname, }) it('app router client component async module', async () => { const browser = await next.browser('/client') ...
s error is often caused by accidentally adding \`'use client'\` to a module that was originally written for the server.", "environmentLabel": null, "label": "Console Error", "source": null, "stack": [], },
rder to implement. await expect(browser).toDisplayCollapsedRedbox(` [ { "code": "E394", "description": "<Page> is an async Client Component. Only Server Components can be async at the moment. Thi
{ "filepath": "test/development/app-dir/error-overlay/async-client-component/async-client-component.test.ts", "language": "typescript", "file_size": 1641, "cut_index": 537, "middle_length": 229 }
ames in assertions. function normalizeBrowserConsoleStackTrace(trace: unknown) { if (typeof trace !== 'string') { return trace } return ( trace // Removes React's internals i.e. incomplete ignore-listing .split( /at (react-stack-bottom-frame|Object\.react_stack_bottom_frame).*/m ...
errorStack: string | undefined const browser = await next.browser('/browser/uncaught', { beforePageLoad: (page) => { page.on('pageerror', (error: unknown) => { errorStack = (error as any).stack }) }, }) if
, '') .trim() ) } describe('app-dir - owner-stack', () => { const { isTurbopack, next } = nextTestSetup({ files: __dirname, }) it('should log stitched error for browser uncaught errors', async () => { let
{ "filepath": "test/development/app-dir/owner-stack/owner-stack.test.ts", "language": "typescript", "file_size": 5092, "cut_index": 716, "middle_length": 229 }
t webdriver from 'next-webdriver' import { join } from 'path' import { resolveNextTgzFilename, run, useTempDir, } from '../../../production/create-next-app/utils' const TEST_TIMEOUT_MS = 5 * 60 * 1000 describe('create-next-app default template', () => { let nextTgzFilename: string beforeAll(() => { nex...
{ cwd, } ) expect(exitCode).toBe(0) const dir = join(cwd, projectName) const nextBin = join(dir, 'node_modules/next/dist/bin/next') const port = await findPort() const server = sp
ectName = 'default-app' const { exitCode } = await run( [ projectName, '--yes', ...(process.env.NEXT_RSPACK ? ['--rspack'] : []), ], nextTgzFilename,
{ "filepath": "test/development/app-dir/create-next-app-default/create-next-app-default.test.ts", "language": "typescript", "file_size": 4216, "cut_index": 614, "middle_length": 229 }
utils' describe('app dir - dynamic error trace', () => { const { next, skipped } = nextTestSetup({ files: __dirname, }) if (skipped) return it('should show the error trace', async () => { const browser = await next.browser('/') // TODO(veil): Where is the stackframe for app/page.js? await exp...
application/rendering/static-and-dynamic#dynamic-rendering", "environmentLabel": "Server", "label": "Runtime Error", "source": "app/lib.js (4:13) @ Foo > 4 | useHeaders() | ^", "stack": [ "Fo
nfo here: https://nextjs.org/docs/app/building-your-
{ "filepath": "test/development/app-dir/dynamic-error-trace/index.test.ts", "language": "typescript", "file_size": 909, "cut_index": 547, "middle_length": 52 }
ort { nextTestSetup } from 'e2e-utils' import { waitForNoRedbox } from 'next-test-utils' describe('hmr-iframe', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should do HMR when rendering two server component changes at the same time', async () => { let browser = await next.browser('/...
('iframe')).contentFrame()) .locator('p') .innerText() ).toEqual('content-new') const cliOutput = next.cliOutput.slice(cliOutputLength) expect(cliOutput).not.toContain('Error') expect(cliOutput).not.toContain('Could not fin
xt.cliOutput.length await next.patchFile('app/page2/page.tsx', (content) => content.replace('content', 'content-new') ) await waitForNoRedbox(browser) expect( await (await (await browser.elementByCss
{ "filepath": "test/development/app-dir/hmr-iframe/hmr-iframe.test.ts", "language": "typescript", "file_size": 1069, "cut_index": 515, "middle_length": 229 }
figs', hasRuntimePrefetch: false, fixturePath: 'fixtures/without-prefetch-config', }, { description: 'with runtime prefetch configs', hasRuntimePrefetch: true, fixturePath: 'fixtures/with-prefetch-config', }, ])( 'cache-components-tasks - $description', ({ fixturePath, hasRuntimePrefetch }...
che|Prerender|Prefetch|Prefetchable|Server)\\b).*` ) const logMessages = logs.map((log) => log.message) const messages = logMessages.filter((message) => logPattern.test(message)) // If there's zero or more than one logs that match,
age: string }>, message: string, expectedEnvironment: string ) { // Match logs that contain the message, with any environment. const logPattern = new RegExp( `^(?=.*\\b${message}\\b)(?=.*\\b(Ca
{ "filepath": "test/development/app-dir/cache-components-tasks/cache-components-tasks.test.ts", "language": "typescript", "file_size": 7148, "cut_index": 716, "middle_length": 229 }
rs' import { connection } from 'next/server' function immediate() { return new Promise<void>((resolve) => setImmediate(resolve)) } export async function Static({ label }: { label: string }) { await immediate() await immediate() console.log(`after immediate - static - ${label}`) return <div>Static - {label}<...
me - {label}</div> } export async function Dynamic({ label }: { label: string }) { await connection() console.log(`after connection - ${label}`) await immediate() await immediate() console.log(`after immediate - dynamic - ${label}`) return <di
immediate - runtime - ${label}`) return <div>Runti
{ "filepath": "test/development/app-dir/cache-components-tasks/fixtures/without-prefetch-config/app/shared.tsx", "language": "tsx", "file_size": 883, "cut_index": 547, "middle_length": 52 }
import { nextTestSetup } from 'e2e-utils' import { retry } from 'next-test-utils' describe('logging-incoming-request', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should not log requests matching ignore pattern', async () => { // Make requests that should be ignored based on config...
expect(next.cliOutput).not.toContain('GET /hello') expect(next.cliOutput).not.toContain('GET /non-existent') expect(next.cliOutput).not.toContain('GET /_next/static/test.js') expect(next.cliOutput).toContain('GET /foo') }) }) })
ait next.fetch('/_next/static/test.js') expect(response.status).toBe(404) // Make a request that should be logged response = await next.fetch('/foo') expect(response.status).toBe(200) await retry(() => {
{ "filepath": "test/development/app-dir/logging-incoming-request/logging-incoming-request.test.ts", "language": "typescript", "file_size": 997, "cut_index": 512, "middle_length": 229 }
it.skip describe('module preservation', () => { itTurbopackDev( 'does not re-evaluate an unmodified module when page module changes', async () => { const browser = await next.browser('/module-preservation') // Wait for initial render with module timestamp await retry(async (...
it next.patchFile('app/module-preservation/page.tsx', (content) => content.replace('hello world', 'hello universe') ) // Wait for HMR to apply and verify the page updated await retry(async () => { const text = a
e evaluation timestamp const initialModuleEvalTime = await browser .elementByCss('#module-eval-time') .text() // Make a change to the page that doesn't affect the unmodified module awa
{ "filepath": "test/development/app-dir/server-hmr/server-hmr.test.ts", "language": "typescript", "file_size": 12442, "cut_index": 921, "middle_length": 229 }
outdent' describe('Cache Components Dev Errors', () => { const { isTurbopack, next, isRspack } = nextTestSetup({ files: __dirname, }) it('should show a red box error on the SSR render', async () => { const browser = await next.browser('/error') // TODO(veil): The "Page <anonymous>" frame should be ...
Page > 2 | const random = Math.random() | ^", "stack": [ "Page app/error/page.tsx (2:23)", "Page <anonymous>", ], } `) }) it('should not show a red box error on client nav
"code": "E1261", "description": "Next.js encountered the unstable value Math.random() while prerendering.", "environmentLabel": "Server", "label": "Instant", "source": "app/error/page.tsx (2:23) @
{ "filepath": "test/development/app-dir/cache-components-dev-errors/cache-components-dev-errors.test.ts", "language": "typescript", "file_size": 6403, "cut_index": 716, "middle_length": 229 }
tring) { return fetchCached( `https://next-data-api-endpoint.vercel.app/api/random?key=${encodeURIComponent('cached-' + cacheKey)}` ) } export async function fetchCached(url: string) { const response = await fetch(url, { cache: 'force-cache' }) return response.text() } export async function getCachedData(...
label, cacheKey, }: { label: string cacheKey: string }) { // This components tests if we correctly handle the case where resolving a cache // reveals another cache in the children. When we're filling caches, we should fill both. const data1 =
g }) { const data = await getCachedData(cacheKey) console.log(`after cache read - ${label}`) return ( <dl> <dt>Cached Data</dt> <dd>{data}</dd> </dl> ) } export async function SuccessiveCachedData({
{ "filepath": "test/development/app-dir/cache-components-dev-warmup/fixtures/without-prefetch-config/app/data-fetching.tsx", "language": "tsx", "file_size": 2260, "cut_index": 563, "middle_length": 229 }
function PrivateCachedData({ label, cacheKey, }: { label: string cacheKey: string }) { const data = await getPrivateCachedData(cacheKey) console.log(`after private cache read - ${label}`) return ( <dl> <dt>Private Cached Data (Page)</dt> <dd>{data}</dd> </dl> ) } export async funct...
<dd>{data1}</dd> <dd> <SuccessivePrivateCachedDataChild label={label} cacheKey={cacheKey} /> </dd> </dl> ) } async function SuccessivePrivateCachedDataChild({ label, cacheKey, }: { label: string cacheKey: string }) {
als another cache in the children. When we're filling caches, we should fill both. const data1 = await getPrivateCachedData(`${cacheKey}-successive-1`) return ( <dl> <dt>Private Cached Data (successive reads)</dt>
{ "filepath": "test/development/app-dir/cache-components-dev-warmup/fixtures/without-prefetch-config/app/private-cache/data-fetching.tsx", "language": "tsx", "file_size": 1313, "cut_index": 524, "middle_length": 229 }
Suspense } from 'react' import { CachedData, UncachedFetch } from '../data-fetching' import { PrivateCachedData, SuccessivePrivateCachedData } from './data-fetching' const CACHE_KEY = '/private-cache/__PAGE__' export default async function Page() { return ( <main> <h1>Warmup Dev Renders - private cache</...
e private caches..."> <SuccessivePrivateCachedData label="page" cacheKey={CACHE_KEY} /> </Suspense> <Suspense fallback="Loading uncached fetch..."> <UncachedFetch label="page" cacheKey={CACHE_KEY} /> </Suspense> </mai
se> <Suspense fallback="Loading two successiv
{ "filepath": "test/development/app-dir/cache-components-dev-warmup/fixtures/without-prefetch-config/app/private-cache/page.tsx", "language": "tsx", "file_size": 837, "cut_index": 520, "middle_length": 52 }
tring) { return fetchCached( `https://next-data-api-endpoint.vercel.app/api/random?key=${encodeURIComponent('cached-' + cacheKey)}` ) } export async function fetchCached(url: string) { const response = await fetch(url, { cache: 'force-cache' }) return response.text() } export async function getCachedData(...
label, cacheKey, }: { label: string cacheKey: string }) { // This components tests if we correctly handle the case where resolving a cache // reveals another cache in the children. When we're filling caches, we should fill both. const data1 =
g }) { const data = await getCachedData(cacheKey) console.log(`after cache read - ${label}`) return ( <dl> <dt>Cached Data</dt> <dd>{data}</dd> </dl> ) } export async function SuccessiveCachedData({
{ "filepath": "test/development/app-dir/cache-components-dev-warmup/fixtures/with-prefetch-config/app/data-fetching.tsx", "language": "tsx", "file_size": 2260, "cut_index": 563, "middle_length": 229 }
k from 'next/link' export default function Page() { // NOTE: these links must be kept in sync with `path` variables used in the test return ( <main> <ul> <li> <Link href="/simple">/simple</Link> </li> <li> <Link href="/private-cache">/private-cache</Link> ...
<li> <Link href="/apis/123">/apis/123</Link> </li> <li> <Link href="/sync-io/static">/sync-io/static</Link> </li> <li> <Link href="/sync-io/runtime">/sync-io/runtime</Link> </li>
</li>
{ "filepath": "test/development/app-dir/cache-components-dev-warmup/fixtures/with-prefetch-config/app/page.tsx", "language": "tsx", "file_size": 816, "cut_index": 522, "middle_length": 14 }
} from 'react' import { UncachedFetch, CachedData } from '../data-fetching' import { PrivateCachedData } from './data-fetching' export const unstable_instant = true export const unstable_prefetch = 'force-runtime' const CACHE_KEY = '/private-cache/__LAYOUT__' export default function Layout({ children }: { children:...
cache..."> <PrivateCachedData label="layout" cacheKey={CACHE_KEY} /> </Suspense> <Suspense fallback="Loading uncached fetch..."> <UncachedFetch label="layout" cacheKey={CACHE_KEY} /> </Suspense> </section>
EY} /> <Suspense fallback="Loading private
{ "filepath": "test/development/app-dir/cache-components-dev-warmup/fixtures/with-prefetch-config/app/private-cache/layout.tsx", "language": "tsx", "file_size": 852, "cut_index": 529, "middle_length": 52 }
m 'react' import { UncachedFetch, CachedData } from '../data-fetching' import { ShortLivedCache } from './data-fetching' export const unstable_instant = true export const unstable_prefetch = 'force-runtime' const CACHE_KEY = __dirname + '/__LAYOUT__' export default function Layout({ children }: { children: React.Rea...
.."> <ShortLivedCache label="layout" cacheKey={CACHE_KEY} /> </Suspense> <Suspense fallback="Loading uncached fetch..."> <UncachedFetch label="layout" cacheKey={CACHE_KEY} /> </Suspense> </section> </>
<Suspense fallback="Loading short-lived cache.
{ "filepath": "test/development/app-dir/cache-components-dev-warmup/fixtures/with-prefetch-config/app/short-lived-cache/layout.tsx", "language": "tsx", "file_size": 850, "cut_index": 535, "middle_length": 52 }
from 'e2e-utils' import { waitForNoRedbox, hasErrorToast } from 'next-test-utils' describe('ssr-only-error', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should show ssr only error in error overlay', async () => { const browser = await next.browser('/') // TODO(veil): Missing O...
) it('should not handle internal nextjs errors that will be handled by error boundaries', async () => { const browser = await next.browser('/notfound', { pushErrorAsConsoleLog: true, }) await waitForNoRedbox(browser) expect(await
"Runtime Error", "source": "app/page.tsx (5:11) @ Component > 5 | throw new Error('SSR only error') | ^", "stack": [ "Component app/page.tsx (5:11)", ], } `) }
{ "filepath": "test/development/app-dir/ssr-only-error/ssr-only-error.test.ts", "language": "typescript", "file_size": 1562, "cut_index": 537, "middle_length": 229 }
{ nextTestSetup } from 'e2e-utils' import { waitForRedbox, waitForNoRedbox } from 'next-test-utils' describe('develop - app-dir - edge errros hmr', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should recover from build errors when server component error', async () => { const browse...
hen client component error', async () => { const browser = await next.browser('/') const clientComponentSource = await next.readFile('app/comp.client.js') await next.patchFile('app/comp.client.js', (content) => { return content.replace('
ace('{/* < */}', '<') // uncomment }) await waitForRedbox(browser) await next.patchFile('app/comp.server.js', clientComponentSource) await waitForNoRedbox(browser) }) it('should recover from build errors w
{ "filepath": "test/development/app-dir/edge-errors-hmr/index.test.ts", "language": "typescript", "file_size": 1189, "cut_index": 518, "middle_length": 229 }
"code": "E394", "componentStack": "... <Next.js Internal Component> <Next.js Internal Component> <Next.js Internal Component> <Next.js Internal Component> <Next.js Internal Component> <Next.js Internal Com...
mise}> > <p> > <p> ... ... ...", "description": "In HTML, <p> cannot be a descendant of <p>. This
<Next.js Internal Component> <Next.js Internal Component> <Next.js Internal Component> <Page params={Promise} searchParams={Pro
{ "filepath": "test/development/app-dir/hydration-error-count/hydration-error-count.test.ts", "language": "typescript", "file_size": 16505, "cut_index": 921, "middle_length": 229 }
ad: boolean | Promise<void> } } if (!globalThis._testState) { globalThis._testState = { initialized: false, reload: false, } } export const subscribeToHMR = async () => { const state = globalThis._testState if (state.initialized) { if (state.reload === true) { let resolve: () => void ...
e.initialized = true const ws = new WebSocket(`ws://localhost:${process.env.PORT}/_next/hmr`) ws.onmessage = (event: any) => { if (typeof event.data === 'string') { const data = JSON.parse(event.data) if (data.type === 'serverComponen
await state.reload } return } stat
{ "filepath": "test/development/app-dir/hmr-iframe/app/page1/subscribeToHMR.ts", "language": "typescript", "file_size": 951, "cut_index": 582, "middle_length": 52 }
rs' import { connection } from 'next/server' function immediate() { return new Promise<void>((resolve) => setImmediate(resolve)) } export async function Static({ label }: { label: string }) { await immediate() await immediate() console.log(`after immediate - static - ${label}`) return <div>Static - {label}<...
me - {label}</div> } export async function Dynamic({ label }: { label: string }) { await connection() console.log(`after connection - ${label}`) await immediate() await immediate() console.log(`after immediate - dynamic - ${label}`) return <di
immediate - runtime - ${label}`) return <div>Runti
{ "filepath": "test/development/app-dir/cache-components-tasks/fixtures/with-prefetch-config/app/shared.tsx", "language": "tsx", "file_size": 883, "cut_index": 547, "middle_length": 52 }
check, retry } from 'next-test-utils' import { join } from 'path' describe('app-dir watch-config-file', () => { const { next } = nextTestSetup({ files: join(__dirname, 'fixture'), }) it('should output config file change and restart server for app router', async () => { await check(async () => next.cliOu...
, }, ] }, } module.exports = nextConfig` ) return next.cliOutput }, /Found a change in next\.config\.js\. Restarting the server to apply the changes\.\.\./)
reactStrictMode: true, async redirects() { return [ { source: '/about', destination: '/', permanent: false
{ "filepath": "test/development/app-dir/watch-config-file/index.test.ts", "language": "typescript", "file_size": 2777, "cut_index": 563, "middle_length": 229 }
s/with-prefetch-config', }, ])( 'cache-components-dev-warmup - $description', ({ fixturePath, hasRuntimePrefetch }) => { const { next, isTurbopack } = nextTestSetup({ files: nodePath.join(__dirname, fixturePath), }) // Restart the dev server for each test to clear the in-memory cache. // We...
urce: string; message: string }>, message: string, expectedEnvironment: string ) { // Match logs that contain the message, with any environment. const logPattern = new RegExp( `^(?=.*\\b${message}\\b)(?=.*\\b(Cache|Prere
s no point restarting if this is the first test. isFirstTest = false return } await next.stop() await next.clean() await next.start() }) function assertLog( logs: Array<{ so
{ "filepath": "test/development/app-dir/cache-components-dev-warmup/cache-components.dev-warmup.test.ts", "language": "typescript", "file_size": 13532, "cut_index": 921, "middle_length": 229 }
ep successive cache reads</h1> <One /> </main> ) } async function One() { const cache1 = await fastCache() console.log('after cache 1') return <Two cache1={cache1} /> } async function Two({ cache1 }) { const cache2 = await slowCache(1) console.log('after cache 2') return <Three cache1={cache1}...
2: {cache2}</div> <div>Cache 3: {cache3}</div> </div> ) } async function fastCache() { 'use cache' return Math.random() } async function slowCache(_key: number) { 'use cache' await new Promise((resolve) => setTimeout(resolve)) retur
<div>Cache 1: {cache1}</div> <div>Cache
{ "filepath": "test/development/app-dir/cache-components-dev-warmup/fixtures/without-prefetch-config/app/successive-caches/page.tsx", "language": "tsx", "file_size": 932, "cut_index": 606, "middle_length": 52 }
Suspense } from 'react' import { CachedData, UncachedFetch } from '../data-fetching' import { PrivateCachedData, SuccessivePrivateCachedData } from './data-fetching' const CACHE_KEY = '/private-cache/__PAGE__' export default async function Page() { return ( <main> <h1>Warmup Dev Renders - private cache</...
e private caches..."> <SuccessivePrivateCachedData label="page" cacheKey={CACHE_KEY} /> </Suspense> <Suspense fallback="Loading uncached fetch..."> <UncachedFetch label="page" cacheKey={CACHE_KEY} /> </Suspense> </mai
se> <Suspense fallback="Loading two successiv
{ "filepath": "test/development/app-dir/cache-components-dev-warmup/fixtures/with-prefetch-config/app/private-cache/page.tsx", "language": "tsx", "file_size": 837, "cut_index": 520, "middle_length": 52 }
export const unstable_instant = true export const unstable_prefetch = 'force-runtime' export default async function Page() { return ( <main> <h1>Warmup Dev Renders - deep successive cache reads</h1> <One /> </main> ) } async function One() { const cache1 = await fastCache() console.log('af...
che 2: {cache2}</div> <div>Cache 3: {cache3}</div> </div> ) } async function fastCache() { 'use cache' return Math.random() } async function slowCache(_key: number) { 'use cache' await new Promise((resolve) => setTimeout(resolve)) r
che2} /> } async function Three({ cache1, cache2 }) { console.log('after caches 1 and 2') const cache3 = await slowCache(2) console.log('after cache 3') return ( <div> <div>Cache 1: {cache1}</div> <div>Ca
{ "filepath": "test/development/app-dir/cache-components-dev-warmup/fixtures/with-prefetch-config/app/successive-caches/page.tsx", "language": "tsx", "file_size": 1019, "cut_index": 512, "middle_length": 229 }
lient' import { useEffect } from 'react' /** * This page is to verify that the Dev Tools surface animates as expected and without jank: * * 1. When the page loads with "1 Issue" present, * no animations should trigger (count change, width growth, etc.). * The surface should assume its intrinsic position im...
. */ // Play with this between `1` and `2` // to make sure the surface doesn't animate the plural form (s) const ERROR_COUNT = 2 export default function Page() { const clx = typeof window === 'undefined' ? 'server' : 'client' useEffect(() => {
ause it will * look janky when the `deltaMs` between changes is less than the `animationDurationMs`. * * 3. When another error comes in, and `deltaMs` is greater, the surface should * subtly bounce and animate the count
{ "filepath": "test/development/app-dir/hydration-error-count/app/animation-test/page.tsx", "language": "tsx", "file_size": 1152, "cut_index": 518, "middle_length": 229 }
Setup } from 'e2e-utils' import { retry } from 'next-test-utils' describe('logging-incoming-request', () => { const { next } = nextTestSetup({ files: __dirname, overrideFiles: { 'next.config.js': ` module.exports = { logging: { incomingRequests: false } }...
0) // Wait for GET /foo to be logged await retry(() => { expect(next.cliOutput).not.toContain('GET /foo') }) // Verify no requests were logged expect(next.cliOutput).not.toContain('GET /') expect(next.cliOutput).not.toContai
.fetch('/hello') expect(response.status).toBe(20
{ "filepath": "test/development/app-dir/logging-incoming-request/logging-incoming-request-false.test.ts", "language": "typescript", "file_size": 861, "cut_index": 529, "middle_length": 52 }
kies, headers } from 'next/headers' import { CachedData } from '../../data-fetching' import { connection } from 'next/server' import { Suspense } from 'react' export const unstable_instant = true export const unstable_prefetch = 'force-runtime' const CACHE_KEY = __dirname + '/__PAGE__' export default function Page({...
<LogAfter label="headers" api={() => headers()} /> <LogAfter label="params" api={() => params} /> <LogAfter label="searchParams" api={() => searchParams} /> {/* Dynamic */} <LogAfter label="connection" api={() => connection()}
or not) </p> <CachedData cacheKey={CACHE_KEY} label="page" /> <LogAfter label="--- dynamic stage ---" api={() => connection()} /> {/* Runtime */} <LogAfter label="cookies" api={() => cookies()} />
{ "filepath": "test/development/app-dir/cache-components-dev-warmup/fixtures/with-prefetch-config/app/apis/[param]/page.tsx", "language": "tsx", "file_size": 1438, "cut_index": 524, "middle_length": 229 }
s' const cacheComponentsEnabled = process.env.__NEXT_CACHE_COMPONENTS === 'true' describe('use-cache-errors', () => { const { next, isRspack, isTurbopack } = nextTestSetup({ files: __dirname, }) it('should not show a false-positive compiler error about a misplaced "use cache" directive', async () => { ...
ait next.browser('/') await browser.elementById('action-button').click() if (isRspack) { // TODO: the source is missing and the stack leaks rspack internals await expect(browser).toDisplayRedbox(` { "description": "Attem
isplacement detection. const browser = await next.browser('/') await waitForNoRedbox(browser) }) it('should show a runtime error when calling the incorrectly used cache function', async () => { const browser = aw
{ "filepath": "test/development/app-dir/use-cache-errors/use-cache-errors.test.ts", "language": "typescript", "file_size": 4353, "cut_index": 614, "middle_length": 229 }
kies, headers } from 'next/headers' import { CachedData } from '../../data-fetching' import { connection } from 'next/server' import { Suspense } from 'react' const CACHE_KEY = __dirname + '/__PAGE__' export default function Page({ params, searchParams }) { return ( <main> <p> This page checks whe...
api={() => params} /> <LogAfter label="searchParams" api={() => searchParams} /> {/* Dynamic */} <LogAfter label="connection" api={() => connection()} /> </main> ) } function LogAfter({ label, api }: { label: string; api: () => Pr
ter label="--- dynamic stage ---" api={() => connection()} /> {/* Runtime */} <LogAfter label="cookies" api={() => cookies()} /> <LogAfter label="headers" api={() => headers()} /> <LogAfter label="params"
{ "filepath": "test/development/app-dir/cache-components-dev-warmup/fixtures/without-prefetch-config/app/apis/[param]/page.tsx", "language": "tsx", "file_size": 1351, "cut_index": 524, "middle_length": 229 }
test-utils' describe('browser-log-forwarding error level', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should only forward error logs to terminal', async () => { const outputIndex = next.cliOutput.length await next.browser('/') await retry(() => { const output = next...
g hydration noise const browserLogs = output .split('\n') .filter( (line) => line.includes('[browser]') && !line.includes('Next.js hydrate callback fire') ) .join('\n') expect(browserLogs).toMatc
// Filter to only browser forwarded logs, excludin
{ "filepath": "test/development/app-dir/browser-log-forwarding/fixtures/error-level/error-level.test.ts", "language": "typescript", "file_size": 982, "cut_index": 582, "middle_length": 52 }
from 'e2e-utils' import { retry } from 'next-test-utils' describe('browser-log-forwarding verbose level', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should forward all logs to terminal', async () => { const outputIndex = next.cliOutput.length await next.browser('/') await...
Filter to only browser forwarded logs, excluding noise const browserLogs = output .split('\n') .filter( (line) => line.includes('[browser]') && !line.includes('Next.js hydrate callback fire') && !line.i
expect(output).toContain('[browser] browser log:') expect(output).toContain('[browser] browser debug:') }) // Get final output after logs are forwarded const output = next.cliOutput.slice(outputIndex) //
{ "filepath": "test/development/app-dir/browser-log-forwarding/fixtures/verbose-level/verbose-level.test.ts", "language": "typescript", "file_size": 1664, "cut_index": 537, "middle_length": 229 }
getRedboxDescription, openRedbox, waitForNoRedbox, retry, } from 'next-test-utils' describe('Cache Components Dev Errors', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should not show a red box error on the SSR render', async () => { const browser = await next.browser('/cach...
ser) let priorValue = latestValue latestValue = await browser.elementByCss('#value').text() expect(latestValue).not.toBe(priorValue) }) await browser.elementByCss('#refresh').click() await retry(async () => { await wait
atestValue latestValue = await browser.elementByCss('#value').text() expect(latestValue).toBe(priorValue) await browser.elementByCss('#refresh').click() await retry(async () => { await waitForNoRedbox(brow
{ "filepath": "test/development/app-dir/cache-components-dev-cache-scope/cache-components-dev-cache-scope.test.ts", "language": "typescript", "file_size": 2790, "cut_index": 563, "middle_length": 229 }
the dev time warning but will reintroduce it when we add in dev-time prerendering. // The tests will likely have to change but I'd like to keep the fixture and assertions as a starting point. describe.skip('dynamic-requests warnings', () => { const { next } = nextTestSetup({ files: __dirname, }) let cliInde...
form/prerender/time" used `Date.now()`' ) expect(next.cliOutput).not.toContain( 'Route "/platform/prerender/time" used `performance.now()`' ) await next.fetch('/platform/prerender/time') expect(next.cliOutput).toContain( 'R
'Route "/platform/prerender/time" used `Date()`' ) expect(next.cliOutput).not.toContain( 'Route "/platform/prerender/time" used `new Date()`' ) expect(next.cliOutput).not.toContain( 'Route "/plat
{ "filepath": "test/development/app-dir/cache-components-warnings/cache-components.warnings.test.ts", "language": "typescript", "file_size": 4052, "cut_index": 614, "middle_length": 229 }
Setup } from 'e2e-utils' import { retry } from 'next-test-utils' describe('typed-env', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should have env types from next config', async () => { await retry(async () => { const envDTS = await next.readFile(`${next.distDir}/types/env.d....
/** Loaded from \`.env.development.local\` */ FROM_ENV_DEV_LOCAL?: string /** Loaded from \`.env.local\` */ FROM_ENV_LOCAL?: string /** Loaded from \`.env.development\` */ FROM_EN
'FROM_ENV_PROD_LOCAL') expect(envDTS).toEqual( outdent` // Type definitions for Next.js environment variables declare global { namespace NodeJS { interface ProcessEnv {
{ "filepath": "test/development/app-dir/typed-env/typed-env.test.ts", "language": "typescript", "file_size": 2637, "cut_index": 563, "middle_length": 229 }
{ nextTestSetup } from 'e2e-utils' import { retry } from 'next-test-utils' import fs from 'fs' import path from 'path' describe('app-dir watch-distdir-deletion', () => { const { next } = nextTestSetup({ files: path.join(__dirname, 'fixture'), }) it('should restart the server when distDir is deleted', async...
recursive: true, force: true, }) // Wait for restart message and server to come back up await retry( async () => { expect(next.cliOutput).toMatch(/The directory at .* was deleted/) }, 30_000, 1000
s compiled const warmupRes = await next.fetch('/') expect(warmupRes.status).toBe(200) // Delete .next (which also removes .next/dev, the watched distDir) await fs.promises.rm(path.join(next.testDir, '.next'), {
{ "filepath": "test/development/app-dir/watch-distdir-deletion/index.test.ts", "language": "typescript", "file_size": 1221, "cut_index": 518, "middle_length": 229 }
m } from './form' import defaultAction1, { foo, bar, baz, qux } from './actions1' import defaultAction2 from './actions2' import defaultAction3 from './actions3' import Link from 'next/link' import { ServerComponent } from './server-component' export default function Page() { const action1 = async () => { 'use s...
{bar} /> <Form id="form-6" action={baz} /> <Form id="form-7" action={qux} /> <Form id="form-8" action={action1} /> <Form id="form-9" action={action2} /> <Form id="form-10" action={async () => { 'use s
t /> <Form id="form-1" action={defaultAction1} /> <Form id="form-2" action={defaultAction2} /> <Form id="form-3" action={defaultAction3} /> <Form id="form-4" action={foo} /> <Form id="form-5" action=
{ "filepath": "test/development/app-dir/source-mapping/app/page.tsx", "language": "tsx", "file_size": 1484, "cut_index": 524, "middle_length": 229 }
er } from './hydration-marker' export default function Page() { return ( <div> <HydrationMarker /> <h1 data-testid="home-title">Instant Navigation Mode Demo</h1> <p> This fixture tests the <strong>Instant Navigation Mode</strong> toggle in Next.js Dev Tools. When enabled, naviga...
Click the link below. You should see the loading skeleton instead of the final page content. </li> <li> Click the blue <em>Instant UI only</em> indicator to unblock dynamic data and resume normal navigation.
trong> (click the Next.js logo in the corner). </li> <li> Toggle <strong>Instant Navigation Mode</strong> to <em>On</em>. The indicator turns blue. </li> <li>
{ "filepath": "test/development/app-dir/instant-navs-devtools/app/(main)/page.tsx", "language": "tsx", "file_size": 2317, "cut_index": 563, "middle_length": 229 }
stSetup({ files: __dirname, }) it('should render the segment explorer for parallel routes', async () => { const browser = await next.browser('/parallel-routes') expect(await getSegmentExplorerContent(browser)).toMatchInlineSnapshot(` "app/ [layout.tsx] parallel-routes/ [layout.tsx, page.tsx] ...
parallel-routes-edge/ [layout.tsx, page.tsx] @bar/ [layout.tsx, page.tsx] @foo/ [layout.tsx, page.tsx]" `) expect(await getSegmentExplorerRoute(browser)).toBe('/parallel-routes-edge') }) it('should render the segment explorer for nes
plorer for parallel routes in edge runtime', async () => { const browser = await next.browser('/parallel-routes-edge') expect(await getSegmentExplorerContent(browser)).toMatchInlineSnapshot(` "app/ [layout.tsx]
{ "filepath": "test/development/app-dir/segment-explorer/segment-explorer.test.ts", "language": "typescript", "file_size": 6708, "cut_index": 716, "middle_length": 229 }
ort { nextTestSetup } from 'e2e-utils' import { retry } from 'next-test-utils' describe('browser-log-forwarding warn level', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should forward warn and error logs to terminal', async () => { const outputIndex = next.cliOutput.length awai...
it('\n') .filter( (line) => line.includes('[browser]') && !line.includes('Next.js hydrate callback fire') ) .join('\n') expect(browserLogs).toMatchInlineSnapshot(` "[browser] browser warn: this is a w
n:') }) // Get final output after logs are forwarded const output = next.cliOutput.slice(outputIndex) // Filter to only browser forwarded logs, excluding hydration noise const browserLogs = output .spl
{ "filepath": "test/development/app-dir/browser-log-forwarding/fixtures/warn-level/warn-level.test.ts", "language": "typescript", "file_size": 1107, "cut_index": 515, "middle_length": 229 }
mport { revalidateTag, cacheLife, cacheTag } from 'next/cache' import { fetchData } from '../api/data' // import { Suspense } from 'react' // import { cookies, headers } from 'next/headers' function InnerComponent({ children }) { return <span id="value">{children}</span> } async function refresh() { 'use server' ...
lt async function Home() { return ( <> <form action={refresh}> <button id="refresh">Refresh</button> </form> <form action={reload}> <button id="reload">Reload</button> </form> <Component /> </> ) }
{await fetchData()}</InnerComponent> } export defau
{ "filepath": "test/development/app-dir/cache-components-dev-cache-scope/app/cached/page.tsx", "language": "tsx", "file_size": 821, "cut_index": 513, "middle_length": 52 }
ERROR: type should be string, got " https://github.com/vercel/next.js/issues/86662.\n// The bug from occurs if we have:\n// - a cache (which requires warming = a restart in dev)\n// - a dynamic function (blocked until the dynamic stage, like an uncached fetch)\n// that dedupes concurrent calls. note that that's not quite the same as caching it,\n// because it gets dropped after finishing.\n\nimport { Suspense } from 'react'\n\nexport default async function Page() {\n return (\n <main>\n <Suspense fallback={<div>Loading...</div>}>\n <d"
cached(), // This fetch going to be blocked on the dynamic stage. // That promise should be rejected when restarting. // If it's not rejected (like it wasn't before the fix), // it'll remain hanging, and we'll never render anything. f
iv id="random"> <DynamicRandom /> </div> </Suspense> </main> ) } async function DynamicRandom() { const [, random] = await Promise.all([ // ensure that there's a restart to warm this cache.
{ "filepath": "test/development/app-dir/cache-components-reused-promise/app/page.tsx", "language": "tsx", "file_size": 1962, "cut_index": 537, "middle_length": 229 }
ser: Playwright): Promise<void> { await retry(async () => { const cookie = await browser.eval(() => document.cookie) expect(cookie).toMatch(/next-instant-navigation-testing=[^;]+/) }) } async function clearInstantModeCookie(browser: Playwright) { await browser.eval(() => { document.co...
ser.elementByCss('[data-instant-nav]').click() } async function clickStartCapturing(browser: Playwright) { await browser .locator('.instant-nav-capture-button', { hasText: 'Start Capturing' }) .click() await waitForInstantModeCooki
=> { const cookie = await browser.eval(() => document.cookie) expect(cookie).not.toContain('next-instant-navigation-testing=') }) } async function clickInstantNavMenuItem(browser: Playwright) { await brow
{ "filepath": "test/development/app-dir/instant-navs-devtools/instant-navs-devtools.test.ts", "language": "typescript", "file_size": 19494, "cut_index": 1331, "middle_length": 229 }
function PrivateCachedData({ label, cacheKey, }: { label: string cacheKey: string }) { const data = await getPrivateCachedData(cacheKey) console.log(`after private cache read - ${label}`) return ( <dl> <dt>Private Cached Data (Page)</dt> <dd>{data}</dd> </dl> ) } export async funct...
<dd>{data1}</dd> <dd> <SuccessivePrivateCachedDataChild label={label} cacheKey={cacheKey} /> </dd> </dl> ) } async function SuccessivePrivateCachedDataChild({ label, cacheKey, }: { label: string cacheKey: string }) {
als another cache in the children. When we're filling caches, we should fill both. const data1 = await getPrivateCachedData(`${cacheKey}-successive-1`) return ( <dl> <dt>Private Cached Data (successive reads)</dt>
{ "filepath": "test/development/app-dir/cache-components-dev-warmup/fixtures/with-prefetch-config/app/private-cache/data-fetching.tsx", "language": "tsx", "file_size": 1313, "cut_index": 524, "middle_length": 229 }
c } from 'fs' import { createServer } from 'http' import { spawn } from 'child_process' import { parseTraceFile } from '../../../lib/parse-trace-file' describe('enabled features in trace', () => { const { next, isNextDev } = nextTestSetup({ files: __dirname, startArgs: ['--no-server-fast-refresh'], }) i...
wait new Promise((resolve) => setTimeout(resolve, 500)) } const traceStructure = parseTraceFile(tracePath) // Verify start-dev-server span has feature tags const startDevServerEvents = traceStructure.eventsByName.get('start-dev-serv
'.next/dev/trace') // Trigger page request to generate traces if (!existsSync(tracePath)) { const $ = await next.render$('/') expect($('p').text()).toBe('hello world') await next.stop('SIGTERM') a
{ "filepath": "test/development/app-dir/enabled-features-trace/enabled-features-trace.test.ts", "language": "typescript", "file_size": 4407, "cut_index": 614, "middle_length": 229 }
nents. describe.skip('source-mapping', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should work with server actions passed to client components', async () => { const browser = await next.browser('/') expect(await browser.elementByCss('#form-1 p').text()).toBe('initial') awai...
rm-2 p').text()).toBe( 'default exported anonymous function expression' ) }) expect(await browser.elementByCss('#form-3 p').text()).toBe('initial') await browser.elementByCss('#form-3 button').click() await retry(async () =>
ssion' ) }) expect(await browser.elementByCss('#form-2 p').text()).toBe('initial') await browser.elementByCss('#form-2 button').click() await retry(async () => { expect(await browser.elementByCss('#fo
{ "filepath": "test/development/app-dir/source-mapping/source-mapping.test.ts", "language": "typescript", "file_size": 6946, "cut_index": 716, "middle_length": 229 }
tTestSetup } from 'e2e-utils' import { retry } from 'next-test-utils' describe('typed-env', () => { const { next } = nextTestSetup({ files: __dirname, env: { NODE_ENV: 'production', }, }) it('should have env types from next config', async () => { await retry(async () => { const envDT...
odeJS { interface ProcessEnv { /** Loaded from \`.env.production.local\` */ FROM_ENV_PROD_LOCAL?: string /** Loaded from \`.env.local\` */ FROM_ENV_LOCAL?: string /** Loaded
('FROM_ENV_DEV') expect(envDTS).not.toContain('FROM_ENV_DEV_LOCAL') expect(envDTS).toMatchInlineSnapshot(` "// Type definitions for Next.js environment variables declare global { namespace N
{ "filepath": "test/development/app-dir/typed-env/typed-env-prod.test.ts", "language": "typescript", "file_size": 1374, "cut_index": 524, "middle_length": 229 }
e client' import { useEffect, useState } from 'react' import { getValue, getAcceptCallCount, subscribe } from './dep-observer.cjs' // Track when this module was evaluated (should NOT change on dep update) const evaluatedAt = Date.now() export default function DepAcceptCjsPage() { const [depValue, setDepValue] = us...
: number) => { setDepValue(newValue) setAcceptCallCount(newCount) }) }, []) return ( <div> <p id="dep-value">{depValue}</p> {evalTime !== null && ( <p id="parent-eval-time">Parent Evaluated At: {evalTime}</p>
alTime(evaluatedAt) // dep-observer.cjs registers module.hot.accept('./dep', cb) in CJS context. // When dep.ts changes, the CJS module handles it and notifies subscribers. return subscribe((newValue: string, newCount
{ "filepath": "test/development/app-dir/hmr-dep-accept/app/dep-accept-cjs/page.tsx", "language": "tsx", "file_size": 1092, "cut_index": 515, "middle_length": 229 }
{ nextTestSetup } from 'e2e-utils' describe('turbopack-import-assertions-use', () => { const { next, isTurbopack } = nextTestSetup({ files: __dirname, }) if (!isTurbopack) { it('should skip for webpack', () => {}) return } it('should apply raw loader via turbopackUse import assertion', async (...
await next.render$('/') expect($('#module-type').text()).toBe('Hello via module type') }) it('should apply identity loader with turbopackModuleType json', async () => { const $ = await next.render$('/') expect($('#json-type').text()).toBe
n', async () => { const $ = await next.render$('/') expect($('#replaced').text()).toBe('Value is: turbopackUse works!') }) it('should apply raw loader with turbopackModuleType ecmascript', async () => { const $ =
{ "filepath": "test/development/app-dir/turbopack-import-assertions-use/turbopack-import-assertions-use.test.ts", "language": "typescript", "file_size": 1224, "cut_index": 518, "middle_length": 229 }
ldcard', () => { describe('default behavior', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should resolve a wildcard alias', async () => { const $ = await next.render$('/wildcard-alias') expect($('body').text()).toMatch(/world/) }) }) describe('without base...
'], }, }, exclude: ['node_modules', '**/*.test.ts', '**/*.test.tsx'], }, null, 2 ), }, }) it('should resolve a wildcard alias', async () => { const $ = await n
paths: { '*': ['./node_modules/*
{ "filepath": "test/development/jsconfig-paths-wildcard/jsconfig-paths-wildcard.test.ts", "language": "typescript", "file_size": 984, "cut_index": 582, "middle_length": 52 }
rip-ansi' import { nextTestSetup } from 'e2e-utils' describe('config validation - validation only runs once', () => { const { next } = nextTestSetup({ files: { 'pages/index.js': ` export default function Page() { return <p>hello world</p> } `, 'next.config.js': ` module.exports ...
hes ? validationHeaderMatches.length : 0 // Count occurrences of specific invalid option mentions const invalidOptionMatches = output.match(/invalidOption/g) const invalidOptionCount = invalidOptionMatches ? invalidOptionMatc
await next.fetch('/') const output = stripAnsi(next.cliOutput) const validationHeaderMatches = output.match( /Invalid next\.config\.js options detected:/g ) const validationHeaderCount = validationHeaderMatc
{ "filepath": "test/development/config-validation/index.test.ts", "language": "typescript", "file_size": 1722, "cut_index": 537, "middle_length": 229 }
utils' import { retry } from 'next-test-utils' describe('App asPath', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should not have any changes in asPath after a bundle rebuild', async () => { const browser = await next.browser('/') const text = await browser.elementByCss('body'...
'replace with this' ) await next.patchFile('pages/_app.js', editedContent) await retry(async () => { const newContent = await browser.elementByCss('body').text() expect(newContent).toBe( '{ "url": { "query": {}, "pathna
nt = originalContent.replace( 'find this',
{ "filepath": "test/development/app-aspath/app-aspath.test.ts", "language": "typescript", "file_size": 907, "cut_index": 547, "middle_length": 52 }
ute type', () => { const { next } = nextTestSetup({ files: __dirname, }) describe('getServerSideProps', () => { it('should update when going from dynamic -> static', async () => { const browser = await next.browser('/pages/gssp') await waitForStaticIndicator(browser, 'Dynamic') // val...
ages/gssp']").click() await waitForStaticIndicator(browser, 'Dynamic') }) it('should be marked dynamic on first load', async () => { const browser = await next.browser('/pages/gssp') await waitForStaticIndicator(browser, 'Dynam
static -> dynamic', async () => { const browser = await next.browser('/pages') await waitForStaticIndicator(browser, 'Static') // validate static -> dynamic updates await browser.elementByCss("[href='/p
{ "filepath": "test/development/dev-indicator/dev-indicator.test.ts", "language": "typescript", "file_size": 5847, "cut_index": 716, "middle_length": 229 }
port { nextTestSetup } from 'e2e-utils' import { retry } from 'next-test-utils' const installCheckVisible = (browser) => { return browser.eval(`(function() { window.checkInterval = setInterval(function() { const root = document.querySelector('nextjs-portal').shadowRoot; const statusElement = root.q...
(window.checkInterval) }, 5) })()`) } describe('Dev Rendering Indicator', () => { const { next } = nextTestSetup({ files: __dirname, }) it('Shows rendering indicator when navigating between pages', async () => { // Ensure both pages a
re showing any status (rendering, compiling, etc.) window.showedIndicator = window.showedIndicator || ( statusElement !== null || (status && status !== 'none') ) if (window.showedIndicator) clearInterval
{ "filepath": "test/development/dev-indicator/dev-rendering-indicator.test.ts", "language": "typescript", "file_size": 1715, "cut_index": 537, "middle_length": 229 }
from 'e2e-utils' import { check } from 'next-test-utils' describe('correct tsconfig.json defaults', () => { const { next } = nextTestSetup({ files: { 'pages/index.tsx': 'export default function Page() {}', }, skipStart: true, dependencies: { typescript: 'latest', '@types/react': 'la...
.json') return content && content !== '{}' ? 'ready' : 'retry' }, 'ready') const tsconfig = JSON.parse(content) expect(next.cliOutput).not.toContain('moduleResolution') expect(tsconfig.compilerOptions).toEqual( exp
'tsconfig.json').catch(() => false) ).toBeFalse() await next.start() let content: string // wait for tsconfig to be written await check(async () => { content = await next.readFile('tsconfig
{ "filepath": "test/development/correct-tsconfig-defaults/index.test.ts", "language": "typescript", "file_size": 1675, "cut_index": 537, "middle_length": 229 }
`) }) const port = await findPort() await new Promise<void>((res) => { server.listen(port, () => res()) }) return { server, port, } } function withBasePath(basePath: string, path: string) { return `${basePath}${path}` } function getImageOptimizerPath(basePath: string) { return withBas...
erer: options.referer } : {}), 'sec-fetch-mode': 'no-cors', 'sec-fetch-site': 'cross-site', }, } ) } function requestInternalDevMiddleware( appPort: string | number, basePath: string, origin: string ) { return fetchViaH
ath: string, options: { referer?: string } = {} ) { return fetchViaHTTP( appPort, withBasePath(basePath, '/_next/static/chunks/pages/_app.js'), undefined, { headers: { ...(options.referer ? { ref
{ "filepath": "test/development/basic/allowed-dev-origins.test.ts", "language": "typescript", "file_size": 16773, "cut_index": 921, "middle_length": 229 }
estSetup } from 'e2e-utils' import { check } from 'next-test-utils' describe('Legacy decorators SWC option', () => { describe('with extended tsconfig', () => { const { next } = nextTestSetup({ files: { 'tsconfig.json': new FileRef( join(__dirname, 'legacy-decorators/tsconfig-extended.json...
{ browser = await next.browser('/') const text = await browser.elementByCss('#count').text() expect(text).toBe('Current number: 0') await browser.elementByCss('#increase').click() await check( () => browse
ages')), }, dependencies: { mobx: '6.3.7', 'mobx-react': '7.2.1', }, }) it('should compile with legacy decorators enabled from extended config', async () => { let browser try
{ "filepath": "test/development/basic/legacy-decorators.test.ts", "language": "typescript", "file_size": 2132, "cut_index": 563, "middle_length": 229 }
estSetup } from 'e2e-utils' import { fetchViaHTTP, renderViaHTTP } from 'next-test-utils' describe.each([[''], ['/docs']])( 'misc basic dev tests, basePath: %p', (basePath: string) => { const { next } = nextTestSetup({ files: { pages: new FileRef(join(__dirname, 'misc/pages')), public: ne...
to public files', async () => { const data = await renderViaHTTP(next.url, basePath + '/data/data.txt') expect(data).toBe('data') const legacy = await renderViaHTTP( next.url, basePath + '/static/legacy.txt' )
owser = await next.browser(basePath + '/process-env') const nodeEnv = await browser.elementByCss('#node-env').text() expect(nodeEnv).toBe('development') await browser.close() }) it('should allow access
{ "filepath": "test/development/basic/misc.test.ts", "language": "typescript", "file_size": 2447, "cut_index": 563, "middle_length": 229 }
trong': return '**' + styled.value + '**' case 'code': return '`' + styled.value + '`' case 'line': return styled.value.map(styledStringToMarkdown).join('') case 'stack': return styled.value.map(styledStringToMarkdown).join('\n') default: throw new Error('Unknown StyledStri...
((a, b) => { const a_ = JSON.stringify(a) const b_ = JSON.stringify(b) if (a_ < b_) return -1 if (a_ > b_) return 1 return 0 }) } function raceIterators<T>(iterators: AsyncIterableIterator<T>[]) { const nexts = iterator
rkdown(issue.detail)), filePath: issue.filePath && normalizePath(issue.filePath), source: issue.source && { ...issue.source, source: normalizePath(issue.source.source.ident), }, })) .sort
{ "filepath": "test/development/basic/next-rs-api.test.ts", "language": "typescript", "file_size": 24300, "cut_index": 1331, "middle_length": 229 }