prefix
stringlengths
512
512
suffix
stringlengths
256
256
middle
stringlengths
14
229
meta
dict
import { Suspense } from 'react' import { connection } from 'next/server' import { HydrationIndicator } from '../../hydration-indicator' import waitForMarkerFile from '../../../waitForMarkerFile' export default async function Page() { // Trigger the Suspense-around-body in the root layout so that no static shell is ...
SlowServerComponent() { await connection() await waitForMarkerFile() const randomValue = Math.floor(Math.random() * 1000) return ( <div id="dynamic"> <div>{`Random value: ${randomValue}`}</div> <HydrationIndicator id="dynamic-hydrat
rationIndicator id="shell-hydrated" /> <hr /> <Suspense fallback={<div id="dynamic-fallback">Loading...</div>}> <SlowServerComponent /> </Suspense> </div> </main> ) } async function
{ "filepath": "test/e2e/app-dir/ppr-partial-hydration/app/without-shell/without-metadata/page.tsx", "language": "tsx", "file_size": 1021, "cut_index": 512, "middle_length": 229 }
{ Suspense } from 'react' import { connection } from 'next/server' import { HydrationIndicator } from '../../hydration-indicator' import waitForMarkerFile from '../../../waitForMarkerFile' import type { Metadata } from 'next' export async function generateMetadata(): Promise<Metadata> { await connection() return ...
se fallback={<div id="dynamic-fallback">Loading...</div>}> <SlowServerComponent /> </Suspense> </div> </main> ) } async function SlowServerComponent() { await connection() await waitForMarkerFile() const randomValue = M
eturn ( <main id="shell"> <h1>This is a page with no static shell + with streaming metadata</h1> <div> <p>Dynamic shell</p> <HydrationIndicator id="shell-hydrated" /> <hr /> <Suspen
{ "filepath": "test/e2e/app-dir/ppr-partial-hydration/app/without-shell/with-streaming-metadata/page.tsx", "language": "tsx", "file_size": 1187, "cut_index": 518, "middle_length": 229 }
configuration is NOT realistic — it's set up to exercise the clamp * logic in both dev and build. In practice, users might tune * `experimental.useCacheTimeout` up (e.g. for slower dev-time backends) or * down (e.g. for faster feedback while iterating); what's unusual here is * the very low `staticPageGenerationTim...
eeps 17s (above 15s). * * This way: * - Dev `/below-dev-timeout` succeeds (proves no clamp; if we clamped, it * would time out at 9s < 11s). * - Dev `/above-dev-timeout` times out at 15s (proves the configured dev * value is actually appl
would be clamped to 9s if we clamped in * dev. We don't, so the raw 15s applies. * - Build `useCacheTimeout: 60` → clamped to 9s. * - `/below-dev-timeout` sleeps 11s (between 9s and 15s). * - `/above-dev-timeout` sl
{ "filepath": "test/e2e/app-dir/use-cache-configured-timeout/next.config.js", "language": "javascript", "file_size": 1482, "cut_index": 524, "middle_length": 229 }
ripAnsi from 'strip-ansi' const expectedTimeoutErrorMessage = 'Filling a cache during prerender timed out, likely because request-specific arguments such as params, searchParams, cookies() or dynamic data were used inside "use cache".' describe('use-cache-configured-timeout', () => { const { next, isNextDev, skip...
h const browser = await next.browser('/below-dev-timeout') await expect(browser.elementByCss('#result').text()).resolves.toBe( 'cached' ) const cliOutput = stripAnsi(next.cliOutput.slice(outputIndex)) ex
ibe('when a "use cache" fill is below the configured dev `useCacheTimeout`', () => { it('should not clamp the dev timeout and allow the cache fill to complete', async () => { const outputIndex = next.cliOutput.lengt
{ "filepath": "test/e2e/app-dir/use-cache-configured-timeout/use-cache-configured-timeout.test.ts", "language": "typescript", "file_size": 2992, "cut_index": 563, "middle_length": 229 }
: any) { let result = '' onData = onData || (() => {}) for await (const chunk of response.body) { result += chunk.toString() onData(chunk.toString(), result) } return result } describe('use-server-inserted-html', () => { const { next } = nextTestSetup({ files: __dirname, dependencies: { ...
x expect(head).toMatch(/{color:(\s*)purple;?}/) // styled-jsx/style expect(head).toMatch(/{color:(\s*)(?:hotpink|#ff69b4);?}/) // styled-jsx/css // from styled-components expect(head).toMatch(/{color:(\s*)(?:blue|#00f);?}/) }) it('sh
'server-only': 'latest', }, }) it('should render initial styles of css-in-js in nodejs SSR correctly', async () => { const $ = await next.render$('/css-in-js') const head = $('head').html() // from styled-js
{ "filepath": "test/e2e/app-dir/use-server-inserted-html/use-server-inserted-html.test.ts", "language": "typescript", "file_size": 3337, "cut_index": 614, "middle_length": 229 }
import React from 'react' import { StyleRegistry, createStyleRegistry } from 'styled-jsx' import { ServerStyleSheet, StyleSheetManager } from 'styled-components' import { useServerInsertedHTML } from 'next/navigation' import { useState } from 'react' export default function RootStyleRegistry({ children }) { const ...
nstance.clearTag() return <>{styles}</> } // Allow multiple useServerInsertedHTML useServerInsertedHTML(() => { return <>{styledJsxFlushEffect()}</> }) useServerInsertedHTML(() => { return <>{styledComponentsFlushEffect()}</> })
= jsxStyleRegistry.styles() jsxStyleRegistry.flush() return <>{styles}</> } const styledComponentsFlushEffect = () => { const styles = styledComponentsStyleSheet.getStyleElement() styledComponentsStyleSheet.i
{ "filepath": "test/e2e/app-dir/use-server-inserted-html/app/root-style-registry.js", "language": "javascript", "file_size": 1297, "cut_index": 524, "middle_length": 229 }
import { Suspense } from 'react' import styled from 'styled-components' export function createDataFetcher(data, { timeout = 0, expire = 10 }) { let result let promise return function Data() { if (result) return result if (!promise) promise = new Promise((resolve) => { setTimeout(() => { ...
pire: 4000, }) function SuspenseyFooter() { readData() // generate large chunk of text to let the suspensey styling be inserted before the suspense script return ( <FootInner id="footer-inner"> {'(generate-large-footer-text)'.repeat(30)}
ow promise } } const Footer = styled.div` border: 1px solid orange; color: blue; ` const FootInner = styled.span` padding: 2px; color: orange; ` const readData = createDataFetcher('streaming', { timeout: 4000, ex
{ "filepath": "test/e2e/app-dir/use-server-inserted-html/app/css-in-js/suspense/page.js", "language": "javascript", "file_size": 1314, "cut_index": 524, "middle_length": 229 }
t } from 'next/server' // We use this in combination with fallback rewrites to redirect all /:teamSlug URLs to /app-future/[locale]/:teamSlug // in order to avoid having to grab all existing pages at build and checking the path in middleware export async function GET( request: NextRequest, { params, }: { ...
cookie: request.headers.get('cookie') ?? '', }), }).then(async (res) => { const resHeaders = new Headers(res.headers) resHeaders.delete('content-encoding') return new Response(res.body, { status: res.status, headers: resHeaders }) })
Headers({
{ "filepath": "test/e2e/app-dir/front-redirect-issue/app/api/app-redirect/[path]/route.ts", "language": "typescript", "file_size": 808, "cut_index": 536, "middle_length": 14 }
tDev } from 'e2e-utils' import { waitForRedbox, getRedboxSource, retry } from 'next-test-utils' import * as Log from './utils/log' // using after is a compile-time error in build mode. const _describe = isNextDev ? describe : describe.skip _describe('after() - pages', () => { const { next } = nextTestSetup({ fi...
redirect: 'follow', headers: { cookie: 'testCookie=testValue', }, } ) expect(res.status).toBe(200) await retry(() => { expect(getLogs()).toContainEqual({ source: '[middleware] /middleware/redirec
Output.slice(currentCliOutputIndex)) } it('runs in middleware', async () => { const requestId = `${Date.now()}` const res = await next.fetch( `/middleware/redirect-source?requestId=${requestId}`, {
{ "filepath": "test/e2e/app-dir/next-after-pages/index.test.ts", "language": "typescript", "file_size": 2087, "cut_index": 563, "middle_length": 229 }
getRedboxSource } from 'next-test-utils' describe('CSS Import from node_modules', () => { const { next, skipped, isTurbopack, isRspack } = nextTestSetup({ files: __dirname, skipStart: isNextStart, skipDeployment: true, dependencies: { sass: '1.54.0' }, }) if (skipped) { return } if (isN...
(/Build failed|Build error occurred/) }) } else { it('should show a build error', async () => { const browser = await next.browser('/') await waitForRedbox(browser) const errorSource = await getRedboxSource(browser) if (
tput).toMatch( /RspackResolver\(NotFound\(\\?"nprogress\/nprogress.css\\?"\)\)/ ) } else { expect(cliOutput).toMatch(/Can't resolve '[^']*?nprogress[^']*?'/) } expect(cliOutput).toMatch
{ "filepath": "test/e2e/app-dir/scss/npm-import-bad/npm-import-bad.test.ts", "language": "typescript", "file_size": 3101, "cut_index": 614, "middle_length": 229 }
tTestSetup } from 'e2e-utils' import { colorToRgb } from 'next-test-utils' describe.each([ { dependencies: { sass: '1.54.0' }, nextConfig: undefined }, { dependencies: { 'sass-embedded': '1.75.0' }, nextConfig: { sassOptions: { implementation: 'sass-embedded', }, }, }, ])( 'Nest...
const browser = await next.browser('/') expect( await browser.elementByCss('.red-text').getComputedCss('color') ).toBe(colorToRgb('red')) expect( await browser.elementByCss('.blue-text').getComputedCss('color') ).toB
it('should render the page', async () => {
{ "filepath": "test/e2e/app-dir/scss/nested-global/nested-global.test.ts", "language": "typescript", "file_size": 890, "cut_index": 547, "middle_length": 52 }
v jest */ import { nextTestSetup } from 'e2e-utils' import { colorToRgb } from 'next-test-utils' describe.each([ { dependencies: { sass: '1.54.0' }, nextConfig: undefined }, { dependencies: { 'sass-embedded': '1.75.0' }, nextConfig: { sassOptions: { implementation: 'sass-embedded', }, ...
Css('background-color') ).toBe(colorToRgb('blue')) // Baz expect( await browser .elementByCss('#verify-div .baz') .getComputedCss('background-color') ).toBe(colorToRgb('blue')) // Lol expect
extConfig, }) it('should render the module', async () => { const browser = await next.browser('/') // Bar expect( await browser .elementByCss('#verify-div .bar') .getComputed
{ "filepath": "test/e2e/app-dir/scss/3rd-party-module/3rd-party-module.test.ts", "language": "typescript", "file_size": 1342, "cut_index": 524, "middle_length": 229 }
v jest */ import { nextTestSetup } from 'e2e-utils' import { colorToRgb } from 'next-test-utils' describe.each([ { dependencies: { sass: '1.54.0' }, nextConfig: undefined }, { dependencies: { 'sass-embedded': '1.75.0' }, nextConfig: { sassOptions: { implementation: 'sass-embedded', }, ...
ies, nextConfig, }) it('should render the module', async () => { const browser = await next.browser('/') expect( await browser.elementByCss('.red-text').getComputedCss('color') ).toBe(colorToRgb('red')) }) } )
dependenc
{ "filepath": "test/e2e/app-dir/scss/loader-order/loader-order.test.ts", "language": "typescript", "file_size": 794, "cut_index": 524, "middle_length": 14 }
tTestSetup } from 'e2e-utils' import { colorToRgb } from 'next-test-utils' describe.each([ { dependencies: { sass: '1.54.0' }, nextConfig: undefined }, { dependencies: { 'sass-embedded': '1.75.0' }, nextConfig: { sassOptions: { implementation: 'sass-embedded', }, }, }, ])( 'SCSS...
{ const browser = await next.browser('/') const redText = await browser.elementByCss('.red-text') expect(await redText.getComputedCss('color')).toBe(colorToRgb('red')) expect(await redText.getComputedCss('background-image')).toMatc
}) it('should render the module', async () =>
{ "filepath": "test/e2e/app-dir/scss/data-url/data-url.test.ts", "language": "typescript", "file_size": 910, "cut_index": 547, "middle_length": 52 }
* eslint-env jest */ import { nextTestSetup } from 'e2e-utils' import { colorToRgb } from 'next-test-utils' describe.each([ { dependencies: { sass: '1.54.0' }, nextConfig: undefined }, { dependencies: { 'sass-embedded': '1.75.0' }, nextConfig: { sassOptions: { implementation: 'sass-embedded'...
ig, }) it('should have the correct color (css ordering)', async () => { const browser = await next.browser('/') expect( await browser.elementByCss('.my-text').getComputedCss('color') ).toBe(colorToRgb('green')) }) }
nextConf
{ "filepath": "test/e2e/app-dir/scss/with-styled-jsx/with-styled-jsx.test.ts", "language": "typescript", "file_size": 786, "cut_index": 513, "middle_length": 14 }
port { nextTestSetup } from 'e2e-utils' import { colorToRgb, getUrlFromBackgroundImage } from 'next-test-utils' // TODO: Skipped as this test should set up the server to handle assetPrefix which it currently does not do. describe.skip('SCSS Support loader handling', () => { describe.each([ { dependencies: { sass...
extConfig, }) it('should render the page', async () => { const browser = await next.browser('/') expect( await browser.elementByCss('.red-text').getComputedCss('color') ).toBe(colorToRgb('red')) const
}, }, ])( 'CSS URL via `file-loader` and asset prefix (2) ($dependencies)', ({ dependencies, nextConfig }) => { const { next } = nextTestSetup({ files: __dirname, dependencies, n
{ "filepath": "test/e2e/app-dir/scss/url-global-asset-prefix-2/url-global-asset-prefix-2.test.ts", "language": "typescript", "file_size": 1567, "cut_index": 537, "middle_length": 229 }
port { nextTestSetup } from 'e2e-utils' describe.each([ { dependencies: { sass: '1.54.0' }, nextConfig: undefined }, { dependencies: { 'sass-embedded': '1.75.0' }, nextConfig: { sassOptions: { implementation: 'sass-embedded', }, }, }, ])('unused scss', ({ dependencies, nextConfig ...
wser.eval( `window.getComputedStyle(document.querySelector('body')).display` ) expect(currentDisplay).toBe('block') }) }) }) describe('Body is not hidden when broken in Development', () => { const { next, isNext
xtConfig, }) ;(isNextDev ? describe : describe.skip)('development only', () => { it('should have body visible', async () => { const browser = await next.browser('/') const currentDisplay = await bro
{ "filepath": "test/e2e/app-dir/scss/unused/unused.test.ts", "language": "typescript", "file_size": 1622, "cut_index": 537, "middle_length": 229 }
nv jest */ import { nextTestSetup } from 'e2e-utils' describe.each([ { dependencies: { sass: '1.54.0' }, nextConfig: undefined }, { dependencies: { 'sass-embedded': '1.75.0' }, nextConfig: { sassOptions: { implementation: 'sass-embedded', }, }, }, ])( 'Good CSS Import from node...
should render the page', async () => { const browser = await next.browser('/') expect( await browser .elementByCss('#nprogress .bar') .getComputedCss('background-color') ).toBe('rgb(34, 153, 221)') }) } )
'0.2.0', }, nextConfig, }) it('
{ "filepath": "test/e2e/app-dir/scss/npm-import/npm-import.test.ts", "language": "typescript", "file_size": 832, "cut_index": 523, "middle_length": 52 }
/* eslint-env jest */ import { nextTestSetup } from 'e2e-utils' import { colorToRgb } from 'next-test-utils' describe.each([ { dependencies: { sass: '1.54.0' }, nextConfig: undefined }, { dependencies: { 'sass-embedded': '1.75.0' }, nextConfig: { sassOptions: { implementation: 'sass-embedded...
ndencies, nextConfig, }) it('should render the page', async () => { const browser = await next.browser('/') expect( await browser.elementByCss('#nm-div').getComputedCss('color') ).toBe(colorToRgb('red')) }) }
me, depe
{ "filepath": "test/e2e/app-dir/scss/nm-module/nm-module.test.ts", "language": "typescript", "file_size": 784, "cut_index": 512, "middle_length": 14 }
ext-test-utils' describe.each([ { dependencies: { sass: '1.54.0' }, nextConfig: undefined }, { dependencies: { 'sass-embedded': '1.75.0' }, nextConfig: { sassOptions: { implementation: 'sass-embedded', }, }, }, ])( 'CSS Module Composes Usage (Basic) ($dependencies)', ({ depend...
await browser.elementByCss('#verify-yellow').getComputedCss('color') ).toBe(colorToRgb('yellow')) expect( await browser .elementByCss('#verify-yellow') .getComputedCss('background-color') ).toBe(colorToR
st browser = await next.browser('/') expect(
{ "filepath": "test/e2e/app-dir/scss/composes-basic/composes-basic.test.ts", "language": "typescript", "file_size": 939, "cut_index": 606, "middle_length": 52 }
int-env jest */ import { nextTestSetup } from 'e2e-utils' import { colorToRgb } from 'next-test-utils' describe.each([ { dependencies: { sass: '1.54.0' }, nextConfig: undefined }, { dependencies: { 'sass-embedded': '1.75.0' }, nextConfig: { sassOptions: { implementation: 'sass-embedded', ...
).toBe(colorToRgb('red')) expect( await browser.elementByCss('#other3').getComputedCss('color') ).toBe(colorToRgb('black')) expect( await browser.elementByCss('#subclass').getComputedCss('color') ).toBe(colorToR
ame, dependencies, nextConfig, }) it('should render the page', async () => { const browser = await next.browser('/') expect( await browser.elementByCss('#other2').getComputedCss('color')
{ "filepath": "test/e2e/app-dir/scss/nm-module-nested/nm-module-nested.test.ts", "language": "typescript", "file_size": 1182, "cut_index": 518, "middle_length": 229 }
tTestSetup } from 'e2e-utils' import { colorToRgb } from 'next-test-utils' describe.each([ { dependencies: { sass: '1.54.0' }, nextConfig: undefined }, { dependencies: { 'sass-embedded': '1.75.0' }, nextConfig: { sassOptions: { implementation: 'sass-embedded', }, }, }, ])( 'Good...
{ const browser = await next.browser('/') expect( await browser.elementByCss('.red-text').getComputedCss('color') ).toBe(colorToRgb('red')) expect( await browser.elementByCss('.blue-text').getComputedCss('color')
}) it('should render the page', async () =>
{ "filepath": "test/e2e/app-dir/scss/npm-import-nested/npm-import-nested.test.ts", "language": "typescript", "file_size": 899, "cut_index": 547, "middle_length": 52 }
v jest */ import { nextTestSetup } from 'e2e-utils' import { colorToRgb, getUrlFromBackgroundImage } from 'next-test-utils' describe.each([ { dependencies: { sass: '1.54.0' }, nextConfig: undefined }, { dependencies: { 'sass-embedded': '1.75.0' }, nextConfig: { sassOptions: { implementation:...
await browser.elementByCss('.red-text').getComputedCss('color') ).toBe(colorToRgb('red')) const background = await browser .elementByCss('.red-text') .getComputedCss('background-image') expect(background).toMatc
{ next } = nextTestSetup({ files: __dirname, dependencies, nextConfig, }) it('should render the page', async () => { const browser = await next.browser('/') expect(
{ "filepath": "test/e2e/app-dir/scss/url-global/url-global.test.ts", "language": "typescript", "file_size": 1400, "cut_index": 524, "middle_length": 229 }
port { isNextStart, nextTestSetup } from 'e2e-utils' import { waitForRedbox, getRedboxSource } from 'next-test-utils' // Importing module CSS in _document is allowed in Turbopack ;(process.env.IS_TURBOPACK_TEST ? describe.skip : describe)( 'Invalid SCSS in _document', () => { const { next, skipped, isRspack } ...
ect(cliOutput).toContain('styles.module.scss') expect(cliOutput).toMatch( /CSS.*cannot.*be imported within.*pages[\\/]_document\.js/ ) // Skip: Rspack loaders cannot access module issuer info for location details i
f (isNextStart) { it('should fail to build', async () => { const { exitCode, cliOutput } = await next.build() expect(exitCode).not.toBe(0) expect(cliOutput).toContain('Failed to compile') exp
{ "filepath": "test/e2e/app-dir/scss/invalid-module-document/invalid-module-document.test.ts", "language": "typescript", "file_size": 1887, "cut_index": 537, "middle_length": 229 }
Invalid CSS Global Module Usage in node_modules', () => { ;(isNextStart ? describe : describe.skip)('production only', () => { const { next } = nextTestSetup({ files: __dirname, skipStart: true, }) it('should fail to build', async () => { const { exitCode, cliOutput } = await next.build...
hin.*node_modules/ ) // Skip: Rspack loaders cannot access module issuer info for location details if (!process.env.NEXT_RSPACK) { expect(cliOutput).toMatch( /Location:.*node_modules[\\/]example[\\/]index\.mjs/ )
h( /Global CSS.*cannot.*be imported from wit
{ "filepath": "test/e2e/app-dir/scss/invalid-global-module/invalid-global-module.test.ts", "language": "typescript", "file_size": 938, "cut_index": 606, "middle_length": 52 }
stSetup } from 'e2e-utils' import { waitForRedbox, getRedboxSource } from 'next-test-utils' describe('Invalid Global CSS', () => { const { next, skipped, isTurbopack, isRspack } = nextTestSetup({ files: __dirname, skipStart: isNextStart, skipDeployment: true, dependencies: { sass: '1.54.0' }, }) ...
orts.*?pages(\/|\\)_app/ ) // Skip: Rspack loaders cannot access module issuer info for location details if (!process.env.NEXT_RSPACK) { expect(cliOutput).toMatch(/Location:.*pages[\\/]index\.js/) } }) } else { it(
if (!isTurbopack) { expect(cliOutput).toContain('Failed to compile') } expect(cliOutput).toContain('styles/global.scss') expect(cliOutput).toMatch( /Please move all first-party global CSS imp
{ "filepath": "test/e2e/app-dir/scss/invalid-global/invalid-global.test.ts", "language": "typescript", "file_size": 2728, "cut_index": 563, "middle_length": 229 }
v jest */ import { nextTestSetup } from 'e2e-utils' import { colorToRgb, getUrlFromBackgroundImage } from 'next-test-utils' describe('SCSS Support loader handling', () => { describe.each([ { dependencies: { sass: '1.54.0' }, nextConfig: undefined }, { dependencies: { 'sass-embedded': '1.75.0' }, ...
r('/') expect( await browser.elementByCss('.red-text').getComputedCss('color') ).toBe(colorToRgb('red')) const background = await browser .elementByCss('.red-text') .getComputedCss('background-image')
s, nextConfig }) => { const { next } = nextTestSetup({ files: __dirname, dependencies, nextConfig, }) it('should render the page', async () => { const browser = await next.browse
{ "filepath": "test/e2e/app-dir/scss/url-global-partial/url-global-partial.test.ts", "language": "typescript", "file_size": 1434, "cut_index": 524, "middle_length": 229 }
t */ import { nextTestSetup } from 'e2e-utils' import { colorToRgb } from 'next-test-utils' const sassOptions = { loadPaths: ['./styles'], } describe.each([ { dependencies: { sass: '1.54.0' }, nextConfig: { sassOptions } }, { dependencies: { 'sass-embedded': '1.75.0' }, nextConfig: { sassOptions: ...
e, dependencies, nextConfig, }) it('should render the module', async () => { const browser = await next.browser('/') expect( await browser.elementByCss('#verify-red').getComputedCss('color') ).toBe(colorToRgb(
nst { next } = nextTestSetup({ files: __dirnam
{ "filepath": "test/e2e/app-dir/scss/basic-module-include-paths/basic-module-include-paths.test.ts", "language": "typescript", "file_size": 858, "cut_index": 529, "middle_length": 52 }
m 'e2e-utils' import { colorToRgb, retry } from 'next-test-utils' describe.each([ { dependencies: { sass: '1.54.0' }, nextConfig: undefined }, { dependencies: { 'sass-embedded': '1.75.0' }, nextConfig: { sassOptions: { implementation: 'sass-embedded', }, }, }, ])('SCSS Support ($d...
(colorToRgb('blue')) }) }) if (isNextDev) { describe('Can hot reload CSS without losing state', () => { it('should update CSS color without remounting <input>', async () => { const browser = await next.browser('/page1')
yles in Production', () => { it('should have CSS for page', async () => { const browser = await next.browser('/page2') expect( await browser.elementByCss('.blue-text').getComputedCss('color') ).toBe
{ "filepath": "test/e2e/app-dir/scss/multi-page/multi-page.test.ts", "language": "typescript", "file_size": 2159, "cut_index": 563, "middle_length": 229 }
from 'e2e-utils' import { colorToRgb } from 'next-test-utils' const sassOptions = { additionalData: ` $var: red; `, } describe.each([ { dependencies: { sass: '1.54.0' }, nextConfig: { sassOptions } }, { dependencies: { 'sass-embedded': '1.75.0' }, nextConfig: { sassOptions: { ...sas...
dencies, nextConfig, }) it('should render the module', async () => { const browser = await next.browser('/') expect( await browser.elementByCss('#verify-red').getComputedCss('color') ).toBe(colorToRgb('red')) })
nextTestSetup({ files: __dirname, depen
{ "filepath": "test/e2e/app-dir/scss/basic-module-additional-data/basic-module-additional-data.test.ts", "language": "typescript", "file_size": 874, "cut_index": 559, "middle_length": 52 }
nst path = require('path') module.exports = async function (content) { let dir = path.dirname(this.resourcePath) let read1 = await new Promise((res, rej) => this.fs.readFile(path.join(dir, 'test.txt'), (err, data) => { if (err) return rej(err) res(data) }) ) let read2 = await new Promise((...
dFile(path.join(dir, 'test.mp4'), (err, data) => { if (err) return rej(err) res(data) }) ) return `module.exports = "Buffer read: ${read1 instanceof Buffer ? read1.length : 0}, string read: '${read2.trim()}', binary read: ${read3.length
this.fs.rea
{ "filepath": "test/e2e/app-dir/webpack-loader-fs/test-file-loader.js", "language": "javascript", "file_size": 790, "cut_index": 514, "middle_length": 14 }
and over again' foo = 'This is the other repeating string. It should be about the same length' foo = 'I should just alternately repeat this and another string over and over again' foo = 'This is the other repeating string. It should be about the same length' foo = 'I should just...
over again' foo = 'This is the other repeating string. It should be about the same length' foo = 'I should just alternately repeat this and another string over and over again' foo = 'This is the other repeating string. It shou
tely repeat this and another string over and over again' foo = 'This is the other repeating string. It should be about the same length' foo = 'I should just alternately repeat this and another string over and
{ "filepath": "test/e2e/app-dir/chunk-loading/components/SuperShared.tsx", "language": "tsx", "file_size": 24368, "cut_index": 1331, "middle_length": 229 }
entsEnabled = process.env.__NEXT_CACHE_COMPONENTS === 'true' describe('app-dir trailingSlash handling', () => { const { next, isNextDev } = nextTestSetup({ files: __dirname, buildArgs: [ '--debug-build-paths', isCacheComponentsEnabled ? '!app/[lang]/legacy/page.js' : '!app/[lang]/...
o-a-trailing-slash').attr('href')).toBe('/a/') }) it('should contain trailing slash to canonical url', async () => { const $ = await next.render$('/') expect($(`link[rel="canonical"]`).attr('href')).toBe( 'http://trailingslash.com/'
pect(res.status).toBe(308) expect(new URL(res.headers.get('location'), next.url).pathname).toBe('/a/') }) it('should render link with trailing slash', async () => { const $ = await next.render$('/') expect($('#t
{ "filepath": "test/e2e/app-dir/trailingslash/trailingslash.test.ts", "language": "typescript", "file_size": 3752, "cut_index": 614, "middle_length": 229 }
from 'e2e-utils' import { waitForNoRedbox } from 'next-test-utils' describe('global-not-found - basic', () => { const { next, isNextDev } = nextTestSetup({ files: __dirname, }) it('should render global-not-found for 404', async () => { const browser = await next.browser('/does-not-exist') if (isNext...
next.render$('/does-not-exist') const errorTitle = $('#global-error-title').text() expect(errorTitle).toBe('global-not-found') const notFoundHtmlProp = $('html').attr('data-global-not-found') expect(notFoundHtmlProp).toBe('true') }) it
FoundHtmlProp = await browser .elementByCss('html') .getAttribute('data-global-not-found') expect(notFoundHtmlProp).toBe('true') }) it('should ssr global-not-found for 404', async () => { const $ = await
{ "filepath": "test/e2e/app-dir/global-not-found/basic/global-not-found-basic.test.ts", "language": "typescript", "file_size": 1592, "cut_index": 537, "middle_length": 229 }
mport { nextTestSetup } from 'e2e-utils' import { waitForNoRedbox } from 'next-test-utils' describe('global-not-found - no-root-layout', () => { const { next, isNextDev } = nextTestSetup({ files: __dirname, }) it('should render global-not-found for 404', async () => { const browser = await next.browser(...
sync () => { const $ = await next.render$('/does-not-exist') const errorTitle = $('#global-error-title').text() expect(errorTitle).toBe('global-not-found') const notFoundHtmlProp = $('html').attr('data-global-not-found') expect(notFound
'global-not-found') const notFoundHtmlProp = await browser .elementByCss('html') .getAttribute('data-global-not-found') expect(notFoundHtmlProp).toBe('true') }) it('should ssr global-not-found for 404', a
{ "filepath": "test/e2e/app-dir/global-not-found/no-root-layout/no-root-layout.test.ts", "language": "typescript", "file_size": 1029, "cut_index": 513, "middle_length": 229 }
mport { nextTestSetup } from 'e2e-utils' describe('global-not-found - both-present', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should render global-not-found for 404 routes', async () => { const $ = await next.render$('/does-not-exist') expect($('html').attr('data-global-not-...
ng notFound() in a page', async () => { const browser = await next.browser('/call-not-found') expect(await browser.elementByCss('#not-found-boundary').text()).toBe( 'not-found.js' ) expect( await browser.elementByCss('html').get
obal-error-title').text()).toBe( 'global-not-found' ) expect( await browser.elementByCss('html').getAttribute('data-global-not-found') ).toBe('true') }) it('should render not-found boundary when calli
{ "filepath": "test/e2e/app-dir/global-not-found/both-present/both-present.test.ts", "language": "typescript", "file_size": 1058, "cut_index": 513, "middle_length": 229 }
{ nextTestSetup } from 'e2e-utils' describe(`mdx`, () => { const { next } = nextTestSetup({ files: __dirname, dependencies: { '@next/mdx': 'canary', '@mdx-js/loader': '^2.2.1', }, }) describe('app directory', () => { it('should work in initial html', async () => { const $ = aw...
ponents', async () => { const $ = await next.render$('/') expect($('h2').text()).toBe('This is a client component') }) }) describe('pages directory', () => { it('should work in initial html', async () => { const $ = await nex
owser = await next.browser('/') expect(await browser.elementByCss('h1').text()).toBe('Hello World') expect(await browser.elementByCss('p').text()).toBe('This is MDX!') }) it('should allow importing client com
{ "filepath": "test/e2e/app-dir/mdx-no-mdx-components/mdx.test.ts", "language": "typescript", "file_size": 1136, "cut_index": 518, "middle_length": 229 }
import { nextTestSetup } from 'e2e-utils' import { retry } from 'next-test-utils' describe('global-not-found - cache-components', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should render global-not-found for 404 routes', async () => { await next.fetch('/does-not-exist') expect...
=> { expect(await browser.elementByCss('h1').text()).toBe('Global Not Found') }) expect(next.cliOutput).not.toContain( 'did not produce a static shell and Next.js was unable to determine a reason. This is a bug in Next.js' ) }) }
when calling notFound() in a page', async () => { const browser = await next.browser('/action') // submit form with #not-found-btn button await browser.elementByCss('#not-found-btn').click() await retry(async ()
{ "filepath": "test/e2e/app-dir/global-not-found/cache-components/cache-components.test.ts", "language": "typescript", "file_size": 999, "cut_index": 512, "middle_length": 229 }
to work locally you need to use `pnpm next-with-deps dev|build` // Make sure you delete node_modules if you are editing the package otherwise it won't // reinstall and reflect your changes. import ExportsDefault from 'my-external-esm-package/exports' import * as ExportsNamed from 'my-external-esm-package/exports' imp...
external-esm-package/imports').then( (mod) => JSON.stringify(mod) ) export default function Client() { return ( <section> <h2>Client</h2> <section> <h3>Exports</h3> <section> <h4>Static</h4> <label>D
s' import { named as namedImports } from 'my-external-esm-package/imports' const pendingDynamicExports = import('my-external-esm-package/exports').then( (mod) => JSON.stringify(mod) ) const pendingDynamicImports = import('my-
{ "filepath": "test/e2e/app-dir/next-condition/fixtures/render/app/external-esm/client.tsx", "language": "tsx", "file_size": 1920, "cut_index": 537, "middle_length": 229 }
ext-with-deps dev|build` // Make sure you delete node_modules if you are editing the package otherwise it won't // reinstall and reflect your changes. import ExportsDefault from 'my-external-esm-package/exports' import * as ExportsNamed from 'my-external-esm-package/exports' import { named as namedExports } from 'my-e...
mod) => JSON.stringify(mod) ) import Client from './client' export default function Page() { return ( <> <section> <h2>Server</h2> <section> <h3>Exports</h3> <section> <h4>Static</h4>
'my-external-esm-package/imports' const pendingDynamicExports = import('my-external-esm-package/exports').then( (mod) => JSON.stringify(mod) ) const pendingDynamicImports = import('my-external-esm-package/imports').then( (
{ "filepath": "test/e2e/app-dir/next-condition/fixtures/render/app/external-esm/page.tsx", "language": "tsx", "file_size": 2037, "cut_index": 563, "middle_length": 229 }
ly you need to use `pnpm next-with-deps dev|build` // Make sure you delete node_modules if you are editing the package otherwise it won't // reinstall and reflect your changes. import ExportsDefault from 'my-cjs-package/exports' import * as ExportsNamed from 'my-cjs-package/exports' import { named as namedExports } fr...
m './client' export default function Page() { return ( <> <section> <h2>Server</h2> <section> <h3>Exports</h3> <section> <h4>Static</h4> <label>Default:</label> <div>{JSON
ports' const pendingDynamicExports = import('my-cjs-package/exports').then((mod) => JSON.stringify(mod) ) const pendingDynamicImports = import('my-cjs-package/imports').then((mod) => JSON.stringify(mod) ) import Client fro
{ "filepath": "test/e2e/app-dir/next-condition/fixtures/render/app/cjs/page.tsx", "language": "tsx", "file_size": 1963, "cut_index": 537, "middle_length": 229 }
to work locally you need to use `pnpm next-with-deps dev|build` // Make sure you delete node_modules if you are editing the package otherwise it won't // reinstall and reflect your changes. import ExportsDefault from 'my-external-cjs-package/exports' import * as ExportsNamed from 'my-external-cjs-package/exports' imp...
external-cjs-package/imports').then( (mod) => JSON.stringify(mod) ) export default function Client() { return ( <section> <h2>Client</h2> <section> <h3>Exports</h3> <section> <h4>Static</h4> <label>D
s' import { named as namedImports } from 'my-external-cjs-package/imports' const pendingDynamicExports = import('my-external-cjs-package/exports').then( (mod) => JSON.stringify(mod) ) const pendingDynamicImports = import('my-
{ "filepath": "test/e2e/app-dir/next-condition/fixtures/render/app/external-cjs/client.tsx", "language": "tsx", "file_size": 1920, "cut_index": 537, "middle_length": 229 }
etup({ files: __dirname, }) async function setup(initialPath: string) { let page: Playwright.Page const browser = await next.browser(initialPath, { beforePageLoad(p: Playwright.Page) { page = p }, }) const act = createRouterAct(page!) return { browser, act } } it('p...
ntByCss('[data-testid="pathname"]').text()).toBe( '/x/1' ) expect( await browser.elementByCss('[data-testid="leaf-input"]').getValue() ).toBe('hello') }) it('resets leaf form state when re-entering a route via fresh push', asyn
await act(async () => { await browser.elementByCss('input[data-link-accordion="/x/2"]').click() await browser.elementByCss('a[href="/x/2"]').click() }) await browser.back() expect(await browser.eleme
{ "filepath": "test/e2e/app-dir/use-router-bfcache-id/use-router-bfcache-id.test.ts", "language": "typescript", "file_size": 5725, "cut_index": 716, "middle_length": 229 }
import { retry } from 'next-test-utils' import { join } from 'path' describe('interception-route-prefetch-cache', () => { function runTests({ next }: ReturnType<typeof nextTestSetup>) { it('should render the correct interception when two distinct layouts share the same path structure', async () => { const ...
expect(await browser.elementById('children').text()).toMatch(/Foo Page/) // Verify we got the right interception expect(await browser.elementById('slot').text()).toMatch( /Intercepted on Foo Page/ ) }) // Go
ser.elementById('children').text()).toMatch(/Foo Page/) }) await browser.elementByCss('[href="/post/1"]').click() await retry(async () => { // Ensure the existing page content is still the same
{ "filepath": "test/e2e/app-dir/interception-route-prefetch-cache/interception-route-prefetch-cache.test.ts", "language": "typescript", "file_size": 2341, "cut_index": 563, "middle_length": 229 }
describe('PPR - partial hydration', () => { const { next, isNextDev, skipped } = nextTestSetup({ files: __dirname, // the file-patching strategy we use for synchronizing the test doesn't work // on deployments skipDeployment: true, }) if (isNextDev || skipped) { it.skip('only testable in pr...
ompleteness. description: 'Static shell, streaming metadata', path: '/with-shell/with-streaming-metadata', }, { description: 'No static shell, no streaming metadata', path: '/without-shell/without-metadata', }, {
// Streaming metadata shouldn't affect streaming order, because if we have a static shell, // then RSC scripts (and thus hydration) don't need to wait for any HTML to be rendered. // I'm including it here for c
{ "filepath": "test/e2e/app-dir/ppr-partial-hydration/ppr-partial-hydration.test.ts", "language": "typescript", "file_size": 5882, "cut_index": 716, "middle_length": 229 }
mport { Suspense } from 'react' import { connection } from 'next/server' import { HydrationIndicator } from '../../hydration-indicator' import waitForMarkerFile from '../../../waitForMarkerFile' import type { Metadata } from 'next' export async function generateMetadata(): Promise<Metadata> { await connection() re...
</main> ) } async function SlowServerComponent() { await connection() await waitForMarkerFile() const randomValue = Math.floor(Math.random() * 1000) return ( <div id="dynamic"> <div>{`Random value: ${randomValue}`}</div> <Hy
<p>Static shell</p> <HydrationIndicator id="shell-hydrated" /> <hr /> <Suspense fallback={<div id="dynamic-fallback">Loading...</div>}> <SlowServerComponent /> </Suspense> </div>
{ "filepath": "test/e2e/app-dir/ppr-partial-hydration/app/with-shell/with-streaming-metadata/page.tsx", "language": "tsx", "file_size": 1057, "cut_index": 513, "middle_length": 229 }
'next/link' export default async function Page(props: PageProps<'/loading-scroll'>) { const search = await props.searchParams const skipSleep = !!search.skipSleep if (!skipSleep) { await new Promise((resolve) => setTimeout(resolve, 5000)) } return ( <> {search.page ? <div id="current-page">{sea...
_, i) => ( <div key={i}>{i}</div> )) } <div id="pages"> {[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map((item) => ( <Link key={item} href={`?page=${item}&skipSleep=1`}> {item} </Link> ))}
t 500 elements Array.from({ length: 500 }, (
{ "filepath": "test/e2e/app-dir/router-autoscroll/app/loading-scroll/page.tsx", "language": "tsx", "file_size": 863, "cut_index": 529, "middle_length": 52 }
tTestSetup } from 'e2e-utils' const describeHeaded = process.env.HEADLESS ? describe.skip : describe describeHeaded('fetch-abort-on-refresh', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should not show abort error in global error boundary when restoring from bfcache', async () => { ...
ical waitUntil: 'load' option here as the event is never being triggered if we hit the bfcache await browser.back({ waitUntil: 'commit' }) // Check that we're back on the slow page (the page that was first redirected to, before the MPA, not the er
wait next.browser('/', { headless: false }) await browser.elementById('trigger-navigation').click() await browser.waitForElementByCss('#root-2') // Go back to trigger bfcache restoration // we overwrite the typ
{ "filepath": "test/e2e/app-dir/fetch-abort-on-refresh/fetch-abort-on-refresh.test.ts", "language": "typescript", "file_size": 1400, "cut_index": 524, "middle_length": 229 }
{ nextTestSetup } from 'e2e-utils' describe('global-not-found - metadata', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should render metadata of global-not-found for 404', async () => { // assert SSR metadata const $ = await next.render$('/does-not-exist') expect($('title'...
ser.elementByCss('meta[name="description"]') expect(await title.text()).toBe('global-not-found') expect(await description.getAttribute('content')).toBe( 'global-not-found description' ) // pick up static icon svg const icon = awai
rel="icon"]').attr('type')).toBe('image/svg+xml') // assert hydrated metadata const browser = await next.browser('/does-not-exist') const title = await browser.elementByCss('title') const description = await brow
{ "filepath": "test/e2e/app-dir/global-not-found/metadata/metadata.test.ts", "language": "typescript", "file_size": 1154, "cut_index": 518, "middle_length": 229 }
from 'e2e-utils' describe('edge runtime node compatibility', () => { const { next, isNextStart } = nextTestSetup({ files: __dirname, }) it('[app] supports node:buffer', async () => { const res = await next.fetch('/buffer', { method: 'POST', body: 'Hello, world!', }) const json = awai...
method: 'POST', body: 'Hello, world!', }) const json = await res.json() expect(json).toEqual({ 'B2.Buffer === B.Buffer': true, 'Buffer === B.Buffer': true, 'typeof B.Buffer': 'function', 'typeof B2.Buffer':
constants', 'kMaxLength', 'kStringMaxLength', 'Buffer', 'SlowBuffer', ]), }) }) it('[pages/api] supports node:buffer', async () => { const res = await next.fetch('/api/buffer', {
{ "filepath": "test/e2e/app-dir/edge-runtime-node-compatibility/edge-runtime-node-compatibility.test.ts", "language": "typescript", "file_size": 1548, "cut_index": 537, "middle_length": 229 }
to work locally you need to use `pnpm next-with-deps dev|build` // Make sure you delete node_modules if you are editing the package otherwise it won't // reinstall and reflect your changes. import ExportsDefault from 'my-esm-package/exports' import * as ExportsNamed from 'my-esm-package/exports' import { named as nam...
ort default function Client() { return ( <section> <h2>Client</h2> <section> <h3>Exports</h3> <section> <h4>Static</h4> <label>Default:</label> <div>{JSON.stringify(ExportsDefault)}</div>
esm-package/imports' const pendingDynamicExports = import('my-esm-package/exports').then((mod) => JSON.stringify(mod) ) const pendingDynamicImports = import('my-esm-package/imports').then((mod) => JSON.stringify(mod) ) exp
{ "filepath": "test/e2e/app-dir/next-condition/fixtures/render/app/esm/client.tsx", "language": "tsx", "file_size": 1846, "cut_index": 537, "middle_length": 229 }
to work locally you need to use `pnpm next-with-deps dev|build` // Make sure you delete node_modules if you are editing the package otherwise it won't // reinstall and reflect your changes. import ExportsDefault from 'my-cjs-package/exports' import * as ExportsNamed from 'my-cjs-package/exports' import { named as nam...
ort default function Client() { return ( <section> <h2>Client</h2> <section> <h3>Exports</h3> <section> <h4>Static</h4> <label>Default:</label> <div>{JSON.stringify(ExportsDefault)}</div>
cjs-package/imports' const pendingDynamicExports = import('my-cjs-package/exports').then((mod) => JSON.stringify(mod) ) const pendingDynamicImports = import('my-cjs-package/imports').then((mod) => JSON.stringify(mod) ) exp
{ "filepath": "test/e2e/app-dir/next-condition/fixtures/render/app/cjs/client.tsx", "language": "tsx", "file_size": 1846, "cut_index": 537, "middle_length": 229 }
eState } from 'react' import { useRouter, usePathname, useSearchParams } from 'next/navigation' import { LinkAccordion } from '../../../components/link-accordion' import { refreshAction } from '../../actions' export function DynamicRenderCounterClient({ uuid }: { uuid: string }) { // Counts how many times this compo...
return <p data-testid="dynamic-render-counter">dynamic renders: {count}</p> } export function LeafContent() { const router = useRouter() const pathname = usePathname() const searchParams = useSearchParams() const { bfcacheId } = router const
reated. Useful as a visual signal that the dynamic part re-ran. const [count, setCount] = useState(0) const [prevUuid, setPrevUuid] = useState(uuid) if (prevUuid !== uuid) { setPrevUuid(uuid) setCount(count + 1) }
{ "filepath": "test/e2e/app-dir/use-router-bfcache-id/app/[group]/[page]/leaf-content.tsx", "language": "tsx", "file_size": 1774, "cut_index": 537, "middle_length": 229 }
port { connection } from 'next/server' import { HydrationIndicator } from '../../hydration-indicator' import waitForMarkerFile from '../../../waitForMarkerFile' export default function Page() { return ( <main id="shell"> <h1>This is a page with static shell + no streaming metadata</h1> <div> ...
async function SlowServerComponent() { await connection() await waitForMarkerFile() const randomValue = Math.floor(Math.random() * 1000) return ( <div id="dynamic"> <div>{`Random value: ${randomValue}`}</div> <HydrationIndicator i
> </Suspense> </div> </main> ) }
{ "filepath": "test/e2e/app-dir/ppr-partial-hydration/app/with-shell/without-metadata/page.tsx", "language": "tsx", "file_size": 896, "cut_index": 547, "middle_length": 52 }
files: __dirname + '/fixtures/random/cache-components', skipDeployment: true, }) if (skipped) { return } it('should not error when accessing middlware that use Math.random()', async () => { let res: Awaited<ReturnType<typeof next.fetch>>, $: Awaited<ReturnTyp...
expect(res.status).toBe(200) $ = await next.render$('/app/prerendered/unstable-cache') expect($('li').length).toBe(2) res = await next.fetch('/app/prerendered/use-cache') expect(res.status).toBe(200) $ = await nex
text()).toBe('rewritten') }) it('should not error when accessing pages that use Math.random() in App Router', async () => { let res, $ res = await next.fetch('/app/prerendered/unstable-cache')
{ "filepath": "test/e2e/app-dir/node-extensions/node-extensions.random.test.ts", "language": "typescript", "file_size": 8865, "cut_index": 716, "middle_length": 229 }
fault Export","named":"EXPORTS NEXT SERVER - Named Export"},"named":"EXPORTS NEXT SERVER - Named Export"} named: "EXPORTS NEXT SERVER - Named Export" Dynamic {"default":{"default":"EXPORTS NEXT SERVER - Default Export","named":"EXPORTS NEXT SERVER - Na...
RVER - Named Export"} named: "IMPORTS NEXT SERVER - Named Export" Dynamic {"default":{"default":"IMPORTS NEXT SERVER - Default Export","named":"IMPORTS NEXT SERVER - Named Export"},"named"
xport","named":"IMPORTS NEXT SERVER - Named Export"} Namespace: {"default":{"default":"IMPORTS NEXT SERVER - Default Export","named":"IMPORTS NEXT SERVER - Named Export"},"named":"IMPORTS NEXT SE
{ "filepath": "test/e2e/app-dir/next-condition/next-condition.test.ts", "language": "typescript", "file_size": 40260, "cut_index": 2151, "middle_length": 229 }
ext-with-deps dev|build` // Make sure you delete node_modules if you are editing the package otherwise it won't // reinstall and reflect your changes. import ExportsDefault from 'my-external-cjs-package/exports' import * as ExportsNamed from 'my-external-cjs-package/exports' import { named as namedExports } from 'my-e...
mod) => JSON.stringify(mod) ) import Client from './client' export default function Page() { return ( <> <section> <h2>Server</h2> <section> <h3>Exports</h3> <section> <h4>Static</h4>
'my-external-cjs-package/imports' const pendingDynamicExports = import('my-external-cjs-package/exports').then( (mod) => JSON.stringify(mod) ) const pendingDynamicImports = import('my-external-cjs-package/imports').then( (
{ "filepath": "test/e2e/app-dir/next-condition/fixtures/render/app/external-cjs/page.tsx", "language": "tsx", "file_size": 2037, "cut_index": 563, "middle_length": 229 }
ge with correct UI elements', async () => { const browser = await next.browser('/trigger-error') // Trigger a client-side error await browser.elementByCss('#trigger-error').click() // Skip UI checks in dev mode (redbox overlay covers the error page) if (isNextDev) { await expect(browser).toD...
} // In production mode, verify the client error page UI elements // Check that the SVG icon is present (32x32 size) const svgIcon = await browser.elementByCss('svg') expect(await svgIcon.getAttribute('width')).toBe('32') expect(a
@ TriggerErrorPage > 9 | throw new Error('Test client error') | ^", "stack": [ "TriggerErrorPage app/trigger-error/page.js (9:11)", ], } `) return
{ "filepath": "test/e2e/app-dir/default-error-page-ui/default-error-page-ui.test.ts", "language": "typescript", "file_size": 5122, "cut_index": 716, "middle_length": 229 }
remove this test when the feature is stable describe('global-not-found - not-present', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should render default 404 when global-not-found is not defined but enabled', async () => { const browser = await next.browser('/does-not-exist') con...
const browser = await next.browser('/call-not-found') const bodyText = await browser.elementByCss('body').text() const htmlLang = await browser.elementByCss('html').getAttribute('lang') // Render the root layout expect(htmlLang).toBe('en')
ound is not defined but enabled', async () => {
{ "filepath": "test/e2e/app-dir/global-not-found/not-present/not-present.test.ts", "language": "typescript", "file_size": 980, "cut_index": 582, "middle_length": 52 }
ly you need to use `pnpm next-with-deps dev|build` // Make sure you delete node_modules if you are editing the package otherwise it won't // reinstall and reflect your changes. import ExportsDefault from 'my-esm-package/exports' import * as ExportsNamed from 'my-esm-package/exports' import { named as namedExports } fr...
m './client' export default function Page() { return ( <> <section> <h2>Server</h2> <section> <h3>Exports</h3> <section> <h4>Static</h4> <label>Default:</label> <div>{JSON
ports' const pendingDynamicExports = import('my-esm-package/exports').then((mod) => JSON.stringify(mod) ) const pendingDynamicImports = import('my-esm-package/imports').then((mod) => JSON.stringify(mod) ) import Client fro
{ "filepath": "test/e2e/app-dir/next-condition/fixtures/render/app/esm/page.tsx", "language": "tsx", "file_size": 1963, "cut_index": 537, "middle_length": 229 }
lient' import { useState, useTransition } from 'react' export function RevalidateButton({ lang }) { const [isPending, startTransition] = useTransition() const [result, setResult] = useState(null) function handleRevalidate(withSlash) { startTransition(async () => { try { const data = await fet...
abled={isPending} id="revalidate-button-with-slash" > {isPending ? 'Revalidating...' : `Revalidate /${lang}/`} </button> <button onClick={handleRevalidate.bind(null, false)} disabled={isPending} id=
) }) } catch (e) { startTransition(() => { setResult(`Error: ${e}`) }) } }) } return ( <div> <button onClick={handleRevalidate.bind(null, true)} dis
{ "filepath": "test/e2e/app-dir/trailingslash/app/[lang]/revalidate-button.js", "language": "javascript", "file_size": 1209, "cut_index": 518, "middle_length": 229 }
ribe.each([ { dependencies: { sass: '1.54.0' }, nextConfig: undefined }, { dependencies: { 'sass-embedded': '1.75.0' }, nextConfig: { sassOptions: { implementation: 'sass-embedded', }, }, }, ])( 'SCSS Support loader handling External imports ($dependencies)', ({ dependencies, n...
= await browser.eval(async function () { return document.fonts.ready.then((fonts) => { const includedFonts = [] for (const font of fonts.values()) { includedFonts.push(font.family) } return inclu
browser = await next.browser('/') const result
{ "filepath": "test/e2e/app-dir/scss/external-url/external-url.test.ts", "language": "typescript", "file_size": 974, "cut_index": 582, "middle_length": 52 }
ion cachedConsoleCalls(outBadge: string, errBadge: string) { 'use cache' console.info( `${outBadge} /console-after-abort/server: template(one: %s, two: %s)`, 'one', 'two' ) console.log( `${outBadge} /console-after-abort/server: This is a console page` + ". Don't match the codeframe." ) ...
ssert( true, `${errBadge} /console-after-abort/server: This is an assert message without a template` ) } let i = 0 export default async function ConsolePage() { const outBadge = `:::${i}:out:::` const errBadge = `:::${i++}:err:::` console
Cache environment. // console.error(new Error('/console-after-abort/server: test')) console.assert( false, `${errBadge} /console-after-abort/server: This is an assert message with a %s`, 'template' ) console.a
{ "filepath": "test/e2e/app-dir/cache-components-console/fixtures/hide-logs-after-abort/app/console-after-abort/server/page.tsx", "language": "tsx", "file_size": 2218, "cut_index": 563, "middle_length": 229 }
e client' import { use } from 'react' function log(outBadge: string, errBadge: string) { console.info( `${outBadge} /console-after-abort/client: template(one: %s, two: %s)`, 'one', 'two' ) console.log( `${outBadge} /console-after-abort/client: This is a console page. Don't match the codeframe.` ...
without a template` ) } export default function ClientConsolePage({ data, outBadge, errBadge, }: { data: Promise<any> outBadge: string errBadge: string }) { console.log( `${outBadge} /console-after-abort/client: logging before prerend
console.assert( false, `${errBadge} /console-after-abort/client: This is an assert message with a %s`, 'template' ) console.assert( true, `${errBadge} /console-after-abort/client: This is an assert message
{ "filepath": "test/e2e/app-dir/cache-components-console/fixtures/hide-logs-after-abort/app/console-after-abort/client/client.tsx", "language": "tsx", "file_size": 1117, "cut_index": 515, "middle_length": 229 }
mport * as path from 'path' import { nextTestSetup, type Playwright } from 'e2e-utils' async function assertNoConsoleErrors(browser: Playwright) { const logs = await browser.log() const warningsAndErrors = logs.filter((log) => { return log.source === 'warning' || log.source === 'error' }) expect(warningsA...
rors(browser) // Click the link to navigate to page two // The first link causes a sliding transition // The second link causes a default transition (cross-fade) await browser.elementByCss('a[href="/transition-types/page-two"]').click()
const browser = await next.browser('/basic') await assertNoConsoleErrors(browser) }) it('transitionTypes smoketest', async () => { const browser = await next.browser('/transition-types') await assertNoConsoleEr
{ "filepath": "test/e2e/app-dir/view-transitions/view-transitions.test.ts", "language": "typescript", "file_size": 1046, "cut_index": 513, "middle_length": 229 }
e-build-file', () => { const { next } = nextTestSetup({ files: __dirname, skipStart: !isNextDev, skipDeployment: true, env: { // Enable persistent caching even when the git working directory is // dirty (e.g. when developing Next.js itself). Without this, the // cache falls back to a...
expect(existsSync(traceBuildPath)).toBe(true) }) it('should contain high-level build trace events', async () => { // Ensure we have a fresh build await next.build() const traceBuildPath = join(next.testDir, '.next/trace-b
during production build', async () => { // Build the app to trigger trace generation await next.build() // Check that trace-build file exists const traceBuildPath = join(next.testDir, '.next/trace-build')
{ "filepath": "test/e2e/app-dir/trace-build-file/trace-build-file.test.ts", "language": "typescript", "file_size": 6589, "cut_index": 716, "middle_length": 229 }
' describe('nx-handling', () => { const { next } = nextTestSetup({ skipDeployment: true, files: __dirname, installCommand: 'npm i', buildCommand: 'npm run build', startCommand: isNextDev ? 'npm run dev' : 'npm run start', packageJson: { name: '@nx-next/source', version: '0.0.0', ...
nx run next-nx-test:serve:production', }, dependencies: { react: '19.0.0', 'react-dom': '19.0.0', '@nx/js': '21.1.3', '@nx/next': '21.1.3', '@nx/workspace': '21.1.3', '@swc-node/register': '~1.9.
focused on Next.js integration. build: 'rm -rf dist; NX_ISOLATE_PLUGINS=false nx run next-nx-test:build', dev: 'NX_ISOLATE_PLUGINS=false nx run next-nx-test:dev', start: 'NX_ISOLATE_PLUGINS=false
{ "filepath": "test/e2e/app-dir/nx-handling/nx-handling.test.ts", "language": "typescript", "file_size": 2125, "cut_index": 563, "middle_length": 229 }
strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M9 12l2 2 4-4M7.835 4.697a3.42 3.42 0 001.946-.806 3.42 3.42 0 014.438 0 3.42 3.42 0 001.946.806 3.42 3.42 0 013.138 3.138 3.42 3.42 0 00.806 1.946 3.42 3.42 0 010 4.438 3.42 3...
</a> </div> <div className="logo-container"> <svg fill="currentColor" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" >
438 3.42 3.42 0 00.806-1.946 3.42 3.42 0 013.138-3.138z" /> </svg> <span>You&apos;re up and running</span> </h2> <a href="#commands"> What&apos;s next?
{ "filepath": "test/e2e/app-dir/nx-handling/apps/next-nx-test/app/page.tsx", "language": "tsx", "file_size": 20905, "cut_index": 1331, "middle_length": 229 }
, 'regular'), }) if (isNextDev) { // dev doesn't support prefetch={true}, so this just performs a basic test to make sure data is reused for 30s it('should return fresh data every navigation', async () => { let browser = await next.browser('/', browserConfigWithFixedTime) // navigate to prefet...
.elementById('random-number').text() expect(newNumber).not.toBe(initialNumber) }) } else { describe('prefetch={true}', () => { let browser: Playwright beforeEach(async () => { browser = await next.browser('/', browserC
back to the prefetch-auto page await browser.elementByCss('[href="/"]').click() await browser.eval(fastForwardTo, 5 * 1000) await browser.elementByCss('[href="/1"]').click() let newNumber = await browser
{ "filepath": "test/e2e/app-dir/app-client-cache/client-cache.defaults.test.ts", "language": "typescript", "file_size": 10715, "cut_index": 921, "middle_length": 229 }
res', 'regular'), nextConfig: { experimental: { staleTimes: { dynamic: 0 } }, }, env: { NEXT_TELEMETRY_DEBUG: '1', }, }) if (isNextDev) { // dev doesn't support prefetch={true}, so this just performs a basic test to make sure data is fresh on each navigation ...
ing state is rendered await browser .elementByCss('[href="/1?timeout=1000"]') .click() .waitForElementByCss('#loading') const initialRandomNumber = await browser .waitForElementByCss('#random-number'
WithFixedTime) // Wait for initial prefetch to complete before clicking await browser.waitForIdleNetwork() // this test introduces an artificial delay in rendering the requested page, so we verify a load
{ "filepath": "test/e2e/app-dir/app-client-cache/client-cache.experimental.test.ts", "language": "typescript", "file_size": 15322, "cut_index": 921, "middle_length": 229 }
s a basic test to make sure data is reused for 30s it('should renew the 30s cache once the data is revalidated', async () => { let browser = await next.browser('/', browserConfigWithFixedTime) // navigate to prefetch-auto page await browser.elementByCss('[href="/1"]').click() await browser....
browser.waitForElementByCss('#random-number') let newNumber = await browser.elementById('random-number').text() // the number should be the same, as we navigated within 30s. expect(newNumber).toBe(initialNumber) // Fast forward t
await browser.elementByCss('[href="/"]').click() await browser.waitForElementByCss('[href="/1"]') await browser.eval(fastForwardTo, 5 * 1000) await browser.elementByCss('[href="/1"]').click() await
{ "filepath": "test/e2e/app-dir/app-client-cache/client-cache.original.test.ts", "language": "typescript", "file_size": 17684, "cut_index": 1331, "middle_length": 229 }
' import path from 'path' import type { Page as PlaywrightPage } from 'playwright' // TODO: This suite is flaky in production and deploy modes, skip until stabilized. describe.skip('app dir client cache with parallel routes', () => { const { next, isNextDev } = nextTestSetup({ files: path.join(__dirname, 'fixtur...
eveal the content. await reveal.click() // Return the anchor link element. return browser.elementByCss(`a[href="${href}"]`) } describe('prefetch={true}', () => { it('should prefetch the full page', async () => { let page: Playwr
ef: string) { // Get the reveal element and scroll it into view. const reveal = await browser.elementByCss(`[data-link-accordion="${href}"]`) await reveal.scrollIntoViewIfNeeded() // Click the reveal element to r
{ "filepath": "test/e2e/app-dir/app-client-cache/client-cache.parallel-routes.test.ts", "language": "typescript", "file_size": 4321, "cut_index": 614, "middle_length": 229 }
} from 'e2e-utils' export const getPathname = (url: string) => { const urlObj = new URL(url) return urlObj.pathname } export const browserConfigWithFixedTime = { beforePageLoad: (page) => { page.addInitScript(() => { const startTime = new Date() const fixedTime = new Date('2023-04-17T00:00:00Z')...
ment the fixed time by the specified duration const currentTime = new Date() currentTime.setTime(currentTime.getTime() + ms) // Update the Date constructor to use the new fixed time // @ts-ignore // eslint-disable-next-line no-native-reassign
// @ts-ignore return new startTime.constructor(fixedTime) } static now() { return fixedTime.getTime() } } }) }, } export const fastForwardTo = (ms) => { // Incre
{ "filepath": "test/e2e/app-dir/app-client-cache/test-utils.ts", "language": "typescript", "file_size": 1633, "cut_index": 537, "middle_length": 229 }
turn ( <> <div> <Link href="/0?timeout=0" prefetch={true}> To Random Number - prefetch: true </Link> </div> <div> <Link href="/0?timeout=1000" prefetch={true}> To Random Number - prefetch: true, slow </Link> </div> <div> <Link...
prefetch={false}> To Random Number 2 - prefetch: false, slow </Link> </div> <div> <Link href="/1?timeout=1000"> To Random Number - prefetch: auto, slow </Link> </div> <div> <Link h
v> <div> <Link href="/2?timeout=1000"
{ "filepath": "test/e2e/app-dir/app-client-cache/fixtures/regular/app/page.js", "language": "javascript", "file_size": 977, "cut_index": 582, "middle_length": 52 }
n ( <> <div> <Link href="/without-loading/0?timeout=0" prefetch={true}> To Random Number - prefetch: true </Link> </div> <div> <Link href="/without-loading/0?timeout=1000" prefetch={true}> To Random Number - prefetch: true, slow </Link> </d...
</div> <div> <Link href="/without-loading/2?timeout=1000" prefetch={false}> To Random Number 2 - prefetch: false, slow </Link> </div> <div> <Link href="/without-loading/1?timeout=1000"> To
Random Number 2 - prefetch: false </Link>
{ "filepath": "test/e2e/app-dir/app-client-cache/fixtures/regular/app/without-loading/page.js", "language": "javascript", "file_size": 970, "cut_index": 582, "middle_length": 52 }
rowser, 'description', 'this is the layout description' ) }) it('should support title template', async () => { const browser = await next.browser('/title-template') // Use the parent layout (root layout) instead of app/title-template/layout.tsx expect(await browser.eval(...
title when no title is defined in page', async () => { const browser = await next.browser('/title-template/use-layout-title') expect(await browser.eval(`document.title`)).toBe( 'title template layout default' ) }) it('sho
// Use the parent layout (app/title-template/layout.tsx) instead of app/title-template/extra/layout.tsx expect(await browser.eval(`document.title`)).toBe('Extra Page | Layout') }) it('should use parent layout
{ "filepath": "test/e2e/app-dir/metadata/metadata.test.ts", "language": "typescript", "file_size": 32881, "cut_index": 1331, "middle_length": 229 }
ge() { return ( <> <p>{'BEGINNINGasdsadiasdhasuidhasdiuasduhiuihueiohjewiohjewiohj'}</p> <p>{'asdsadiasdhasuidhasdiuasasdsadduhiuihueiohjewiohjewiohj'}</p> <p>{'asdasd'}</p> <p>{'asdasdasadasdasd232344234234234'}</p> <p>{'asdsadiasdhasuidhasdiuasasdsadduhiuihueiohjewiohjewiohj'}</p> ...
4234'}</p> <p>{'asdsadiasdhasuidhasdiuasasdsadduhiuihueiohjewiohjewiohj'}</p> <p>{'asdasd'}</p> <p>{'asdasdasadasdasd232344234234234'}</p> <p>{'asdsadiasdhasuidhasdiuasasdsadduhiuihueiohjewiohjewiohj'}</p> <p>{'asdasd'}</p>
sdasd232344234234234'}</p> <p>{'asdsadiasdhasuidhasdiuasduhiuihueiohjewiohjewiohj'}</p> <p>{'asdsadiasdhasuidhasdiuasasdsadduhiuihueiohjewiohjewiohj'}</p> <p>{'asdasd'}</p> <p>{'asdasdasadasdasd23234423423
{ "filepath": "test/e2e/app-dir/metadata/app/large-shell/[slug]/page.tsx", "language": "tsx", "file_size": 5816, "cut_index": 716, "middle_length": 229 }
from 'react' import type { Metadata } from 'next' import Link from 'next/link' import Client from './client' export default function Page() { return ( <div id="basic"> <Link id="to-index" href="/"> to index </Link> <br /> <Link href="/title-template/extra/inner" id="to-nested"> ...
dex, follow', alternates: {}, pagination: { previous: '/basic?page=1', next: '/basic?page=3', }, formatDetection: { email: false, address: false, telephone: false, // Properties set to `true` should not be included in `forma
n-when-cross-origin', keywords: ['next.js', 'react', 'javascript'], authors: [{ name: 'huozhi' }, { name: 'tree', url: 'https://tree.com' }], manifest: '/api/manifest', creator: 'shu', publisher: 'vercel', robots: 'in
{ "filepath": "test/e2e/app-dir/metadata/app/basic/page.tsx", "language": "tsx", "file_size": 1324, "cut_index": 524, "middle_length": 229 }
' export const runtime = 'edge' export default function Page() { return ( <div id="basic"> <Link id="to-index" href="/"> to index </Link> <br /> <Link href="/title-template/extra/inner" id="to-nested"> to /title-template/extra/inner </Link> <Client /> </di...
://tree.com' }], manifest: '/api/manifest', robots: 'index, follow', alternates: {}, pagination: { previous: '/basic?page=1', next: '/basic?page=3', }, formatDetection: { email: false, address: false, telephone: false, },
rs: [{ name: 'huozhi' }, { name: 'tree', url: 'https
{ "filepath": "test/e2e/app-dir/metadata/app/basic-edge/page.tsx", "language": "tsx", "file_size": 916, "cut_index": 606, "middle_length": 52 }
{ nextTestSetup } from 'e2e-utils' describe('cache-components PPR bot static generation bypass', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should bypass static generation for DOM bot requests to avoid SSG_BAILOUT', async () => { const res = await next.fetch('/foo', { heade...
// Check that the page rendered successfully // With PPR, content is streamed via script tags expect(html).toContain('\\"children\\":\\"foo\\"') // Verify Math.random() was executed (check for a decimal number in the streamed content)
allows them to handle dynamic content // like Math.random() without triggering SSG_BAILOUT errors. expect(res.status).toBe(200) // Verify that the response contains the page content const html = await res.text()
{ "filepath": "test/e2e/app-dir/cache-components-bot-ua/cache-components-bot-ua.test.ts", "language": "typescript", "file_size": 1175, "cut_index": 518, "middle_length": 229 }
retry } from 'next-test-utils' describe('interception-dynamic-segment-middleware', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should work when interception route is paired with a dynamic segment & middleware', async () => { const browser = await next.browser('/') await browse...
) }) }) it('should intercept with back/forward navigation with middleware', async () => { // Test that interception works correctly with middleware and browser navigation const browser = await next.browser('/') // Navigate with
await retry(async () => { expect(await browser.elementById('modal').text()).toBe('default') }) await retry(async () => { expect(await browser.elementById('children').text()).toMatch( /not intercepted/
{ "filepath": "test/e2e/app-dir/interception-dynamic-segment-middleware/interception-dynamic-segment-middleware.test.ts", "language": "typescript", "file_size": 2168, "cut_index": 563, "middle_length": 229 }
routes-breadcrumbs', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should provide an unmatched catch-all route with params', async () => { const browser = await next.browser('/') await browser.elementByCss("[href='/artist1']").click() const slot = await browser.waitForElement...
um2']").click() await retry(async () => { // verify page is rendering the params expect(await browser.elementByCss('h2').text()).toBe('Album: album2') }) // verify slot is rendering the params expect(await slot.text()).toConta
ait slot.text()).toContain('Artist: artist1') expect(await slot.text()).toContain('Album: Select an album') expect(await slot.text()).toContain('Track: Select a track') await browser.elementByCss("[href='/artist1/alb
{ "filepath": "test/e2e/app-dir/parallel-routes-breadcrumbs/parallel-routes-breadcrumbs.test.ts", "language": "typescript", "file_size": 3476, "cut_index": 614, "middle_length": 229 }
he layout manually ;(process.env.IS_TURBOPACK_TEST ? describe.skip : describe)( 'app-dir create root layout', () => { const isDev = (global as any).isNextDev if ((global as any).isNextDeploy) { it('should skip next deploy for now', () => {}) return } if (isDev) { describe('page.j...
tput.length const browser = await next.browser('/route') expect(await browser.elementById('page-text').text()).toBe( 'Hello world!' ) await check( () => stripAnsi(next.cliOutput.
'next.config.js': new FileRef( path.join(__dirname, 'next.config.js') ), }, }) it('create root layout', async () => { const outputIndex = next.cliOu
{ "filepath": "test/e2e/app-dir/create-root-layout/create-root-layout.test.ts", "language": "typescript", "file_size": 7179, "cut_index": 716, "middle_length": 229 }
t { next, isNextDev, isNextStart } = nextTestSetup({ files: __dirname, }) it('should generate an opengraph image with a metadata route handler that uses "use cache"', async () => { const res = await next.fetch('/opengraph-image') expect(res.status).toBe(200) expect(res.headers.get('content-type'))....
tch('/icon') expect(res.status).toBe(200) expect(res.headers.get('content-type')).toBe('image/png') if (isNextStart) { const [buildStatus] = next.cliOutput.match(/. \/icon/) // TODO: Should always be `○ /icon`. expect(buildS
s).toBeOneOf([ '○ /opengraph-image', 'ƒ /opengraph-image', ]) } }) it('should generate an icon image with a metadata route handler that uses "use cache"', async () => { const res = await next.fe
{ "filepath": "test/e2e/app-dir/use-cache-metadata-route-handler/use-cache-metadata-route-handler.test.ts", "language": "typescript", "file_size": 4948, "cut_index": 614, "middle_length": 229 }
rt { ImageResponse } from 'next/og' export const alt = 'About Acme' export const size = { width: 1200, height: 630 } export const contentType = 'image/png' async function fetchPostData() { 'use cache' return { title: 'Test', created: Date.now() } } export default async function Image() { const post = await fe...
justifyContent: 'center', flexDirection: 'column', }} > <h1>{post.title}</h1> <p style={{ fontSize: 32 }}> {new Date(post.created).toLocaleTimeString()} </p> </div> ), size )
display: 'flex', alignItems: 'center',
{ "filepath": "test/e2e/app-dir/use-cache-metadata-route-handler/app/opengraph-image.tsx", "language": "tsx", "file_size": 827, "cut_index": 516, "middle_length": 52 }
retry } from 'next-test-utils' describe('next/script beforeInteractive inline payload escaping', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should html-escape forwarded string props so they cannot break out of the inline __next_s script', async () => { const html = await next.rend...
lineChildren=true</script>' ) expect(html).not.toContain('</script><script>window.__xssSrc=true</script>') // The fixture's <PwnDetector /> exposes each result as a `data-*` // attribute on `[data-testid="xss-status"]`. `data-ready="true"`
L tokenizer level and the trailing <script> executes. expect(html).not.toContain( '</script><script>window.__xssInlineInnerHTML=true</script>' ) expect(html).not.toContain( '</script><script>window.__xssIn
{ "filepath": "test/e2e/app-dir/script-before-interactive-xss/script-before-interactive-xss.test.ts", "language": "typescript", "file_size": 2178, "cut_index": 563, "middle_length": 229 }
script' import { PwnDetector } from './xss-detector' // Regression fixture for HTML-escaping of the inline __next_s payload that // Next.js emits for `beforeInteractive` scripts. Any string prop forwarded // through `restProps` (here `data-tracking-id`, but `id` and any other // attribute are equivalent) reaches the i...
acking-id="</script><script>window.__xssInlineInnerHTML=true</script>" dangerouslySetInnerHTML={{ // The body evaluates a `<` comparison so the global doubles as proof // of both "did this run" and "did the HTML-escape preserve
the fingerprint it leaves on `window` // is picked up by <PwnDetector />. export default function Page() { return ( <div> <Script id="inline-innerhtml-xss" strategy="beforeInteractive" data-tr
{ "filepath": "test/e2e/app-dir/script-before-interactive-xss/app/page.tsx", "language": "tsx", "file_size": 1938, "cut_index": 537, "middle_length": 229 }
on: // // 1. Whether any malicious injected `<script>` executed. Each would set a // `__xss*` global from its `</script><script>...</script>` break-out. // 2. Whether each legitimate beforeInteractive `<Script>` actually ran AND, // for the inline ones, that the HTML-escape round-trip preserved the // source ...
boolean `data-*` attribute for simple per-result querying // from tests. type Report = { xssInlineInnerHTML: boolean xssInlineChildren: boolean xssSrc: boolean escapeProofInlineInnerHTML: boolean escapeProofInlineChildren: boolean loadedSrc: b
fail the `=== true` // check. The external-src script only needs to confirm it loaded, so it // uses a plain flag (`__loadedSrc`). // // Each result is both rendered as human-readable text for debugging and // exposed as a
{ "filepath": "test/e2e/app-dir/script-before-interactive-xss/app/xss-detector.tsx", "language": "tsx", "file_size": 3255, "cut_index": 614, "middle_length": 229 }
{import('next').NextConfig} */ const nextConfig = { cacheComponents: true, experimental: { optimisticRouting: true, }, // The bug being regressed requires the response for /[teamSlug] to // exercise its `@actions/[...catchAll]` parallel slot even though the // canonical URL has no parts left to feed t...
anonical URL is short enough // that no parts reach the catch-all under normal routing. async rewrites() { return [ { source: '/:teamSlug', destination: '/:teamSlug/overview', }, ] }, } module.exports = nextConfig
lot, but the c
{ "filepath": "test/e2e/app-dir/segment-cache/optimistic-routing-parallel-slot-catchall-regression/next.config.js", "language": "javascript", "file_size": 795, "cut_index": 524, "middle_length": 14 }
stSetup } from 'e2e-utils' import { waitForRedbox, getRedboxSource } from 'next-test-utils' describe('Invalid Global CSS with Custom App', () => { const { next, skipped, isTurbopack, isRspack } = nextTestSetup({ files: __dirname, skipStart: isNextStart, skipDeployment: true, dependencies: { sass: '1....
y global CSS imports.*?pages(\/|\\)_app/ ) // Skip: Rspack loaders cannot access module issuer info for location details if (!process.env.NEXT_RSPACK) { expect(cliOutput).toMatch(/Location:.*pages[\\/]index\.js/) } })
).not.toBe(0) if (!isTurbopack) { expect(cliOutput).toContain('Failed to compile') } expect(cliOutput).toContain('styles/global.scss') expect(cliOutput).toMatch( /Please move all first-part
{ "filepath": "test/e2e/app-dir/scss/invalid-global-with-app/invalid-global-with-app.test.ts", "language": "typescript", "file_size": 2744, "cut_index": 563, "middle_length": 229 }
ependencies: { 'sass-embedded': '1.75.0' }, nextConfig: { ...nextConfig, sassOptions: { implementation: 'sass-embedded', }, }, }, ])('SCSS Support ($dependencies)', ({ dependencies, nextConfig }) => { const { next, isNextDev, skipped } = nextTestSetup({ files: __dirname, //...
compiled and prefixed`, async () => { const $ = await next.render$('/') const cssSheet = $('link[rel="stylesheet"]') expect(cssSheet.length).toBe(1) const stylesheetUrl = cssSheet.attr('href') const cssContent = a
nfig, }) if (skipped) return // TODO: Figure out this test for dev and Turbopack ;(isNextDev ? describe.skip : describe)('Production only', () => { describe('CSS Compilation and Prefixing', () => { it(`should've
{ "filepath": "test/e2e/app-dir/scss/compilation-and-prefixing/compilation-and-prefixing.test.ts", "language": "typescript", "file_size": 6913, "cut_index": 716, "middle_length": 229 }
mistic routing - parallel slot catch-all regression', () => { const { next, isNextDev } = nextTestSetup({ files: __dirname, }) if (isNextDev) { // Optimistic routing is a production-build feature; in dev mode the // router does not have complete information about which routes // exist, so predict...
ch-all, resolving the URL to the team-page // content even though /myteam/myproject is a separate route. The // router skipped the server fetch entirely under the (incorrect) // assumption that the URL was already known. // // Detection: visit /m
n // `@actions/[...catchAll]` slot) used to poison route prediction. // After visiting /myteam, navigating to a longer sibling URL like // /myteam/myproject would reuse a prediction derived from the // @actions slot's cat
{ "filepath": "test/e2e/app-dir/segment-cache/optimistic-routing-parallel-slot-catchall-regression/optimistic-routing-parallel-slot-catchall-regression.test.ts", "language": "typescript", "file_size": 3183, "cut_index": 614, "middle_length": 229 }
from 'e2e-utils' import type * as Playwright from 'playwright' import { createRouterAct } from 'router-act' describe('client params', () => { const { next, isNextDev } = nextTestSetup({ files: __dirname, }) if (isNextDev) { test('prefetching is disabled', () => {}) return } it('client segments t...
// be able to fully prefetch them, without invoking a dynamic server render. const toggleLinkVisibility = await browser.elementByCss( 'input[data-link-accordion="/clothing/1"]' ) await act(async () => { await toggleLinkVisibility.cl
: Playwright.Page) { act = createRouterAct(p) }, }) // Prefetch the page. Although this page access dynamic params, it only // does so inside segments that are marked with "use cache". So we should
{ "filepath": "test/e2e/app-dir/segment-cache/client-params/client-params.test.ts", "language": "typescript", "file_size": 1601, "cut_index": 537, "middle_length": 229 }
act' function Content({ params, searchParams, }: { params: Promise<{ product: string }> searchParams: Promise<Record<string, string | string[] | undefined>> }) { const { product } = use(params) const searchParamsDict = use(searchParams) let query = null if (Object.keys(searchParamsDict).length > 0) { ...
rams, }: { params: Promise<{ product: string }> searchParams: Promise<Record<string, string | string[] | undefined>> }) { return ( <Suspense fallback="Loading..."> <Content params={params} searchParams={searchParams} /> </Suspense> )
default function ProductPage({ params, searchPa
{ "filepath": "test/e2e/app-dir/segment-cache/client-params/app/[category]/[product]/page.tsx", "language": "tsx", "file_size": 869, "cut_index": 559, "middle_length": 52 }
BrowserWithFakeClock(url: string) { let page!: Playwright.Page const startDate = Date.now() const browser = await next.browser(url, { async beforePageLoad(p: Playwright.Page) { page = p await page.clock.install() await page.clock.setFixedTime(startDate) }, }) co...
Css( 'input[data-link-accordion="/per-page-config/dynamic-stale-60"]' ) await toggle.click() const link = await browser.elementByCss( 'a[href="/per-page-config/dynamic-stale-60"]' ) await link.cli
t, startDate } = await startBrowserWithFakeClock('/per-page-config') // Navigate to the dynamic page with unstable_dynamicStaleTime = 60 await act( async () => { const toggle = await browser.elementBy
{ "filepath": "test/e2e/app-dir/segment-cache/staleness/segment-cache-per-page-dynamic-stale-time.test.ts", "language": "typescript", "file_size": 13114, "cut_index": 921, "middle_length": 229 }
v } = nextTestSetup({ files: __dirname, }) if (isNextDev) { test('disabled in development / deployment', () => {}) return } it('entry expires when its stale time has elapsed', async () => { let page: Playwright.Page const browser = await next.browser('/', { beforePageLoad(p: Playwrigh...
nc () => { await toggle2MinutesLink.click() await browser.elementByCss('a[href="/stale-2-minutes"]') }, { includes: 'Content with stale time of 2 minutes', } ) await act( async () => { await t
ait browser.elementByCss( 'input[data-link-accordion="/stale-2-minutes"]' ) const toggle4MinutesLink = await browser.elementByCss( 'input[data-link-accordion="/stale-4-minutes"]' ) await act( asy
{ "filepath": "test/e2e/app-dir/segment-cache/staleness/segment-cache-stale-time.test.ts", "language": "typescript", "file_size": 8563, "cut_index": 716, "middle_length": 229 }
stSetup } from 'e2e-utils' import { waitForRedbox, getRedboxSource } from 'next-test-utils' describe('Valid and Invalid Global CSS with Custom App', () => { const { next, skipped, isTurbopack, isRspack } = nextTestSetup({ files: __dirname, skipStart: isNextStart, skipDeployment: true, dependencies: {...
l first-party global CSS imports' ) // Skip: Rspack loaders cannot access module issuer info for location details if (!process.env.NEXT_RSPACK) { expect(cliOutput).toMatch(/Location:.*pages[\\/]index\.js/) } }) } else
t(exitCode).not.toBe(0) if (!isTurbopack) { expect(cliOutput).toContain('Failed to compile') } expect(cliOutput).toContain('styles/global.scss') expect(cliOutput).toContain( 'Please move al
{ "filepath": "test/e2e/app-dir/scss/valid-and-invalid-global/valid-and-invalid-global.test.ts", "language": "typescript", "file_size": 2737, "cut_index": 563, "middle_length": 229 }
eslint-env jest */ import { nextTestSetup } from 'e2e-utils' import { colorToRgb } from 'next-test-utils' describe.each([ { dependencies: { sass: '1.54.0' }, nextConfig: undefined }, { dependencies: { 'sass-embedded': '1.75.0' }, nextConfig: { sassOptions: { implementation: 'sass-embedded',...
dencies, nextConfig, }) it('should have CSS for page', async () => { const browser = await next.browser('/') expect( await browser.elementByCss('#verify-red').getComputedCss('color') ).toBe(colorToRgb('red')) })
e, depen
{ "filepath": "test/e2e/app-dir/scss/dev-module/dev-module.test.ts", "language": "typescript", "file_size": 791, "cut_index": 514, "middle_length": 14 }
from 'e2e-utils' describe('app-dir - metadata-icons-parallel-routes', () => { const { next } = nextTestSetup({ files: __dirname, }) it('should present favicon with other icons when parallel routes are presented', async () => { const $ = await next.render$('/') expect($('link[type="image/x-icon"]').l...
nk[rel="icon"][type="image/svg+xml"]') expect(pngIcon.length).toBe(1) expect(svgIcon.length).toBe(1) // Verify the URLs are distinct expect(pngIcon.attr('href')).toMatch(/icon\.png/) expect(svgIcon.attr('href')).toMatch(/icon\.svg/)
both are present', async () => { const $ = await next.render$('/') // Should have both PNG and SVG icons for browser fallback support const pngIcon = $('link[rel="icon"][type="image/png"]') const svgIcon = $('li
{ "filepath": "test/e2e/app-dir/metadata-icons-parallel-routes/metadata-icons-parallel-routes.test.ts", "language": "typescript", "file_size": 1909, "cut_index": 537, "middle_length": 229 }
mport Link from 'next/link' export default async function Page(props) { const searchParams = await props.searchParams return ( <> <div id="root-params">{JSON.stringify(searchParams)}</div> <Link href="/search">Go to search</Link> <hr /> <ul> <li> <Link href="/search-p...
</Link> </li> <li> <Link href="/params-first" prefetch={false}> /params-first </Link> </li> <li> <Link href="/root-page-first" prefetch={false}> /root-page-first
-params?id=3" prefetch={true}> /search-params?id=3 (prefetch: true) </Link> </li> <li> <Link href="/search-params" prefetch={true}> /search-params (prefetch: true)
{ "filepath": "test/e2e/app-dir/searchparams-reuse-loading/app/page.tsx", "language": "tsx", "file_size": 1053, "cut_index": 513, "middle_length": 229 }