More Turbopack fixes (#56299)

Skips additional production-only tests.

Follow-up to #56089.

In this PR I went through all of `test/integration` looking for `nextBuild(` and added the skipping logic.
This commit is contained in:
Tim Neutkens 2023-10-02 15:55:23 +02:00 committed by GitHub
parent ecd94c1a4d
commit 59bda2d818
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
127 changed files with 5849 additions and 5400 deletions

View file

@ -22,7 +22,9 @@ const gip500Err =
let appPort
let app
it('does not show error with getStaticProps in pages/500 build', async () => {
describe('gsp-gssp', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('does not show error with getStaticProps in pages/500 build', async () => {
await fs.move(pages500, `${pages500}.bak`)
await fs.writeFile(
pages500,
@ -39,38 +41,8 @@ it('does not show error with getStaticProps in pages/500 build', async () => {
expect(stderr).not.toMatch(gip500Err)
expect(code).toBe(0)
})
it('does not show error with getStaticProps in pages/500 dev', async () => {
await fs.move(pages500, `${pages500}.bak`)
await fs.writeFile(
pages500,
`
const page = () => 'custom 500 page'
export const getStaticProps = () => ({ props: { a: 'b' } })
export default page
`
)
let stderr = ''
appPort = await findPort()
app = await launchApp(appDir, appPort, {
onStderr(msg) {
stderr += msg || ''
},
})
await renderViaHTTP(appPort, '/abc')
await waitFor(1000)
await killApp(app)
await fs.remove(pages500)
await fs.move(`${pages500}.bak`, pages500)
expect(stderr).not.toMatch(gip500Err)
})
it('shows error with getServerSideProps in pages/500 build', async () => {
it('shows error with getServerSideProps in pages/500 build', async () => {
await fs.move(pages500, `${pages500}.bak`)
await fs.writeFile(
pages500,
@ -87,38 +59,9 @@ it('shows error with getServerSideProps in pages/500 build', async () => {
expect(stderr).toMatch(gip500Err)
expect(code).toBe(1)
})
it('shows error with getServerSideProps in pages/500 dev', async () => {
await fs.move(pages500, `${pages500}.bak`)
await fs.writeFile(
pages500,
`
const page = () => 'custom 500 page'
export const getServerSideProps = () => ({ props: { a: 'b' } })
export default page
`
)
let stderr = ''
appPort = await findPort()
app = await launchApp(appDir, appPort, {
onStderr(msg) {
stderr += msg || ''
},
})
await renderViaHTTP(appPort, '/500')
await waitFor(1000)
await killApp(app)
await fs.remove(pages500)
await fs.move(`${pages500}.bak`, pages500)
expect(stderr).toMatch(gip500Err)
})
it('does build 500 statically with getInitialProps in _app and getStaticProps in pages/500', async () => {
it('does build 500 statically with getInitialProps in _app and getStaticProps in pages/500', async () => {
await fs.writeFile(
pagesApp,
`
@ -163,9 +106,9 @@ it('does build 500 statically with getInitialProps in _app and getStaticProps in
expect(stderr).not.toMatch(gip500Err)
expect(buildStdout).toContain('rendered 500')
expect(code).toBe(0)
expect(await fs.pathExists(join(appDir, '.next/server/pages/500.html'))).toBe(
true
)
expect(
await fs.pathExists(join(appDir, '.next/server/pages/500.html'))
).toBe(true)
let appStdout = ''
const appPort = await findPort()
@ -182,9 +125,9 @@ it('does build 500 statically with getInitialProps in _app and getStaticProps in
await killApp(app)
expect(appStdout).not.toContain('rendered 500')
})
})
it('does not build 500 statically with no pages/500 and getServerSideProps in _error', async () => {
it('does not build 500 statically with no pages/500 and getServerSideProps in _error', async () => {
await fs.rename(pages500, `${pages500}.bak`)
await fs.writeFile(
pagesError,
@ -219,9 +162,9 @@ it('does not build 500 statically with no pages/500 and getServerSideProps in _e
console.log(buildStderr)
expect(buildStderr).not.toMatch(gip500Err)
expect(code).toBe(0)
expect(await fs.pathExists(join(appDir, '.next/server/pages/500.html'))).toBe(
false
)
expect(
await fs.pathExists(join(appDir, '.next/server/pages/500.html'))
).toBe(false)
let appStderr = ''
const appPort = await findPort()
@ -235,4 +178,66 @@ it('does not build 500 statically with no pages/500 and getServerSideProps in _e
await killApp(app)
expect(appStderr).toContain('called _error getServerSideProps')
})
})
describe('development mode', () => {
it('does not show error with getStaticProps in pages/500 dev', async () => {
await fs.move(pages500, `${pages500}.bak`)
await fs.writeFile(
pages500,
`
const page = () => 'custom 500 page'
export const getStaticProps = () => ({ props: { a: 'b' } })
export default page
`
)
let stderr = ''
appPort = await findPort()
app = await launchApp(appDir, appPort, {
onStderr(msg) {
stderr += msg || ''
},
})
await renderViaHTTP(appPort, '/abc')
await waitFor(1000)
await killApp(app)
await fs.remove(pages500)
await fs.move(`${pages500}.bak`, pages500)
expect(stderr).not.toMatch(gip500Err)
})
it('shows error with getServerSideProps in pages/500 dev', async () => {
await fs.move(pages500, `${pages500}.bak`)
await fs.writeFile(
pages500,
`
const page = () => 'custom 500 page'
export const getServerSideProps = () => ({ props: { a: 'b' } })
export default page
`
)
let stderr = ''
appPort = await findPort()
app = await launchApp(appDir, appPort, {
onStderr(msg) {
stderr += msg || ''
},
})
await renderViaHTTP(appPort, '/500')
await waitFor(1000)
await killApp(app)
await fs.remove(pages500)
await fs.move(`${pages500}.bak`, pages500)
expect(stderr).toMatch(gip500Err)
})
})
})

View file

@ -70,6 +70,36 @@ describe('500 Page Support', () => {
runTests('dev')
})
describe('development mode 2', () => {
it('shows error with getInitialProps in pages/500 dev', async () => {
await fs.move(pages500, `${pages500}.bak`)
await fs.writeFile(
pages500,
`
const page = () => 'custom 500 page'
page.getInitialProps = () => ({ a: 'b' })
export default page
`
)
let stderr = ''
appPort = await findPort()
app = await launchApp(appDir, appPort, {
onStderr(msg) {
stderr += msg || ''
},
})
await renderViaHTTP(appPort, '/500')
await waitFor(1000)
await killApp(app)
await fs.remove(pages500)
await fs.move(`${pages500}.bak`, pages500)
expect(stderr).toMatch(gip500Err)
})
})
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await fs.remove(join(appDir, '.next'))
@ -81,7 +111,9 @@ describe('500 Page Support', () => {
runTests('server')
})
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode 2',
() => {
it('does not build 500 statically with getInitialProps in _app', async () => {
await fs.writeFile(
pagesApp,
@ -322,33 +354,6 @@ describe('500 Page Support', () => {
expect(stderr).toMatch(gip500Err)
expect(code).toBe(1)
})
it('shows error with getInitialProps in pages/500 dev', async () => {
await fs.move(pages500, `${pages500}.bak`)
await fs.writeFile(
pages500,
`
const page = () => 'custom 500 page'
page.getInitialProps = () => ({ a: 'b' })
export default page
`
}
)
let stderr = ''
appPort = await findPort()
app = await launchApp(appDir, appPort, {
onStderr(msg) {
stderr += msg || ''
},
})
await renderViaHTTP(appPort, '/500')
await waitFor(1000)
await killApp(app)
await fs.remove(pages500)
await fs.move(`${pages500}.bak`, pages500)
expect(stderr).toMatch(gip500Err)
})
})

View file

@ -19,6 +19,7 @@ let cdnAccessLog = []
const nextConfig = new File(path.resolve(__dirname, '../next.config.js'))
describe('absolute assetPrefix with path prefix', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
cdnPort = await findPort()
// lightweight http proxy
@ -118,4 +119,5 @@ describe('absolute assetPrefix with path prefix', () => {
`/_next/data/${buildId}/gssp.json?prop=foo`
)
})
})
})

View file

@ -13,6 +13,7 @@ const nextConfig = new File(join(appDir, 'next.config.js'))
let buildOutput
describe('AMP Validation on Export', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
const { stdout = '', stderr = '' } = await nextBuild(appDir, [], {
stdout: true,
@ -123,4 +124,5 @@ describe('AMP Validation on Export', () => {
nextConfig.restore()
}
})
})
})

View file

@ -14,6 +14,7 @@ let appPort
const appDir = join(__dirname, '../')
describe('AMP Custom Optimizer', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should build and start for static page', async () => {
const { code } = await nextBuild(appDir)
expect(code).toBe(0)
@ -51,4 +52,5 @@ describe('AMP Custom Optimizer', () => {
'script async src="https://cdn.ampproject.org/rtv/001515617716922/v0.mjs"'
)
})
})
})

View file

@ -15,6 +15,7 @@ let appPort
const appDir = join(__dirname, '../')
describe('AMP Custom Validator', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should build and start successfully', async () => {
const { code } = await nextBuild(appDir)
expect(code).toBe(0)
@ -27,7 +28,9 @@ describe('AMP Custom Validator', () => {
expect(html).toContain('Hello from AMP')
})
})
describe('development mode', () => {
it('should run in dev mode successfully', async () => {
let stderr = ''
@ -44,4 +47,5 @@ describe('AMP Custom Validator', () => {
expect(stderr).not.toContain('error')
expect(html).toContain('Hello from AMP')
})
})
})

View file

@ -16,6 +16,7 @@ let appPort
let app
describe('AMP Fragment Styles', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir, [])
appPort = await findPort()
@ -31,4 +32,5 @@ describe('AMP Fragment Styles', () => {
expect(styles).toMatch(/background:(.*|)hotpink/)
expect(styles).toMatch(/font-size:(.*|)16\.4px/)
})
})
})

View file

@ -118,6 +118,9 @@ describe('AMP SSG Support', () => {
runTests(true)
})
describe('export mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
let buildId
beforeAll(async () => {
@ -145,5 +148,7 @@ describe('AMP SSG Support', () => {
await fsExists(outFile(join('_next/data', buildId, 'hybrid.json')))
).toBe(true)
})
}
)
})
})

View file

@ -59,8 +59,7 @@ describe('API routes', () => {
runTests()
})
describe('Server support', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()

View file

@ -643,8 +643,7 @@ describe('API routes', () => {
runTests(true)
})
describe('Server support', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
mode = 'server'

View file

@ -11,6 +11,7 @@ import {
} from './utils'
describe('app dir with output export (next dev / next build)', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should throw when exportPathMap configured', async () => {
nextConfig.replace(
'trailingSlash: true,',
@ -139,4 +140,5 @@ describe('app dir with output export (next dev / next build)', () => {
await fs.remove(outputDir)
}
})
})
})

View file

@ -18,6 +18,7 @@ const nextConfig = new File(join(appDir, 'next.config.js'))
let app
describe('app dir with output export (next start)', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
afterEach(async () => {
await killApp(app)
nextConfig.restore()
@ -57,4 +58,5 @@ describe('app dir with output export (next start)', () => {
`"next start" does not work with "output: standalone" configuration. Use "node .next/standalone/server.js" instead.`
)
})
})
})

View file

@ -51,6 +51,7 @@ const respectsChunkAttachmentOrder = async () => {
}
describe('Root components import order', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
@ -66,9 +67,10 @@ describe('Root components import order', () => {
'root components should be imported in this order _document > _app > page in order to respect side effects',
respectsSideEffects
)
})
})
describe('on dev server', () => {
describe('development mode', () => {
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(join(__dirname, '../'), appPort)

View file

@ -16,6 +16,7 @@ let server
let app
describe('Custom Document Fragment Styles', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
app = nextServer({
@ -37,4 +38,5 @@ describe('Custom Document Fragment Styles', () => {
expect(styles).toMatch(/background:(.*|)hotpink/)
expect(styles).toMatch(/font-size:(.*|)16\.4px/)
})
})
})

View file

@ -1,12 +1,17 @@
import { nextBuild } from 'next-test-utils'
import { join } from 'path'
it('throws an error when prerendering a page with config dynamic error', async () => {
describe('app-dynamic-error', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('throws an error when prerendering a page with config dynamic error', async () => {
const appDir = join(__dirname, '../../app-dynamic-error')
const { stderr, code } = await nextBuild(appDir, [], {
stderr: true,
stdout: true,
})
expect(stderr).toContain('Error occurred prerendering page "/dynamic-error"')
expect(stderr).toContain(
'Error occurred prerendering page "/dynamic-error"'
)
expect(code).toBe(1)
})
})
})

View file

@ -27,8 +27,10 @@ const runTests = () => {
})
}
describe('dev mode', () => {
// Skip as it runs `next build`, seems that is a bug.
;(process.env.TURBOPACK ? describe.skip : describe)('dev mode', () => {
beforeAll(async () => {
// TODO: This look like a bug, `nextBuild` shouldn't be required here.
await nextBuild(appDir)
appPort = await findPort()
buildId = 'development'

View file

@ -11,6 +11,7 @@ const fixturesDir = join(__dirname, '..', 'fixtures')
const nextConfig = new File(join(fixturesDir, 'basic-app/next.config.js'))
describe('Build Output', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const configs = [{}, { gzipSize: false }]
for (const experimental of configs) {
@ -264,7 +265,9 @@ describe('Build Output', () => {
expect(stdout).toMatch(/λ \/404 (.* )?\d{1,} B/)
expect(stdout).toMatch(/\+ First Load JS shared by all [ 0-9.]* kB/)
expect(stdout).toMatch(/ chunks\/main-[0-9a-z]{16}\.js [ 0-9.]* kB/)
expect(stdout).toMatch(/ chunks\/framework-[0-9a-z]{16}\.js [ 0-9. ]* kB/)
expect(stdout).toMatch(
/ chunks\/framework-[0-9a-z]{16}\.js [ 0-9. ]* kB/
)
expect(stdout).not.toContain(' /_document')
expect(stdout).not.toContain(' /_app')
@ -291,4 +294,5 @@ describe('Build Output', () => {
expect(stdout).not.toContain('<buildId>')
})
})
})
})

View file

@ -7,6 +7,7 @@ import { nextBuild } from 'next-test-utils'
const appDir = join(__dirname, '../app')
describe('build trace with extra entries', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should build and trace correctly', async () => {
const result = await nextBuild(appDir, undefined, {
cwd: appDir,
@ -37,9 +38,9 @@ describe('build trace with extra entries', () => {
]
expect(tracedFiles.some((file) => file.endsWith('hello.json'))).toBe(true)
expect(tracedFiles.some((file) => file.includes('some-cms/index.js'))).toBe(
true
)
expect(
tracedFiles.some((file) => file.includes('some-cms/index.js'))
).toBe(true)
expect(
tracedFiles.some((file) => file === '../../../include-me/hello.txt')
).toBe(true)
@ -56,7 +57,9 @@ describe('build trace with extra entries', () => {
)
).toBe(true)
expect(
tracedFiles.some((file) => file.includes('nested-structure/package.json'))
tracedFiles.some((file) =>
file.includes('nested-structure/package.json')
)
).toBe(true)
expect(
tracedFiles.some((file) =>
@ -70,4 +73,5 @@ describe('build trace with extra entries', () => {
false
)
})
})
})

View file

@ -7,6 +7,7 @@ import { nextBuild } from 'next-test-utils'
const appDir = join(__dirname, '../app')
describe('build trace with extra entries', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should build and trace correctly', async () => {
const result = await nextBuild(appDir, undefined, {
cwd: appDir,
@ -53,10 +54,14 @@ describe('build trace with extra entries', () => {
indexTrace.files.some((file) => file.includes('some-cms/index.js'))
).toBe(true)
expect(
indexTrace.files.some((file) => file === '../../../include-me/hello.txt')
indexTrace.files.some(
(file) => file === '../../../include-me/hello.txt'
)
).toBe(true)
expect(
indexTrace.files.some((file) => file === '../../../include-me/second.txt')
indexTrace.files.some(
(file) => file === '../../../include-me/second.txt'
)
).toBe(true)
expect(indexTrace.files.some((file) => file.includes('exclude-me'))).toBe(
false
@ -84,4 +89,5 @@ describe('build trace with extra entries', () => {
imageTrace.files.some((file) => file.includes('public/test.jpg'))
).toBe(false)
})
})
})

View file

@ -7,7 +7,8 @@ import { join } from 'path'
const appDir = join(__dirname, '../')
describe('Build warnings', () => {
it('should not shown warning about minification withou any modification', async () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should not shown warning about minification without any modification', async () => {
const { stderr } = await nextBuild(appDir, undefined, { stderr: true })
expect(stderr).not.toContain('optimization has been disabled')
})
@ -86,4 +87,5 @@ describe('Build warnings', () => {
}))
expect(stdout).not.toContain('no-cache')
})
})
})

View file

@ -13,6 +13,7 @@ const appDir = join(__dirname, '../')
const errorRegex = /getStaticPaths was added without a getStaticProps in/
describe('Catches Missing getStaticProps', () => {
describe('development mode', () => {
it('should catch it in dev mode', async () => {
const appPort = await findPort()
const app = await launchApp(appDir, appPort)
@ -21,11 +22,13 @@ describe('Catches Missing getStaticProps', () => {
expect(html).toMatch(errorRegex)
})
})
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should catch it in server build mode', async () => {
const { stderr } = await nextBuild(appDir, [], {
stderr: true,
})
expect(stderr).toMatch(errorRegex)
})
})
})

View file

@ -80,6 +80,7 @@ const testExitSignal = async (
}
describe('CLI Usage', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
describe('start', () => {
test('should exit when SIGINT is signalled', async () => {
require('console').log('before build')
@ -277,6 +278,40 @@ describe('CLI Usage', () => {
})
})
describe('telemetry', () => {
test('--help', async () => {
const help = await runNextCommand(['telemetry', '--help'], {
stdout: true,
})
expect(help.stdout).toMatch(
/Allows you to control Next\.js' telemetry collection/
)
})
test('-h', async () => {
const help = await runNextCommand(['telemetry', '-h'], {
stdout: true,
})
expect(help.stdout).toMatch(
/Allows you to control Next\.js' telemetry collection/
)
})
test('should warn when unknown argument provided', async () => {
const { stderr } = await runNextCommand(['telemetry', '--random'], {
stderr: true,
})
expect(stderr).toEqual('Unknown or unexpected option: --random\n')
})
test('should not throw UnhandledPromiseRejectionWarning', async () => {
const { stderr } = await runNextCommand(['telemetry', '--random'], {
stderr: true,
})
expect(stderr).not.toContain('UnhandledPromiseRejectionWarning')
})
})
})
describe('no command', () => {
test('--help', async () => {
const help = await runNextCommand(['--help'], {
@ -755,39 +790,6 @@ describe('CLI Usage', () => {
})
})
describe('telemetry', () => {
test('--help', async () => {
const help = await runNextCommand(['telemetry', '--help'], {
stdout: true,
})
expect(help.stdout).toMatch(
/Allows you to control Next\.js' telemetry collection/
)
})
test('-h', async () => {
const help = await runNextCommand(['telemetry', '-h'], {
stdout: true,
})
expect(help.stdout).toMatch(
/Allows you to control Next\.js' telemetry collection/
)
})
test('should warn when unknown argument provided', async () => {
const { stderr } = await runNextCommand(['telemetry', '--random'], {
stderr: true,
})
expect(stderr).toEqual('Unknown or unexpected option: --random\n')
})
test('should not throw UnhandledPromiseRejectionWarning', async () => {
const { stderr } = await runNextCommand(['telemetry', '--random'], {
stderr: true,
})
expect(stderr).not.toContain('UnhandledPromiseRejectionWarning')
})
})
describe('info', () => {
function matchInfoOutput(stdout, { nextConfigOutput = '.*' } = {}) {
expect(stdout).toMatch(

View file

@ -7,6 +7,7 @@ import { nextBuild } from 'next-test-utils'
const appDir = join(__dirname, '..')
describe('Promise in next config', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
afterEach(() => fs.remove(join(appDir, 'next.config.js')))
it('should warn when a promise is returned on webpack', async () => {
@ -31,4 +32,5 @@ describe('Promise in next config', () => {
/> Promise returned in next config\. https:\/\//
)
})
})
})

View file

@ -8,6 +8,7 @@ const nextConfigJS = join(appDir, 'next.config.js')
const nextConfigMJS = join(appDir, 'next.config.mjs')
describe('Invalid config syntax', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should error when next.config.js contains syntax error', async () => {
await fs.writeFile(
nextConfigJS,
@ -48,4 +49,5 @@ describe('Invalid config syntax', () => {
)
expect(stderr).toContain('SyntaxError')
})
})
})

View file

@ -5,6 +5,7 @@ import fs from 'fs-extra'
const nextConfigPath = path.join(__dirname, '../next.config.js')
describe('next.config.js validation', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it.each([
{
name: 'invalid config types',
@ -53,4 +54,5 @@ describe('next.config.js validation', () => {
}
}
)
})
})

View file

@ -12,6 +12,7 @@ import {
const appDir = path.join(__dirname, '..')
describe('Errors on conflict between public file and page file', () => {
describe('development mode', () => {
it('Throws error during development', async () => {
const appPort = await findPort()
const app = await launchApp(appDir, appPort)
@ -25,10 +26,14 @@ describe('Errors on conflict between public file and page file', () => {
}
await killApp(app)
})
})
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('Throws error during build', async () => {
const conflicts = ['/another/conflict', '/another', '/hello']
const results = await nextBuild(appDir, [], { stdout: true, stderr: true })
const results = await nextBuild(appDir, [], {
stdout: true,
stderr: true,
})
const output = results.stdout + results.stderr
expect(output).toMatch(/Conflicting public and page files were found/)
@ -36,4 +41,5 @@ describe('Errors on conflict between public file and page file', () => {
expect(output.indexOf(conflict) > 0).toBe(true)
}
})
})
})

View file

@ -8,6 +8,7 @@ const appDir = join(__dirname, '../')
const pagesDir = join(appDir, 'pages')
describe('Conflicting SSG paths', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
afterEach(() => fs.remove(pagesDir))
it('should show proper error when two dynamic SSG routes have conflicting paths', async () => {
@ -184,4 +185,5 @@ describe('Conflicting SSG paths', () => {
`path: "/hellO/world" from page: "/[...catchAll]" conflicts with path: "/hello/world"`
)
})
})
})

View file

@ -57,6 +57,7 @@ function runTests() {
}
describe('CSS optimization for SSR apps', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await fs.writeFile(
nextConfig,
@ -76,4 +77,5 @@ describe('CSS optimization for SSR apps', () => {
await fs.remove(nextConfig)
})
runTests()
})
})

View file

@ -28,6 +28,7 @@ function runTests() {
}
describe('css-minify', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
@ -37,4 +38,5 @@ describe('css-minify', () => {
await killApp(app)
})
runTests()
})
})

View file

@ -243,6 +243,7 @@ describe('Can hot reload CSS Module without losing state', () => {
})
describe.skip('Invalid CSS Module Usage in node_modules', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'invalid-module')
beforeAll(async () => {
@ -259,11 +260,15 @@ describe.skip('Invalid CSS Module Usage in node_modules', () => {
expect(stderr).toMatch(
/CSS Modules.*cannot.*be imported from within.*node_modules/
)
expect(stderr).toMatch(/Location:.*node_modules[\\/]example[\\/]index\.mjs/)
expect(stderr).toMatch(
/Location:.*node_modules[\\/]example[\\/]index\.mjs/
)
})
})
})
describe.skip('Invalid Global CSS Module Usage in node_modules', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'invalid-global-module')
beforeAll(async () => {
@ -280,7 +285,10 @@ describe.skip('Invalid Global CSS Module Usage in node_modules', () => {
expect(stderr).toMatch(
/Global CSS.*cannot.*be imported from within.*node_modules/
)
expect(stderr).toMatch(/Location:.*node_modules[\\/]example[\\/]index\.mjs/)
expect(stderr).toMatch(
/Location:.*node_modules[\\/]example[\\/]index\.mjs/
)
})
})
})

View file

@ -38,6 +38,7 @@ describe('Ordering with styled-jsx (dev)', () => {
})
describe('Ordering with styled-jsx (prod)', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'with-styled-jsx')
let appPort
@ -69,4 +70,5 @@ describe('Ordering with styled-jsx (prod)', () => {
)
expect(currentColor).toMatchInlineSnapshot(`"rgb(0, 128, 0)"`)
})
})
})

View file

@ -15,6 +15,7 @@ import { join } from 'path'
const fixturesDir = join(__dirname, '../..', 'css-fixtures')
describe('CSS Support', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
describe('CSS Compilation and Prefixing', () => {
const appDir = join(fixturesDir, 'compilation-and-prefixing')
@ -175,7 +176,9 @@ describe('CSS Support', () => {
const cssPreload = $('link[rel="preload"][as="style"]')
expect(cssPreload.length).toBe(1)
expect(cssPreload.attr('href')).toMatch(/^\/_next\/static\/css\/.*\.css$/)
expect(cssPreload.attr('href')).toMatch(
/^\/_next\/static\/css\/.*\.css$/
)
const cssSheet = $('link[rel="stylesheet"]')
expect(cssSheet.length).toBe(1)
@ -213,7 +216,9 @@ describe('CSS Support', () => {
expect(cssFiles.length).toBe(1)
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8')
expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatch(/nprogress/)
expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatch(
/nprogress/
)
})
})
@ -245,10 +250,12 @@ describe('CSS Support', () => {
).toMatchInlineSnapshot(`".other{color:blue}.test{color:red}"`)
})
})
})
})
// https://github.com/vercel/next.js/issues/15468
describe('CSS Property Ordering', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'next-issue-15468')
let appPort
@ -285,4 +292,5 @@ describe('CSS Property Ordering', () => {
)
expect(width2).toMatchInlineSnapshot(`"5px"`)
})
})
})

View file

@ -15,6 +15,7 @@ import { join } from 'path'
const fixturesDir = join(__dirname, '../..', 'css-fixtures')
describe('CSS Support', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
describe('CSS Import from node_modules', () => {
const appDir = join(fixturesDir, 'npm-import-bad')
@ -30,6 +31,7 @@ describe('CSS Support', () => {
expect(stderr).not.toMatch(/Build error occurred/)
})
})
})
// https://github.com/vercel/next.js/issues/18557
describe('CSS page transition inject <style> with nonce so it works with CSP header', () => {

View file

@ -11,6 +11,7 @@ let app
// TODO: re-enable with React 18
describe.skip('Custom error page exception', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir, undefined, {
nodeArgs,
@ -31,4 +32,5 @@ describe.skip('Custom error page exception', () => {
/Application error: a client-side exception has occurred/
)
})
})
})

View file

@ -143,6 +143,9 @@ describe.skip.each([
})
describe('with generateEtags enabled', () => {
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
beforeAll(async () => {
await nextBuild(appDir)
await startServer({ GENERATE_ETAGS: 'true', NODE_ENV: 'production' })
@ -150,9 +153,13 @@ describe.skip.each([
afterAll(() => killApp(server))
it('response includes etag header', async () => {
const response = await fetchViaHTTP(nextUrl, '/', undefined, { agent })
const response = await fetchViaHTTP(nextUrl, '/', undefined, {
agent,
})
expect(response.headers.get('etag')).toBeTruthy()
})
}
)
})
describe('with generateEtags disabled', () => {
@ -222,7 +229,9 @@ describe.skip.each([
expect(html).toContain('made it to dashboard')
expect(stderr).toContain('Cannot render page with path "dashboard"')
})
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
it('should warn in production mode', async () => {
const { code } = await nextBuild(appDir)
expect(code).toBe(0)
@ -244,6 +253,8 @@ describe.skip.each([
expect(html).toContain('made it to dashboard')
expect(stderr).toContain('Cannot render page with path "dashboard"')
})
}
)
})
describe('compression handling', function () {

View file

@ -132,12 +132,9 @@ describe('GS(S)P Page Errors', () => {
describe('dev mode', () => {
runTests(true)
})
describe('build mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
runTests()
})
describe('start mode', () => {
it('Error stack printed to stderr', async () => {
try {
await fs.writeFile(

View file

@ -15,6 +15,7 @@ let appPort
let app
describe('De-dedupes scripts in _document', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
appPort = await findPort()
await nextBuild(appDir)
@ -39,4 +40,5 @@ describe('De-dedupes scripts in _document', () => {
}
expect(foundDuplicate).toBe(false)
})
})
})

View file

@ -19,6 +19,9 @@ let app
describe('distDir', () => {
describe('With basic usage', () => {
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
beforeAll(async () => {
await fs.remove(join(appDir, '.next'))
await fs.remove(join(appDir, 'dist'))
@ -41,6 +44,8 @@ describe('distDir', () => {
it('should not build the app within the default `.next` directory', async () => {
expect(await fs.exists(join(__dirname, '/../.next'))).toBeFalsy()
})
}
)
})
describe('dev mode', () => {
@ -66,7 +71,7 @@ describe('distDir', () => {
expect(await fs.exists(join(__dirname, '/../.next'))).toBeFalsy()
})
})
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should throw error with invalid distDir', async () => {
const origNextConfig = await fs.readFile(nextConfig, 'utf8')
await fs.writeFile(nextConfig, `module.exports = { distDir: '' }`)
@ -89,4 +94,5 @@ describe('distDir', () => {
expect(stderr.length).toBe(0)
})
})
})

View file

@ -82,8 +82,13 @@ describe('Edge runtime code with imports', () => {
beforeEach(() => init(importStatement))
describe('development mode', () => {
it('throws unsupported module error in dev at runtime and highlights the faulty line', async () => {
context.app = await launchApp(context.appDir, context.appPort, appOption)
context.app = await launchApp(
context.appDir,
context.appPort,
appOption
)
const res = await fetchViaHTTP(context.appPort, url)
expect(res.status).toBe(500)
await check(async () => {
@ -95,17 +100,26 @@ describe('Edge runtime code with imports', () => {
return 'success'
}, 'success')
})
})
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
it('throws unsupported module error in production at runtime and prints error on logs', async () => {
const { stderr } = await nextBuild(context.appDir, undefined, {
stderr: true,
})
expect(stderr).toContain(getUnsupportedModuleWarning(moduleName))
context.app = await nextStart(context.appDir, context.appPort, appOption)
context.app = await nextStart(
context.appDir,
context.appPort,
appOption
)
const res = await fetchViaHTTP(context.appPort, url)
expect(res.status).toBe(500)
expectUnsupportedModuleProdError(moduleName)
})
}
)
})
describe.each([
@ -154,6 +168,7 @@ describe('Edge runtime code with imports', () => {
`)
})
describe('development mode', () => {
it('throws unsupported module error in dev at runtime and highlights the faulty line', async () => {
context.app = await launchApp(
context.appDir,
@ -171,7 +186,10 @@ describe('Edge runtime code with imports', () => {
return 'success'
}, 'success')
})
})
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
it('throws unsupported module error in production at runtime and prints error on logs', async () => {
const { stderr } = await nextBuild(context.appDir, undefined, {
stderr: true,
@ -188,6 +206,8 @@ describe('Edge runtime code with imports', () => {
})
}
)
}
)
describe.each([
{
@ -241,7 +261,9 @@ describe('Edge runtime code with imports', () => {
return 'success'
}, 'success')
})
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
it('does not build and reports', async () => {
const { code, stderr } = await nextBuild(context.appDir, undefined, {
ignoreFail: true,
@ -251,6 +273,8 @@ describe('Edge runtime code with imports', () => {
expect(code).toEqual(1)
expectModuleNotFoundProdError(moduleName, stderr)
})
}
)
})
describe.each([
@ -299,18 +323,26 @@ describe('Edge runtime code with imports', () => {
expect(res.headers.get('x-from-runtime')).toBeDefined()
expectNoError(moduleName)
})
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
it('does not throw in production at runtime', async () => {
const { stderr } = await nextBuild(context.appDir, undefined, {
stderr: true,
})
expect(stderr).not.toContain(getUnsupportedModuleWarning(moduleName))
context.app = await nextStart(context.appDir, context.appPort, appOption)
context.app = await nextStart(
context.appDir,
context.appPort,
appOption
)
const res = await fetchViaHTTP(context.appPort, url)
expect(res.status).toBe(200)
expect(res.headers.get('x-from-runtime')).toBeDefined()
expectNoError(moduleName)
})
}
)
})
describe.each([
@ -360,14 +392,22 @@ describe('Edge runtime code with imports', () => {
expect(res.headers.get('x-from-runtime')).toBe('false')
expectNoError(moduleName)
})
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
it('does not throw in production at runtime', async () => {
await nextBuild(context.appDir, undefined, { stderr: true })
context.app = await nextStart(context.appDir, context.appPort, appOption)
context.app = await nextStart(
context.appDir,
context.appPort,
appOption
)
const res = await fetchViaHTTP(context.appPort, url)
expect(res.status).toBe(200)
expect(res.headers.get('x-from-runtime')).toBe('false')
expectNoError(moduleName)
})
}
)
})
})

View file

@ -95,17 +95,25 @@ describe('Edge runtime code with imports', () => {
return 'success'
}, 'success')
})
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
it('throws unsupported module error in production at runtime and prints error on logs', async () => {
const { stderr } = await nextBuild(context.appDir, undefined, {
stderr: true,
})
expect(stderr).toContain(getUnsupportedModuleWarning(moduleName))
context.app = await nextStart(context.appDir, context.appPort, appOption)
context.app = await nextStart(
context.appDir,
context.appPort,
appOption
)
const res = await fetchViaHTTP(context.appPort, url)
expect(res.status).toBe(500)
expectUnsupportedModuleProdError(moduleName)
})
}
)
})
describe.each([
@ -157,7 +165,9 @@ describe('Edge runtime code with imports', () => {
return 'success'
}, 'success')
})
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
it('does not build and reports module not found error', async () => {
const { code, stderr } = await nextBuild(context.appDir, undefined, {
ignoreFail: true,
@ -167,6 +177,8 @@ describe('Edge runtime code with imports', () => {
expect(code).toEqual(1)
expectModuleNotFoundProdError(moduleName, stderr)
})
}
)
})
describe.each([
@ -221,7 +233,9 @@ describe('Edge runtime code with imports', () => {
return 'success'
}, 'success')
})
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
it('does not build and reports module not found error', async () => {
const { code, stderr } = await nextBuild(context.appDir, undefined, {
ignoreFail: true,
@ -232,6 +246,8 @@ describe('Edge runtime code with imports', () => {
expectModuleNotFoundProdError(moduleName, stderr)
})
}
)
})
describe.each([
@ -279,16 +295,24 @@ describe('Edge runtime code with imports', () => {
expect(res.status).toBe(200)
expectNoError(moduleName)
})
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
it('does not throw in production at runtime', async () => {
const { stderr } = await nextBuild(context.appDir, undefined, {
stderr: true,
})
expect(stderr).toContain(getUnsupportedModuleWarning(moduleName))
context.app = await nextStart(context.appDir, context.appPort, appOption)
context.app = await nextStart(
context.appDir,
context.appPort,
appOption
)
const res = await fetchViaHTTP(context.appPort, url)
expect(res.status).toBe(200)
expectNoError(moduleName)
})
}
)
})
})

View file

@ -72,17 +72,25 @@ describe('Edge runtime code with imports', () => {
)
expect(res.status).toBe(500)
})
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
it(`${title} build test Response`, async () => {
await nextBuild(context.appDir, undefined, {
stderr: true,
})
context.app = await nextStart(context.appDir, context.appPort, appOption)
context.app = await nextStart(
context.appDir,
context.appPort,
appOption
)
const res = await fetchViaHTTP(context.appPort, url)
expect(context.logs.stderr).toContain(
'Expected an instance of Response to be returned'
)
expect(res.status).toBe(500)
})
}
)
})
})

View file

@ -16,6 +16,7 @@ let app
let port
describe('Handles an Error in _error', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
port = await findPort()
@ -35,4 +36,5 @@ describe('Handles an Error in _error', () => {
const html = await browser.eval('document.body.innerHTML')
expect(html).toMatch(/Internal Server Error/i)
})
})
})

View file

@ -16,6 +16,7 @@ const appDir = join(__dirname, '..')
let app
describe('Failing to load _error', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
afterAll(() => killApp(app))
it('handles failing to load _error correctly', async () => {
@ -60,4 +61,5 @@ describe('Failing to load _error', () => {
: 'fail'
}, /reloaded/)
})
})
})

View file

@ -8,9 +8,13 @@ const appDir = path.join(__dirname, '..')
const nextConfig = path.join(appDir, 'next.config.js')
describe('Errors on output to public', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('Throws error when `distDir` is set to public', async () => {
await fs.writeFile(nextConfig, `module.exports = { distDir: 'public' }`)
const results = await nextBuild(appDir, [], { stdout: true, stderr: true })
const results = await nextBuild(appDir, [], {
stdout: true,
stderr: true,
})
expect(results.stdout + results.stderr).toMatch(
/The 'public' directory is reserved in Next\.js and can not be set as/
)
@ -33,4 +37,5 @@ describe('Errors on output to public', () => {
/The 'public' directory is reserved in Next\.js and can not be used as/
)
})
})
})

View file

@ -8,6 +8,7 @@ const appDir = path.join(__dirname, '..')
const nextConfig = path.join(appDir, 'next.config.js')
describe('Errors on output to static', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('Throws error when export out dir is static', async () => {
await fs.remove(nextConfig)
await nextBuild(appDir)
@ -24,4 +25,5 @@ describe('Errors on output to static', () => {
/The 'static' directory is reserved in Next\.js and can not be used as/
)
})
})
})

View file

@ -40,6 +40,7 @@ const mjsCjsLinting = join(__dirname, '../mjs-cjs-linting')
const dirTypescript = join(__dirname, '../with-typescript')
describe('Next Build', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
test('first time setup', async () => {
const eslintrcJson = join(dirFirstTimeSetup, '.eslintrc.json')
await fs.writeFile(eslintrcJson, '')
@ -62,7 +63,9 @@ describe('Next Build', () => {
})
const output = stdout + stderr
expect(output).toContain('Warning: Synchronous scripts should not be used.')
expect(output).toContain(
'Warning: Synchronous scripts should not be used.'
)
expect(output).toContain(
'Error: Comments inside children section of tag should be placed inside braces'
)
@ -97,7 +100,9 @@ describe('Next Build', () => {
'Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images.'
)
expect(output).toContain('Warning: Do not include stylesheets manually')
expect(output).toContain('Warning: Synchronous scripts should not be used')
expect(output).toContain(
'Warning: Synchronous scripts should not be used'
)
expect(output).toContain(
'Warning: `rel="preconnect"` is missing from Google Font'
)
@ -121,7 +126,9 @@ describe('Next Build', () => {
expect(output).toContain(
'Error: Comments inside children section of tag should be placed inside braces'
)
expect(output).toContain('Warning: Synchronous scripts should not be used.')
expect(output).toContain(
'Warning: Synchronous scripts should not be used.'
)
})
test('invalid older eslint version', async () => {
@ -149,7 +156,9 @@ describe('Next Build', () => {
const output = stdout + stderr
expect(output).not.toContain('Build error occurred')
expect(output).not.toContain('NoFilesFoundError')
expect(output).toContain('Warning: Synchronous scripts should not be used.')
expect(output).toContain(
'Warning: Synchronous scripts should not be used.'
)
expect(output).toContain('Compiled successfully')
})
@ -162,7 +171,9 @@ describe('Next Build', () => {
const output = stdout + stderr
expect(output).not.toContain('Build error occurred')
expect(output).not.toContain('AllFilesIgnoredError')
expect(output).toContain('Warning: Synchronous scripts should not be used.')
expect(output).toContain(
'Warning: Synchronous scripts should not be used.'
)
expect(output).toContain('Compiled successfully')
})
@ -206,4 +217,5 @@ describe('Next Build', () => {
expect(cacheExists).toBe(true)
})
})
})

View file

@ -19,6 +19,7 @@ const fileExist = (path) =>
// Issue #36855
// https://github.com/vercel/next.js/issues/36855
describe('Static 404 Export', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('only export 404.html when trailingSlash: false', async () => {
await nextBuild(appDir)
await nextExport(appDir, { outdir })
@ -38,9 +39,11 @@ describe('Static 404 Export', () => {
expect(await fileExist(join(outdir, '404.html.html'))).toBe(false)
expect(await fileExist(join(outdir, '404.html'))).toBe(true)
})
})
})
describe('Export with a page named 404.js', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should export a custom 404.html instead of default 404.html', async () => {
await nextBuild(appDir)
await nextExport(appDir, { outdir })
@ -48,4 +51,5 @@ describe('Export with a page named 404.js', () => {
const html = await readFile(join(outdir, '404.html'), 'utf8')
expect(html).toMatch(/this is a 404 page override the default 404\.html/)
})
})
})

View file

@ -10,6 +10,7 @@ const appDir = join(__dirname, '../')
const outdir = join(appDir, 'out')
describe('Export with default map', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
await nextExport(appDir, { outdir })
@ -28,13 +29,17 @@ describe('Export with default map', () => {
it('should export hybrid amp page correctly', async () => {
expect.assertions(2)
await expect(access(join(outdir, 'some.html'))).resolves.toBe(undefined)
await expect(access(join(outdir, 'some.amp.html'))).resolves.toBe(undefined)
await expect(access(join(outdir, 'some.amp.html'))).resolves.toBe(
undefined
)
})
it('should export nested hybrid amp page correctly', async () => {
expect.assertions(3)
await expect(access(join(outdir, 'docs.html'))).resolves.toBe(undefined)
await expect(access(join(outdir, 'docs.amp.html'))).resolves.toBe(undefined)
await expect(access(join(outdir, 'docs.amp.html'))).resolves.toBe(
undefined
)
const html = await readFile(join(outdir, 'docs.html'))
const $ = cheerio.load(html)
@ -44,7 +49,9 @@ describe('Export with default map', () => {
it('should export nested hybrid amp page correctly with folder', async () => {
expect.assertions(3)
await expect(access(join(outdir, 'info.html'))).resolves.toBe(undefined)
await expect(access(join(outdir, 'info.amp.html'))).resolves.toBe(undefined)
await expect(access(join(outdir, 'info.amp.html'))).resolves.toBe(
undefined
)
const html = await readFile(join(outdir, 'info.html'))
const $ = cheerio.load(html)
@ -62,4 +69,5 @@ describe('Export with default map', () => {
const $ = cheerio.load(html)
expect($('link[rel=amphtml]').attr('href')).toBe('/index.amp')
})
})
})

View file

@ -14,9 +14,8 @@ import {
const appDir = join(__dirname, '../')
const outdir = join(appDir, 'out')
;(process.env.TURBOPACK ? describe.skip : describe)(
'Export Dynamic Pages',
() => {
describe('Export Dynamic Pages', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
let server
let port
beforeAll(async () => {
@ -48,5 +47,5 @@ const outdir = join(appDir, 'out')
await browser.close()
}
})
}
)
})
})

View file

@ -8,6 +8,7 @@ const appDir = join(__dirname, '../')
const outdir = join(appDir, 'out')
describe('Export error for fallback: true', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should build successfully', async () => {
await fs.remove(join(appDir, '.next'))
const { code } = await nextBuild(appDir)
@ -22,4 +23,5 @@ describe('Export error for fallback: true', () => {
)
expect(stderr).toContain('/[slug]')
})
})
})

View file

@ -7,6 +7,7 @@ const appDir = join(__dirname, '../')
const outdir = join(appDir, 'out')
describe('Export with getInitialProps', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should show warning with next export', async () => {
await nextBuild(appDir)
const { stderr } = await nextExport(appDir, { outdir }, { stderr: true })
@ -14,4 +15,5 @@ describe('Export with getInitialProps', () => {
'https://nextjs.org/docs/messages/get-initial-props-export'
)
})
})
})

View file

@ -8,6 +8,7 @@ const appDir = join(__dirname, '../')
const outdir = join(appDir, 'out')
describe('Export with default loader next/image component', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should build successfully', async () => {
await fs.remove(join(appDir, '.next'))
const { code } = await nextBuild(appDir)
@ -20,4 +21,5 @@ describe('Export with default loader next/image component', () => {
'Image Optimization using the default loader is not compatible with export.'
)
})
})
})

View file

@ -11,6 +11,7 @@ const nextConfig = new File(join(appDir, 'next.config.js'))
const pagesIndexJs = new File(join(appDir, 'pages', 'index.js'))
describe('Export with cloudinary loader next/legacy/image component', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextConfig.replace(
'{ /* replaceme */ }',
@ -42,9 +43,11 @@ describe('Export with cloudinary loader next/legacy/image component', () => {
afterAll(async () => {
await nextConfig.restore()
})
})
})
describe('Export with custom loader next/legacy/image component', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextConfig.replace(
'{ /* replaceme */ }',
@ -80,9 +83,11 @@ describe('Export with custom loader next/legacy/image component', () => {
await nextConfig.restore()
await pagesIndexJs.restore()
})
})
})
describe('Export with custom loader config but no loader prop on next/legacy/image', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextConfig.replace(
'{ /* replaceme */ }',
@ -106,9 +111,11 @@ describe('Export with custom loader config but no loader prop on next/legacy/ima
await nextConfig.restore()
await pagesIndexJs.restore()
})
})
})
describe('Export with unoptimized next/legacy/image component', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextConfig.replace(
'{ /* replaceme */ }',
@ -139,4 +146,5 @@ describe('Export with unoptimized next/legacy/image component', () => {
afterAll(async () => {
await nextConfig.restore()
})
})
})

View file

@ -8,6 +8,7 @@ const appDir = join(__dirname, '../')
const outdir = join(appDir, 'out')
describe('Export index page with `notFound: true` in `getStaticProps`', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should build successfully', async () => {
await fs.remove(join(appDir, '.next'))
const { code } = await nextBuild(appDir)
@ -18,4 +19,5 @@ describe('Export index page with `notFound: true` in `getStaticProps`', () => {
const { code } = await nextExport(appDir, { outdir })
if (code !== 0) throw new Error(`export failed with status ${code}`)
})
})
})

View file

@ -6,6 +6,7 @@ import { nextBuild, nextExportDefault } from 'next-test-utils'
const appDir = join(__dirname, '../')
describe('Export cli prints progress info', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
let buildStdout
let exportStdout
beforeAll(async () => {
@ -32,4 +33,5 @@ describe('Export cli prints progress info', () => {
expect(found).toBeTruthy()
})
})
})

View file

@ -10,6 +10,7 @@ const appDir = join(__dirname, '../')
const outdir = join(appDir, 'out')
describe('Export config#exportTrailingSlash set to false', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
await nextExport(appDir, { outdir })
@ -33,4 +34,5 @@ describe('Export config#exportTrailingSlash set to false', () => {
const $single = cheerio.load(htmlSingle)
expect($single('p').text()).toBe('I am a single post')
})
})
})

View file

@ -7,6 +7,7 @@ import { nextBuild } from 'next-test-utils'
const appDir = join(__dirname, '../')
describe('bundle pages externals with config.experimental.bundlePagesExternals', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should have no externals with the config set', async () => {
await nextBuild(appDir, [], { stdout: true })
const output = await fs.readFile(
@ -15,4 +16,5 @@ describe('bundle pages externals with config.experimental.bundlePagesExternals',
)
expect(output).not.toContain('require("external-package")')
})
})
})

View file

@ -7,7 +7,8 @@ import { join } from 'path'
const fixturesDir = join(__dirname, '..', 'fixtures')
describe('Build Output', () => {
describe('Fallback Modules', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
describe('Crypto Application', () => {
let stdout
const appDir = join(fixturesDir, 'with-crypto')
@ -51,4 +52,5 @@ describe('Build Output', () => {
expect(indexFirstLoad.endsWith('kB')).toBe(true)
})
})
})
})

View file

@ -51,7 +51,7 @@ function runTests() {
}
describe('Fetch polyfill with ky-universal', () => {
describe('dev support', () => {
describe('development mode', () => {
beforeAll(async () => {
appPort = await findPort()
await startApiServer()
@ -68,8 +68,7 @@ describe('Fetch polyfill with ky-universal', () => {
runTests()
})
describe('Server support', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await startApiServer()
await nextBuild(appDir, [], {

View file

@ -70,7 +70,7 @@ function runTests() {
}
describe('Fetch polyfill', () => {
describe('dev support', () => {
describe('development mode', () => {
beforeAll(async () => {
appPort = await findPort()
await startApiServer()
@ -87,8 +87,7 @@ describe('Fetch polyfill', () => {
runTests()
})
describe('Server support', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await startApiServer()
await nextBuild(appDir, [], {

View file

@ -8,13 +8,17 @@ const appDir = path.join(__dirname, '..')
const nextConfig = path.join(appDir, 'next.config.js')
describe('Building Firebase', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
// TODO: investigate re-enabling this test in node 12 environment
it.skip('Throws an error when building with firebase dependency with worker_threads', async () => {
await fs.writeFile(
nextConfig,
`module.exports = { experimental: { workerThreads: true } }`
)
const results = await nextBuild(appDir, [], { stdout: true, stderr: true })
const results = await nextBuild(appDir, [], {
stdout: true,
stderr: true,
})
expect(results.stdout + results.stderr).toMatch(/Build error occurred/)
expect(results.stdout + results.stderr).toMatch(
/grpc_node\.node\. Module did not self-register\./
@ -23,10 +27,16 @@ describe('Building Firebase', () => {
it('Throws no error when building with firebase dependency without worker_threads', async () => {
await fs.remove(nextConfig)
const results = await nextBuild(appDir, [], { stdout: true, stderr: true })
expect(results.stdout + results.stderr).not.toMatch(/Build error occurred/)
const results = await nextBuild(appDir, [], {
stdout: true,
stderr: true,
})
expect(results.stdout + results.stderr).not.toMatch(
/Build error occurred/
)
expect(results.stdout + results.stderr).not.toMatch(
/grpc_node\.node\. Module did not self-register\./
)
})
})
})

View file

@ -15,6 +15,7 @@ let appPort
let app
describe('excludeDefaultMomentLocales', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
appPort = await findPort()
await nextBuild(appDir)
@ -31,4 +32,5 @@ describe('excludeDefaultMomentLocales', () => {
expect(locales.length).toBe(1)
await browser.close()
})
})
})

View file

@ -18,6 +18,7 @@ let app
const fileNames = ['1', '2.ext', '3.html']
describe('GS(S)P with file extension', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await fs.remove(join(appDir, '.next'))
const { code } = await nextBuild(appDir)
@ -55,4 +56,5 @@ describe('GS(S)P with file extension', () => {
expect(result.pageProps.value).toBe(fileNames[i])
)
})
})
})

View file

@ -499,7 +499,6 @@ describe('GS(S)P Redirect Support', () => {
afterAll(() => killApp(app))
runTests()
})
it('should error for redirect during prerendering', async () => {
await fs.mkdirp(join(appDir, 'pages/invalid'))
@ -538,4 +537,5 @@ describe('GS(S)P Redirect Support', () => {
'`redirect` can not be returned from getStaticProps during prerendering'
)
})
})
})

View file

@ -537,7 +537,6 @@ describe('GS(S)P Redirect Support', () => {
it('should not have errors in output', async () => {
expect(output).not.toContain('Failed to update prerender files')
})
})
it('should error for redirect during prerendering', async () => {
await fs.mkdirp(join(appDir, 'pages/invalid'))
@ -576,4 +575,5 @@ describe('GS(S)P Redirect Support', () => {
'`redirect` can not be returned from getStaticProps during prerendering'
)
})
})
})

View file

@ -6,6 +6,7 @@ import { nextBuild } from 'next-test-utils'
const appDir = path.join(__dirname, '..')
describe('Handles Errors During Export', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('Does not crash workers', async () => {
const { stdout, stderr } = await nextBuild(appDir, [], {
stdout: true,
@ -24,4 +25,5 @@ describe('Handles Errors During Export', () => {
expect(stderr).toContain('/custom-error')
expect(stderr).toContain('custom error message')
})
})
})

View file

@ -9,6 +9,7 @@ let appPort
let server
describe('hydrate/render ordering', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
appPort = await findPort()
await nextBuild(appDir, [], {})
@ -33,4 +34,5 @@ describe('hydrate/render ordering', () => {
await browser.close()
})
})
})

View file

@ -78,6 +78,9 @@ describe('i18n Support basePath', () => {
})
describe('with localeDetection disabled', () => {
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
beforeAll(async () => {
await fs.remove(join(appDir, '.next'))
nextConfig.replace('// localeDetection', 'localeDetection')
@ -173,5 +176,7 @@ describe('i18n Support basePath', () => {
expect($('#router-as-path').text()).toBe('/')
}
})
}
)
})
})

View file

@ -88,6 +88,9 @@ describe('i18n Support', () => {
})
describe('with localeDetection disabled', () => {
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
beforeAll(async () => {
await fs.remove(join(appDir, '.next'))
nextConfig.replace('// localeDetection', 'localeDetection')
@ -205,6 +208,8 @@ describe('i18n Support', () => {
expect($('#router-as-path').text()).toBe('/')
}
})
}
)
})
describe('with trailingSlash: true', () => {
@ -520,7 +525,7 @@ describe('i18n Support', () => {
}
)
})
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should show proper error for duplicate defaultLocales', async () => {
nextConfig.write(`
module.exports = {
@ -601,4 +606,5 @@ describe('i18n Support', () => {
`i18n domain: "hello:3000" is invalid it should be a valid domain without protocol (https://) or port (:3000) e.g. example.vercel.sh`
)
})
})
})

View file

@ -483,6 +483,9 @@ describe('Image Optimizer', () => {
})
describe('Server support for headers in next.config.js', () => {
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
const size = 96 // defaults defined in server/config.ts
let app
let appPort
@ -536,7 +539,9 @@ describe('Image Optimizer', () => {
Object.keys(files).forEach((dir) => {
if (
Object.keys(files[dir]).some((file) => file.includes(`${maxAge}.`))
Object.keys(files[dir]).some((file) =>
file.includes(`${maxAge}.`)
)
) {
found = true
}
@ -557,6 +562,8 @@ describe('Image Optimizer', () => {
`inline; filename="test.webp"`
)
})
}
)
})
describe('dev support next.config.js cloudinary loader', () => {
@ -619,6 +626,9 @@ describe('Image Optimizer', () => {
})
describe('External rewrite support with for serving static content in images', () => {
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
let app
let appPort
@ -668,7 +678,9 @@ describe('Image Optimizer', () => {
Object.keys(files).forEach((dir) => {
if (
Object.keys(files[dir]).some((file) => file.includes(`${maxAge}.`))
Object.keys(files[dir]).some((file) =>
file.includes(`${maxAge}.`)
)
) {
found = true
}
@ -677,6 +689,8 @@ describe('Image Optimizer', () => {
}, 'success')
await expectWidth(res, 64)
})
}
)
})
describe('dev support for dynamic blur placeholder', () => {

View file

@ -10,6 +10,7 @@ const nextConfigPath = join(appDir, 'next.config.js')
const cleanUp = () => fs.remove(nextConfigPath)
describe('Handles valid/invalid assetPrefix', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(() => cleanUp())
afterAll(() => cleanUp())
@ -35,4 +36,5 @@ describe('Handles valid/invalid assetPrefix', () => {
const { stderr } = await nextBuild(appDir, undefined, { stderr: true })
expect(stderr).not.toMatch(/Specified assetPrefix is not a string/)
})
})
})

View file

@ -8,6 +8,7 @@ const appDir = join(__dirname, '../')
const nextConfig = new File(join(appDir, 'next.config.js'))
describe('Invalid static image import in _document', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
afterAll(() => nextConfig.restore())
it('Should fail to build when no next.config.js', async () => {
@ -41,4 +42,5 @@ describe('Invalid static image import in _document', () => {
/Images.*cannot.*be imported within.*pages[\\/]_document\.js/
)
})
})
})

View file

@ -7,6 +7,7 @@ import { nextBuild } from 'next-test-utils'
const appDir = path.join(__dirname, '..')
describe('Invalid Page automatic static optimization', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('Fails softly with descriptive error', async () => {
const { stderr } = await nextBuild(appDir, [], { stderr: true })
@ -19,7 +20,10 @@ describe('Invalid Page automatic static optimization', () => {
it('handles non-error correctly', async () => {
const testPage = path.join(appDir, 'pages/[slug].js')
await fs.rename(path.join(appDir, 'pages'), path.join(appDir, 'pages-bak'))
await fs.rename(
path.join(appDir, 'pages'),
path.join(appDir, 'pages-bak')
)
await fs.ensureDir(path.join(appDir, 'pages'))
await fs.writeFile(
@ -55,4 +59,5 @@ describe('Invalid Page automatic static optimization', () => {
)
}
})
})
})

View file

@ -65,6 +65,9 @@ describe('TypeScript Features', () => {
})
describe('should build', () => {
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
beforeAll(async () => {
await nextBuild(appDir)
})
@ -73,11 +76,15 @@ describe('TypeScript Features', () => {
join(appDir, '.next/server/pages/hello.js.nft.json')
)
expect(
helloTrace.files.some((file) => file.includes('components/world.js'))
helloTrace.files.some((file) =>
file.includes('components/world.js')
)
).toBe(false)
expect(
helloTrace.files.some((file) => file.includes('react/index.js'))
).toBe(true)
})
}
)
})
})

View file

@ -5,6 +5,7 @@ import { join } from 'path'
const appDir = join(__dirname, '..')
describe('Empty JSConfig Support', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
test('should compile successfully', async () => {
const { code, stdout } = await nextBuild(appDir, [], {
stdout: true,
@ -12,4 +13,5 @@ describe('Empty JSConfig Support', () => {
expect(code).toBe(0)
expect(stdout).toMatch(/Compiled successfully/)
})
})
})

View file

@ -85,6 +85,9 @@ function runTests() {
})
describe('should build', () => {
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
beforeAll(async () => {
await nextBuild(appDir)
})
@ -121,7 +124,9 @@ function runTests() {
)
).toBe(false)
expect(
resolveOrderTrace.files.some((file) => file.includes('lib/a/api.js'))
resolveOrderTrace.files.some((file) =>
file.includes('lib/a/api.js')
)
).toBe(false)
expect(
resolveOrderTrace.files.some((file) =>
@ -139,6 +144,8 @@ function runTests() {
)
).toBe(false)
})
}
)
})
}

View file

@ -7,6 +7,7 @@ import { nextBuild } from 'next-test-utils'
const appDir = join(__dirname, '..')
describe('jsconfig.json', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should build normally', async () => {
const res = await await nextBuild(appDir, [], { stdout: true })
expect(res.stdout).toMatch(/Compiled successfully/)
@ -30,4 +31,5 @@ describe('jsconfig.json', () => {
})
}
})
})
})

View file

@ -7,9 +7,11 @@ jest.setTimeout(1000 * 60 * 2)
const appDir = join(__dirname, '..')
describe('JSON Serialization', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
test('should fail with original error', async () => {
const { code, stderr } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1)
expect(stderr).toContain('Do not know how to serialize a BigInt')
})
})
})

View file

@ -34,7 +34,7 @@ describe('dev mode', () => {
})
// TODO enable that once turbopack supports middleware in dev mode
describe.skip('production mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)

View file

@ -3,6 +3,7 @@ import { nextBuild } from 'next-test-utils'
import { join } from 'path'
describe('Middleware validation during build', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(__dirname, '..')
const middlewareFile = join(appDir, 'middleware.js')
const middlewareError = 'Middleware is returning a response body'
@ -88,4 +89,5 @@ describe('Middleware validation during build', () => {
expect(code).toBe(0)
})
})
})
})

View file

@ -14,6 +14,7 @@ const context = {
}
describe('Middleware Production Prefetch', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
afterAll(() => killApp(context.app))
beforeAll(async () => {
const build = await nextBuild(context.appDir, undefined, {
@ -72,4 +73,5 @@ describe('Middleware Production Prefetch', () => {
return attrs.find((src) => src.includes('/ssg-page-2')) ? 'nope' : 'yes'
}, 'yes')
})
})
})

View file

@ -264,6 +264,7 @@ async function hasImagePreloadBeforeCSSPreload() {
}
describe('Image Component Tests', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
@ -311,7 +312,9 @@ describe('Image Component Tests', () => {
})
it('should add data-nimg data attribute based on layout', async () => {
expect(
await browser.elementById('image-with-sizes').getAttribute('data-nimg')
await browser
.elementById('image-with-sizes')
.getAttribute('data-nimg')
).toBe('responsive')
expect(
await browser.elementById('basic-image').getAttribute('data-nimg')
@ -396,4 +399,5 @@ describe('Image Component Tests', () => {
})
lazyLoadingTests()
})
})
})

View file

@ -30,6 +30,7 @@ function runTests() {
}
describe('Custom Resolver Tests', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
@ -58,4 +59,5 @@ describe('Custom Resolver Tests', () => {
})
runTests()
})
})
})

View file

@ -25,6 +25,7 @@ function runTests() {
}
describe('Image Component Tests In Prod Mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
@ -35,6 +36,7 @@ describe('Image Component Tests In Prod Mode', () => {
})
runTests()
})
})
describe('Image Component Tests In Dev Mode', () => {

View file

@ -15,6 +15,7 @@ let app
let browser
describe('Image Component No IntersectionObserver test', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
@ -68,4 +69,5 @@ describe('Image Component No IntersectionObserver test', () => {
)
})
})
})
})

View file

@ -15,6 +15,7 @@ let appPort
let app
describe('Noscript Tests', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
@ -39,4 +40,5 @@ describe('Noscript Tests', () => {
)
})
})
})
})

View file

@ -15,7 +15,7 @@ let app
let devOutput
describe('svgo-webpack with Image Component', () => {
describe('next build', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should not fail to build invalid usage of the Image component', async () => {
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(stderr).toBeFalsy()
@ -23,7 +23,7 @@ describe('svgo-webpack with Image Component', () => {
})
})
describe('next dev', () => {
describe('development mode', () => {
beforeAll(async () => {
devOutput = { stdout: '', stderr: '' }
appPort = await findPort()

View file

@ -21,7 +21,7 @@ const handleOutput = (msg) => {
}
describe('TypeScript Image Component', () => {
describe('next build', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should fail to build invalid usage of the Image component', async () => {
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(stderr).toMatch(/Failed to compile/)
@ -47,7 +47,7 @@ describe('TypeScript Image Component', () => {
})
})
describe('next dev', () => {
describe('development mode', () => {
beforeAll(async () => {
output = ''
appPort = await findPort()
@ -75,6 +75,7 @@ describe('TypeScript Image Component', () => {
})
})
describe('development mode 2', () => {
it('should remove global image types when disabled (dev)', async () => {
const content = await fs.readFile(nextConfig, 'utf8')
await fs.writeFile(
@ -87,4 +88,5 @@ describe('TypeScript Image Component', () => {
const envTypes = await fs.readFile(join(appDir, 'next-env.d.ts'), 'utf8')
expect(envTypes).not.toContain('image-types/global')
})
})
})

View file

@ -15,7 +15,7 @@ let app
let devOutput
describe('svgo-webpack with Image Component', () => {
describe('next build', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should not fail to build invalid usage of the Image component', async () => {
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
const errors = stderr
@ -26,7 +26,7 @@ describe('svgo-webpack with Image Component', () => {
})
})
describe('next dev', () => {
describe('development mode', () => {
beforeAll(async () => {
devOutput = { stdout: '', stderr: '' }
appPort = await findPort()

View file

@ -21,7 +21,7 @@ const handleOutput = (msg) => {
}
describe('TypeScript Image Component', () => {
describe('next build', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should fail to build invalid usage of the Image component', async () => {
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(stderr).toMatch(/Failed to compile/)
@ -47,7 +47,7 @@ describe('TypeScript Image Component', () => {
})
})
describe('next dev', () => {
describe('development mode', () => {
beforeAll(async () => {
output = ''
appPort = await findPort()

View file

@ -5,6 +5,7 @@ import { nextBuild, readNextBuildServerPageFile } from 'next-test-utils'
const appDir = path.join(__dirname, '../app')
describe('Non-Next externalization', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
})
@ -13,4 +14,5 @@ describe('Non-Next externalization', () => {
const content = readNextBuildServerPageFile(appDir, '/')
expect(content).not.toContain('BrokenExternalMarker')
})
})
})

View file

@ -79,7 +79,7 @@ describe('Non-Standard NODE_ENV', () => {
await killApp(app)
expect(output).not.toContain(warningText)
})
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should still DCE NODE_ENV specific code', async () => {
await nextBuild(appDir, undefined, {
env: {
@ -103,6 +103,34 @@ describe('Non-Standard NODE_ENV', () => {
}
})
it('should show the warning with NODE_ENV set to development with next build', async () => {
const { stderr } = await nextBuild(appDir, [], {
env: {
NODE_ENV: 'development',
},
stderr: true,
})
expect(stderr).toContain(warningText)
})
it('should show the warning with NODE_ENV set to development with next start', async () => {
let output = ''
await nextBuild(appDir)
app = await nextStart(appDir, await findPort(), {
env: {
NODE_ENV: 'development',
},
onStderr(msg) {
output += msg || ''
},
})
await waitFor(2000)
await killApp(app)
expect(output).toContain(warningText)
})
})
it('should show the warning with NODE_ENV set to invalid value', async () => {
let output = ''
@ -152,31 +180,4 @@ describe('Non-Standard NODE_ENV', () => {
await killApp(app)
expect(output).toContain(warningText)
})
it('should show the warning with NODE_ENV set to development with next build', async () => {
const { stderr } = await nextBuild(appDir, [], {
env: {
NODE_ENV: 'development',
},
stderr: true,
})
expect(stderr).toContain(warningText)
})
it('should show the warning with NODE_ENV set to development with next start', async () => {
let output = ''
await nextBuild(appDir)
app = await nextStart(appDir, await findPort(), {
env: {
NODE_ENV: 'development',
},
onStderr(msg) {
output += msg || ''
},
})
await waitFor(2000)
await killApp(app)
expect(output).toContain(warningText)
})
})

View file

@ -6,6 +6,7 @@ import { join } from 'path'
const appDir = join(__dirname, '../')
describe('Numeric Separator Support', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should successfully build for a JavaScript file', async () => {
const { code, stdout, stderr } = await nextBuild(appDir, [], {
stdout: true,
@ -17,4 +18,5 @@ describe('Numeric Separator Support', () => {
expect(stdout).toContain('Compiled successfully')
expect(stderr).not.toContain('Failed to compile')
})
})
})

View file

@ -17,6 +17,7 @@ async function uncommentExport(page) {
}
describe('Page Config', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('builds without error when export const config is used outside page', async () => {
const { stderr } = await nextBuild(appDir, undefined, { stderr: true })
expect(stderr).not.toMatch(/Failed to compile\./)
@ -98,4 +99,5 @@ describe('Page Config', () => {
await reset()
}
})
})
})

View file

@ -5,7 +5,7 @@ import { renderViaHTTP, findPort, launchApp, killApp } from 'next-test-utils'
const context = {}
describe('Configuration', () => {
describe('MDX-rs Configuration', () => {
beforeAll(async () => {
context.appPort = await findPort()
context.server = await launchApp(join(__dirname, '../'), context.appPort)

View file

@ -22,6 +22,7 @@ let proxyServer
let nextDataRequests = []
describe('Prefetching Links in viewport', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
const port = await findPort()
@ -85,7 +86,9 @@ describe('Prefetching Links in viewport', () => {
.click()
.waitForElementByCss('#another')
expect(await browser.elementByCss('#another').text()).toBe('Hello world')
expect(await browser.elementByCss('#another').text()).toBe(
'Hello world'
)
} finally {
stallJs = false
}
@ -420,7 +423,9 @@ describe('Prefetching Links in viewport', () => {
console.log({ linkHrefs, scriptSrcs })
expect(scriptSrcs.some((src) => src.includes('pages/index-'))).toBe(true)
expect(linkHrefs.some((href) => href.includes('pages/index-'))).toBe(false)
expect(linkHrefs.some((href) => href.includes('pages/index-'))).toBe(
false
)
})
it('should not duplicate prefetches', async () => {
@ -554,4 +559,5 @@ describe('Prefetching Links in viewport', () => {
'/_next/data/test-build/ssg/dynamic/two.json',
])
})
})
})

View file

@ -6,6 +6,7 @@ import { nextBuild } from 'next-test-utils'
const appDir = join(__dirname, '..')
describe('Invalid Prerender Catchall Params', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should fail the build', async () => {
const out = await nextBuild(appDir, [], { stderr: true })
expect(out.stderr).toMatch(`Build error occurred`)
@ -13,4 +14,5 @@ describe('Invalid Prerender Catchall Params', () => {
'A required parameter (slug) was not provided as an array received string in getStaticPaths for /[...slug]'
)
})
})
})

View file

@ -6,6 +6,7 @@ import { nextBuild } from 'next-test-utils'
const appDir = join(__dirname, '..')
describe('Legacy Prerender', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
describe('handles old getStaticParams', () => {
it('should fail the build', async () => {
const out = await nextBuild(appDir, [], { stderr: true })
@ -15,4 +16,5 @@ describe('Legacy Prerender', () => {
expect(out.stderr).toMatch('Keys that need to be moved: foo, baz.')
})
})
})
})

View file

@ -96,6 +96,9 @@ describe('SSG Prerender Revalidate', () => {
// Regression test for https://github.com/vercel/next.js/issues/24806
describe('[regression] production mode and incremental cache size exceeded', () => {
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
beforeAll(async () => {
await fs.remove(join(appDir, '.next'))
await nextBuild(appDir, [])
@ -113,5 +116,7 @@ describe('SSG Prerender Revalidate', () => {
runTests('/named', '/named')
runTests('/nested', '/nested')
runTests('/nested/named', '/nested/named')
}
)
})
})

View file

@ -265,7 +265,7 @@ describe('SSG Prerender', () => {
}
})
})
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
describe('export mode', () => {
// disable fallback: true since this is an error during `next export`
const fallbackTruePages = [
@ -319,7 +319,10 @@ describe('SSG Prerender', () => {
for (const page of fallbackBlockingPages) {
const pagePath = join(appDir, 'pages', page)
fallbackBlockingPageContents[page] = await fs.readFile(pagePath, 'utf8')
fallbackBlockingPageContents[page] = await fs.readFile(
pagePath,
'utf8'
)
await fs.writeFile(
pagePath,
fallbackBlockingPageContents[page].replace(
@ -374,10 +377,13 @@ describe('SSG Prerender', () => {
for (const route of routes) {
await fs.access(join(exportDir, `${route}/index.html`))
await fs.access(join(exportDir, '_next/data', buildId, `${route}.json`))
await fs.access(
join(exportDir, '_next/data', buildId, `${route}.json`)
)
}
})
navigateTest()
})
})
})

Some files were not shown because too many files have changed in this diff Show more