Unverified Commit 59bda2d8 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

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.
parent ecd94c1a
...@@ -22,7 +22,9 @@ const gip500Err = ...@@ -22,7 +22,9 @@ const gip500Err =
let appPort let appPort
let app 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.move(pages500, `${pages500}.bak`)
await fs.writeFile( await fs.writeFile(
pages500, pages500,
...@@ -39,38 +41,8 @@ it('does not show error with getStaticProps in pages/500 build', async () => { ...@@ -39,38 +41,8 @@ it('does not show error with getStaticProps in pages/500 build', async () => {
expect(stderr).not.toMatch(gip500Err) expect(stderr).not.toMatch(gip500Err)
expect(code).toBe(0) 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') it('shows error with getServerSideProps in pages/500 build', async () => {
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 () => {
await fs.move(pages500, `${pages500}.bak`) await fs.move(pages500, `${pages500}.bak`)
await fs.writeFile( await fs.writeFile(
pages500, pages500,
...@@ -87,38 +59,9 @@ it('shows error with getServerSideProps in pages/500 build', async () => { ...@@ -87,38 +59,9 @@ it('shows error with getServerSideProps in pages/500 build', async () => {
expect(stderr).toMatch(gip500Err) expect(stderr).toMatch(gip500Err)
expect(code).toBe(1) 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) it('does build 500 statically with getInitialProps in _app and getStaticProps in pages/500', async () => {
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 () => {
await fs.writeFile( await fs.writeFile(
pagesApp, pagesApp,
` `
...@@ -163,9 +106,9 @@ it('does build 500 statically with getInitialProps in _app and getStaticProps in ...@@ -163,9 +106,9 @@ it('does build 500 statically with getInitialProps in _app and getStaticProps in
expect(stderr).not.toMatch(gip500Err) expect(stderr).not.toMatch(gip500Err)
expect(buildStdout).toContain('rendered 500') expect(buildStdout).toContain('rendered 500')
expect(code).toBe(0) expect(code).toBe(0)
expect(await fs.pathExists(join(appDir, '.next/server/pages/500.html'))).toBe( expect(
true await fs.pathExists(join(appDir, '.next/server/pages/500.html'))
) ).toBe(true)
let appStdout = '' let appStdout = ''
const appPort = await findPort() const appPort = await findPort()
...@@ -182,9 +125,9 @@ it('does build 500 statically with getInitialProps in _app and getStaticProps in ...@@ -182,9 +125,9 @@ it('does build 500 statically with getInitialProps in _app and getStaticProps in
await killApp(app) await killApp(app)
expect(appStdout).not.toContain('rendered 500') 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.rename(pages500, `${pages500}.bak`)
await fs.writeFile( await fs.writeFile(
pagesError, pagesError,
...@@ -219,9 +162,9 @@ it('does not build 500 statically with no pages/500 and getServerSideProps in _e ...@@ -219,9 +162,9 @@ it('does not build 500 statically with no pages/500 and getServerSideProps in _e
console.log(buildStderr) console.log(buildStderr)
expect(buildStderr).not.toMatch(gip500Err) expect(buildStderr).not.toMatch(gip500Err)
expect(code).toBe(0) expect(code).toBe(0)
expect(await fs.pathExists(join(appDir, '.next/server/pages/500.html'))).toBe( expect(
false await fs.pathExists(join(appDir, '.next/server/pages/500.html'))
) ).toBe(false)
let appStderr = '' let appStderr = ''
const appPort = await findPort() const appPort = await findPort()
...@@ -235,4 +178,66 @@ it('does not build 500 statically with no pages/500 and getServerSideProps in _e ...@@ -235,4 +178,66 @@ it('does not build 500 statically with no pages/500 and getServerSideProps in _e
await killApp(app) await killApp(app)
expect(appStderr).toContain('called _error getServerSideProps') 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)
})
})
}) })
...@@ -70,6 +70,36 @@ describe('500 Page Support', () => { ...@@ -70,6 +70,36 @@ describe('500 Page Support', () => {
runTests('dev') 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', () => { ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
await fs.remove(join(appDir, '.next')) await fs.remove(join(appDir, '.next'))
...@@ -81,7 +111,9 @@ describe('500 Page Support', () => { ...@@ -81,7 +111,9 @@ describe('500 Page Support', () => {
runTests('server') runTests('server')
}) })
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode 2',
() => {
it('does not build 500 statically with getInitialProps in _app', async () => { it('does not build 500 statically with getInitialProps in _app', async () => {
await fs.writeFile( await fs.writeFile(
pagesApp, pagesApp,
...@@ -322,33 +354,6 @@ describe('500 Page Support', () => { ...@@ -322,33 +354,6 @@ describe('500 Page Support', () => {
expect(stderr).toMatch(gip500Err) expect(stderr).toMatch(gip500Err)
expect(code).toBe(1) 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)
})
}) })
...@@ -19,6 +19,7 @@ let cdnAccessLog = [] ...@@ -19,6 +19,7 @@ let cdnAccessLog = []
const nextConfig = new File(path.resolve(__dirname, '../next.config.js')) const nextConfig = new File(path.resolve(__dirname, '../next.config.js'))
describe('absolute assetPrefix with path prefix', () => { describe('absolute assetPrefix with path prefix', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
cdnPort = await findPort() cdnPort = await findPort()
// lightweight http proxy // lightweight http proxy
...@@ -118,4 +119,5 @@ describe('absolute assetPrefix with path prefix', () => { ...@@ -118,4 +119,5 @@ describe('absolute assetPrefix with path prefix', () => {
`/_next/data/${buildId}/gssp.json?prop=foo` `/_next/data/${buildId}/gssp.json?prop=foo`
) )
}) })
})
}) })
...@@ -13,6 +13,7 @@ const nextConfig = new File(join(appDir, 'next.config.js')) ...@@ -13,6 +13,7 @@ const nextConfig = new File(join(appDir, 'next.config.js'))
let buildOutput let buildOutput
describe('AMP Validation on Export', () => { describe('AMP Validation on Export', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
const { stdout = '', stderr = '' } = await nextBuild(appDir, [], { const { stdout = '', stderr = '' } = await nextBuild(appDir, [], {
stdout: true, stdout: true,
...@@ -123,4 +124,5 @@ describe('AMP Validation on Export', () => { ...@@ -123,4 +124,5 @@ describe('AMP Validation on Export', () => {
nextConfig.restore() nextConfig.restore()
} }
}) })
})
}) })
...@@ -14,6 +14,7 @@ let appPort ...@@ -14,6 +14,7 @@ let appPort
const appDir = join(__dirname, '../') const appDir = join(__dirname, '../')
describe('AMP Custom Optimizer', () => { describe('AMP Custom Optimizer', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should build and start for static page', async () => { it('should build and start for static page', async () => {
const { code } = await nextBuild(appDir) const { code } = await nextBuild(appDir)
expect(code).toBe(0) expect(code).toBe(0)
...@@ -51,4 +52,5 @@ describe('AMP Custom Optimizer', () => { ...@@ -51,4 +52,5 @@ describe('AMP Custom Optimizer', () => {
'script async src="https://cdn.ampproject.org/rtv/001515617716922/v0.mjs"' 'script async src="https://cdn.ampproject.org/rtv/001515617716922/v0.mjs"'
) )
}) })
})
}) })
...@@ -15,6 +15,7 @@ let appPort ...@@ -15,6 +15,7 @@ let appPort
const appDir = join(__dirname, '../') const appDir = join(__dirname, '../')
describe('AMP Custom Validator', () => { describe('AMP Custom Validator', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should build and start successfully', async () => { it('should build and start successfully', async () => {
const { code } = await nextBuild(appDir) const { code } = await nextBuild(appDir)
expect(code).toBe(0) expect(code).toBe(0)
...@@ -27,7 +28,9 @@ describe('AMP Custom Validator', () => { ...@@ -27,7 +28,9 @@ describe('AMP Custom Validator', () => {
expect(html).toContain('Hello from AMP') expect(html).toContain('Hello from AMP')
}) })
})
describe('development mode', () => {
it('should run in dev mode successfully', async () => { it('should run in dev mode successfully', async () => {
let stderr = '' let stderr = ''
...@@ -44,4 +47,5 @@ describe('AMP Custom Validator', () => { ...@@ -44,4 +47,5 @@ describe('AMP Custom Validator', () => {
expect(stderr).not.toContain('error') expect(stderr).not.toContain('error')
expect(html).toContain('Hello from AMP') expect(html).toContain('Hello from AMP')
}) })
})
}) })
...@@ -16,6 +16,7 @@ let appPort ...@@ -16,6 +16,7 @@ let appPort
let app let app
describe('AMP Fragment Styles', () => { describe('AMP Fragment Styles', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
await nextBuild(appDir, []) await nextBuild(appDir, [])
appPort = await findPort() appPort = await findPort()
...@@ -31,4 +32,5 @@ describe('AMP Fragment Styles', () => { ...@@ -31,4 +32,5 @@ describe('AMP Fragment Styles', () => {
expect(styles).toMatch(/background:(.*|)hotpink/) expect(styles).toMatch(/background:(.*|)hotpink/)
expect(styles).toMatch(/font-size:(.*|)16\.4px/) expect(styles).toMatch(/font-size:(.*|)16\.4px/)
}) })
})
}) })
...@@ -118,6 +118,9 @@ describe('AMP SSG Support', () => { ...@@ -118,6 +118,9 @@ describe('AMP SSG Support', () => {
runTests(true) runTests(true)
}) })
describe('export mode', () => { describe('export mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
let buildId let buildId
beforeAll(async () => { beforeAll(async () => {
...@@ -145,5 +148,7 @@ describe('AMP SSG Support', () => { ...@@ -145,5 +148,7 @@ describe('AMP SSG Support', () => {
await fsExists(outFile(join('_next/data', buildId, 'hybrid.json'))) await fsExists(outFile(join('_next/data', buildId, 'hybrid.json')))
).toBe(true) ).toBe(true)
}) })
}
)
}) })
}) })
...@@ -59,8 +59,7 @@ describe('API routes', () => { ...@@ -59,8 +59,7 @@ describe('API routes', () => {
runTests() runTests()
}) })
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
describe('Server support', () => {
beforeAll(async () => { beforeAll(async () => {
await nextBuild(appDir) await nextBuild(appDir)
appPort = await findPort() appPort = await findPort()
......
...@@ -643,8 +643,7 @@ describe('API routes', () => { ...@@ -643,8 +643,7 @@ describe('API routes', () => {
runTests(true) runTests(true)
}) })
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
describe('Server support', () => {
beforeAll(async () => { beforeAll(async () => {
await nextBuild(appDir) await nextBuild(appDir)
mode = 'server' mode = 'server'
......
...@@ -11,6 +11,7 @@ import { ...@@ -11,6 +11,7 @@ import {
} from './utils' } from './utils'
describe('app dir with output export (next dev / next build)', () => { 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 () => { it('should throw when exportPathMap configured', async () => {
nextConfig.replace( nextConfig.replace(
'trailingSlash: true,', 'trailingSlash: true,',
...@@ -139,4 +140,5 @@ describe('app dir with output export (next dev / next build)', () => { ...@@ -139,4 +140,5 @@ describe('app dir with output export (next dev / next build)', () => {
await fs.remove(outputDir) await fs.remove(outputDir)
} }
}) })
})
}) })
...@@ -18,6 +18,7 @@ const nextConfig = new File(join(appDir, 'next.config.js')) ...@@ -18,6 +18,7 @@ const nextConfig = new File(join(appDir, 'next.config.js'))
let app let app
describe('app dir with output export (next start)', () => { describe('app dir with output export (next start)', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
afterEach(async () => { afterEach(async () => {
await killApp(app) await killApp(app)
nextConfig.restore() nextConfig.restore()
...@@ -57,4 +58,5 @@ describe('app dir with output export (next start)', () => { ...@@ -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.` `"next start" does not work with "output: standalone" configuration. Use "node .next/standalone/server.js" instead.`
) )
}) })
})
}) })
...@@ -51,6 +51,7 @@ const respectsChunkAttachmentOrder = async () => { ...@@ -51,6 +51,7 @@ const respectsChunkAttachmentOrder = async () => {
} }
describe('Root components import order', () => { describe('Root components import order', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
await nextBuild(appDir) await nextBuild(appDir)
appPort = await findPort() appPort = await findPort()
...@@ -66,9 +67,10 @@ describe('Root components import order', () => { ...@@ -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', 'root components should be imported in this order _document > _app > page in order to respect side effects',
respectsSideEffects respectsSideEffects
) )
})
}) })
describe('on dev server', () => { describe('development mode', () => {
beforeAll(async () => { beforeAll(async () => {
appPort = await findPort() appPort = await findPort()
app = await launchApp(join(__dirname, '../'), appPort) app = await launchApp(join(__dirname, '../'), appPort)
......
...@@ -16,6 +16,7 @@ let server ...@@ -16,6 +16,7 @@ let server
let app let app
describe('Custom Document Fragment Styles', () => { describe('Custom Document Fragment Styles', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
await nextBuild(appDir) await nextBuild(appDir)
app = nextServer({ app = nextServer({
...@@ -37,4 +38,5 @@ describe('Custom Document Fragment Styles', () => { ...@@ -37,4 +38,5 @@ describe('Custom Document Fragment Styles', () => {
expect(styles).toMatch(/background:(.*|)hotpink/) expect(styles).toMatch(/background:(.*|)hotpink/)
expect(styles).toMatch(/font-size:(.*|)16\.4px/) expect(styles).toMatch(/font-size:(.*|)16\.4px/)
}) })
})
}) })
import { nextBuild } from 'next-test-utils' import { nextBuild } from 'next-test-utils'
import { join } from 'path' import { join } from 'path'
describe('app-dynamic-error', () => {
it('throws an error when prerendering a page with config dynamic error', async () => { ;(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 appDir = join(__dirname, '../../app-dynamic-error')
const { stderr, code } = await nextBuild(appDir, [], { const { stderr, code } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
stdout: 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) expect(code).toBe(1)
})
})
}) })
...@@ -27,8 +27,10 @@ const runTests = () => { ...@@ -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 () => { beforeAll(async () => {
// TODO: This look like a bug, `nextBuild` shouldn't be required here.
await nextBuild(appDir) await nextBuild(appDir)
appPort = await findPort() appPort = await findPort()
buildId = 'development' buildId = 'development'
......
...@@ -11,6 +11,7 @@ const fixturesDir = join(__dirname, '..', 'fixtures') ...@@ -11,6 +11,7 @@ const fixturesDir = join(__dirname, '..', 'fixtures')
const nextConfig = new File(join(fixturesDir, 'basic-app/next.config.js')) const nextConfig = new File(join(fixturesDir, 'basic-app/next.config.js'))
describe('Build Output', () => { describe('Build Output', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const configs = [{}, { gzipSize: false }] const configs = [{}, { gzipSize: false }]
for (const experimental of configs) { for (const experimental of configs) {
...@@ -264,7 +265,9 @@ describe('Build Output', () => { ...@@ -264,7 +265,9 @@ describe('Build Output', () => {
expect(stdout).toMatch(/λ \/404 (.* )?\d{1,} B/) expect(stdout).toMatch(/λ \/404 (.* )?\d{1,} B/)
expect(stdout).toMatch(/\+ First Load JS shared by all [ 0-9.]* kB/) 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\/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(' /_document')
expect(stdout).not.toContain(' /_app') expect(stdout).not.toContain(' /_app')
...@@ -291,4 +294,5 @@ describe('Build Output', () => { ...@@ -291,4 +294,5 @@ describe('Build Output', () => {
expect(stdout).not.toContain('<buildId>') expect(stdout).not.toContain('<buildId>')
}) })
}) })
})
}) })
...@@ -7,6 +7,7 @@ import { nextBuild } from 'next-test-utils' ...@@ -7,6 +7,7 @@ import { nextBuild } from 'next-test-utils'
const appDir = join(__dirname, '../app') const appDir = join(__dirname, '../app')
describe('build trace with extra entries', () => { describe('build trace with extra entries', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should build and trace correctly', async () => { it('should build and trace correctly', async () => {
const result = await nextBuild(appDir, undefined, { const result = await nextBuild(appDir, undefined, {
cwd: appDir, cwd: appDir,
...@@ -37,9 +38,9 @@ describe('build trace with extra entries', () => { ...@@ -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.endsWith('hello.json'))).toBe(true)
expect(tracedFiles.some((file) => file.includes('some-cms/index.js'))).toBe( expect(
true tracedFiles.some((file) => file.includes('some-cms/index.js'))
) ).toBe(true)
expect( expect(
tracedFiles.some((file) => file === '../../../include-me/hello.txt') tracedFiles.some((file) => file === '../../../include-me/hello.txt')
).toBe(true) ).toBe(true)
...@@ -56,7 +57,9 @@ describe('build trace with extra entries', () => { ...@@ -56,7 +57,9 @@ describe('build trace with extra entries', () => {
) )
).toBe(true) ).toBe(true)
expect( expect(
tracedFiles.some((file) => file.includes('nested-structure/package.json')) tracedFiles.some((file) =>
file.includes('nested-structure/package.json')
)
).toBe(true) ).toBe(true)
expect( expect(
tracedFiles.some((file) => tracedFiles.some((file) =>
...@@ -70,4 +73,5 @@ describe('build trace with extra entries', () => { ...@@ -70,4 +73,5 @@ describe('build trace with extra entries', () => {
false false
) )
}) })
})
}) })
...@@ -7,6 +7,7 @@ import { nextBuild } from 'next-test-utils' ...@@ -7,6 +7,7 @@ import { nextBuild } from 'next-test-utils'
const appDir = join(__dirname, '../app') const appDir = join(__dirname, '../app')
describe('build trace with extra entries', () => { describe('build trace with extra entries', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should build and trace correctly', async () => { it('should build and trace correctly', async () => {
const result = await nextBuild(appDir, undefined, { const result = await nextBuild(appDir, undefined, {
cwd: appDir, cwd: appDir,
...@@ -53,10 +54,14 @@ describe('build trace with extra entries', () => { ...@@ -53,10 +54,14 @@ describe('build trace with extra entries', () => {
indexTrace.files.some((file) => file.includes('some-cms/index.js')) indexTrace.files.some((file) => file.includes('some-cms/index.js'))
).toBe(true) ).toBe(true)
expect( expect(
indexTrace.files.some((file) => file === '../../../include-me/hello.txt') indexTrace.files.some(
(file) => file === '../../../include-me/hello.txt'
)
).toBe(true) ).toBe(true)
expect( expect(
indexTrace.files.some((file) => file === '../../../include-me/second.txt') indexTrace.files.some(
(file) => file === '../../../include-me/second.txt'
)
).toBe(true) ).toBe(true)
expect(indexTrace.files.some((file) => file.includes('exclude-me'))).toBe( expect(indexTrace.files.some((file) => file.includes('exclude-me'))).toBe(
false false
...@@ -84,4 +89,5 @@ describe('build trace with extra entries', () => { ...@@ -84,4 +89,5 @@ describe('build trace with extra entries', () => {
imageTrace.files.some((file) => file.includes('public/test.jpg')) imageTrace.files.some((file) => file.includes('public/test.jpg'))
).toBe(false) ).toBe(false)
}) })
})
}) })
...@@ -7,7 +7,8 @@ import { join } from 'path' ...@@ -7,7 +7,8 @@ import { join } from 'path'
const appDir = join(__dirname, '../') const appDir = join(__dirname, '../')
describe('Build warnings', () => { 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 }) const { stderr } = await nextBuild(appDir, undefined, { stderr: true })
expect(stderr).not.toContain('optimization has been disabled') expect(stderr).not.toContain('optimization has been disabled')
}) })
...@@ -86,4 +87,5 @@ describe('Build warnings', () => { ...@@ -86,4 +87,5 @@ describe('Build warnings', () => {
})) }))
expect(stdout).not.toContain('no-cache') expect(stdout).not.toContain('no-cache')
}) })
})
}) })
...@@ -13,6 +13,7 @@ const appDir = join(__dirname, '../') ...@@ -13,6 +13,7 @@ const appDir = join(__dirname, '../')
const errorRegex = /getStaticPaths was added without a getStaticProps in/ const errorRegex = /getStaticPaths was added without a getStaticProps in/
describe('Catches Missing getStaticProps', () => { describe('Catches Missing getStaticProps', () => {
describe('development mode', () => {
it('should catch it in dev mode', async () => { it('should catch it in dev mode', async () => {
const appPort = await findPort() const appPort = await findPort()
const app = await launchApp(appDir, appPort) const app = await launchApp(appDir, appPort)
...@@ -21,11 +22,13 @@ describe('Catches Missing getStaticProps', () => { ...@@ -21,11 +22,13 @@ describe('Catches Missing getStaticProps', () => {
expect(html).toMatch(errorRegex) expect(html).toMatch(errorRegex)
}) })
})
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should catch it in server build mode', async () => { it('should catch it in server build mode', async () => {
const { stderr } = await nextBuild(appDir, [], { const { stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
}) })
expect(stderr).toMatch(errorRegex) expect(stderr).toMatch(errorRegex)
}) })
})
}) })
...@@ -80,6 +80,7 @@ const testExitSignal = async ( ...@@ -80,6 +80,7 @@ const testExitSignal = async (
} }
describe('CLI Usage', () => { describe('CLI Usage', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
describe('start', () => { describe('start', () => {
test('should exit when SIGINT is signalled', async () => { test('should exit when SIGINT is signalled', async () => {
require('console').log('before build') require('console').log('before build')
...@@ -277,6 +278,40 @@ describe('CLI Usage', () => { ...@@ -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', () => { describe('no command', () => {
test('--help', async () => { test('--help', async () => {
const help = await runNextCommand(['--help'], { const help = await runNextCommand(['--help'], {
...@@ -755,39 +790,6 @@ describe('CLI Usage', () => { ...@@ -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', () => { describe('info', () => {
function matchInfoOutput(stdout, { nextConfigOutput = '.*' } = {}) { function matchInfoOutput(stdout, { nextConfigOutput = '.*' } = {}) {
expect(stdout).toMatch( expect(stdout).toMatch(
......
...@@ -7,6 +7,7 @@ import { nextBuild } from 'next-test-utils' ...@@ -7,6 +7,7 @@ import { nextBuild } from 'next-test-utils'
const appDir = join(__dirname, '..') const appDir = join(__dirname, '..')
describe('Promise in next config', () => { describe('Promise in next config', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
afterEach(() => fs.remove(join(appDir, 'next.config.js'))) afterEach(() => fs.remove(join(appDir, 'next.config.js')))
it('should warn when a promise is returned on webpack', async () => { it('should warn when a promise is returned on webpack', async () => {
...@@ -31,4 +32,5 @@ describe('Promise in next config', () => { ...@@ -31,4 +32,5 @@ describe('Promise in next config', () => {
/> Promise returned in next config\. https:\/\// /> Promise returned in next config\. https:\/\//
) )
}) })
})
}) })
...@@ -8,6 +8,7 @@ const nextConfigJS = join(appDir, 'next.config.js') ...@@ -8,6 +8,7 @@ const nextConfigJS = join(appDir, 'next.config.js')
const nextConfigMJS = join(appDir, 'next.config.mjs') const nextConfigMJS = join(appDir, 'next.config.mjs')
describe('Invalid config syntax', () => { describe('Invalid config syntax', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should error when next.config.js contains syntax error', async () => { it('should error when next.config.js contains syntax error', async () => {
await fs.writeFile( await fs.writeFile(
nextConfigJS, nextConfigJS,
...@@ -48,4 +49,5 @@ describe('Invalid config syntax', () => { ...@@ -48,4 +49,5 @@ describe('Invalid config syntax', () => {
) )
expect(stderr).toContain('SyntaxError') expect(stderr).toContain('SyntaxError')
}) })
})
}) })
...@@ -5,6 +5,7 @@ import fs from 'fs-extra' ...@@ -5,6 +5,7 @@ import fs from 'fs-extra'
const nextConfigPath = path.join(__dirname, '../next.config.js') const nextConfigPath = path.join(__dirname, '../next.config.js')
describe('next.config.js validation', () => { describe('next.config.js validation', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it.each([ it.each([
{ {
name: 'invalid config types', name: 'invalid config types',
...@@ -53,4 +54,5 @@ describe('next.config.js validation', () => { ...@@ -53,4 +54,5 @@ describe('next.config.js validation', () => {
} }
} }
) )
})
}) })
...@@ -12,6 +12,7 @@ import { ...@@ -12,6 +12,7 @@ import {
const appDir = path.join(__dirname, '..') const appDir = path.join(__dirname, '..')
describe('Errors on conflict between public file and page file', () => { describe('Errors on conflict between public file and page file', () => {
describe('development mode', () => {
it('Throws error during development', async () => { it('Throws error during development', async () => {
const appPort = await findPort() const appPort = await findPort()
const app = await launchApp(appDir, appPort) const app = await launchApp(appDir, appPort)
...@@ -25,10 +26,14 @@ describe('Errors on conflict between public file and page file', () => { ...@@ -25,10 +26,14 @@ describe('Errors on conflict between public file and page file', () => {
} }
await killApp(app) await killApp(app)
}) })
})
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('Throws error during build', async () => { it('Throws error during build', async () => {
const conflicts = ['/another/conflict', '/another', '/hello'] 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 const output = results.stdout + results.stderr
expect(output).toMatch(/Conflicting public and page files were found/) expect(output).toMatch(/Conflicting public and page files were found/)
...@@ -36,4 +41,5 @@ describe('Errors on conflict between public file and page file', () => { ...@@ -36,4 +41,5 @@ describe('Errors on conflict between public file and page file', () => {
expect(output.indexOf(conflict) > 0).toBe(true) expect(output.indexOf(conflict) > 0).toBe(true)
} }
}) })
})
}) })
...@@ -8,6 +8,7 @@ const appDir = join(__dirname, '../') ...@@ -8,6 +8,7 @@ const appDir = join(__dirname, '../')
const pagesDir = join(appDir, 'pages') const pagesDir = join(appDir, 'pages')
describe('Conflicting SSG paths', () => { describe('Conflicting SSG paths', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
afterEach(() => fs.remove(pagesDir)) afterEach(() => fs.remove(pagesDir))
it('should show proper error when two dynamic SSG routes have conflicting paths', async () => { it('should show proper error when two dynamic SSG routes have conflicting paths', async () => {
...@@ -184,4 +185,5 @@ describe('Conflicting SSG paths', () => { ...@@ -184,4 +185,5 @@ describe('Conflicting SSG paths', () => {
`path: "/hellO/world" from page: "/[...catchAll]" conflicts with path: "/hello/world"` `path: "/hellO/world" from page: "/[...catchAll]" conflicts with path: "/hello/world"`
) )
}) })
})
}) })
...@@ -57,6 +57,7 @@ function runTests() { ...@@ -57,6 +57,7 @@ function runTests() {
} }
describe('CSS optimization for SSR apps', () => { describe('CSS optimization for SSR apps', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
await fs.writeFile( await fs.writeFile(
nextConfig, nextConfig,
...@@ -76,4 +77,5 @@ describe('CSS optimization for SSR apps', () => { ...@@ -76,4 +77,5 @@ describe('CSS optimization for SSR apps', () => {
await fs.remove(nextConfig) await fs.remove(nextConfig)
}) })
runTests() runTests()
})
}) })
...@@ -28,6 +28,7 @@ function runTests() { ...@@ -28,6 +28,7 @@ function runTests() {
} }
describe('css-minify', () => { describe('css-minify', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
await nextBuild(appDir) await nextBuild(appDir)
appPort = await findPort() appPort = await findPort()
...@@ -37,4 +38,5 @@ describe('css-minify', () => { ...@@ -37,4 +38,5 @@ describe('css-minify', () => {
await killApp(app) await killApp(app)
}) })
runTests() runTests()
})
}) })
...@@ -243,6 +243,7 @@ describe('Can hot reload CSS Module without losing state', () => { ...@@ -243,6 +243,7 @@ describe('Can hot reload CSS Module without losing state', () => {
}) })
describe.skip('Invalid CSS Module Usage in node_modules', () => { describe.skip('Invalid CSS Module Usage in node_modules', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'invalid-module') const appDir = join(fixturesDir, 'invalid-module')
beforeAll(async () => { beforeAll(async () => {
...@@ -259,11 +260,15 @@ describe.skip('Invalid CSS Module Usage in node_modules', () => { ...@@ -259,11 +260,15 @@ describe.skip('Invalid CSS Module Usage in node_modules', () => {
expect(stderr).toMatch( expect(stderr).toMatch(
/CSS Modules.*cannot.*be imported from within.*node_modules/ /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', () => { 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') const appDir = join(fixturesDir, 'invalid-global-module')
beforeAll(async () => { beforeAll(async () => {
...@@ -280,7 +285,10 @@ describe.skip('Invalid Global CSS Module Usage in node_modules', () => { ...@@ -280,7 +285,10 @@ describe.skip('Invalid Global CSS Module Usage in node_modules', () => {
expect(stderr).toMatch( expect(stderr).toMatch(
/Global CSS.*cannot.*be imported from within.*node_modules/ /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/
)
})
}) })
}) })
......
...@@ -38,6 +38,7 @@ describe('Ordering with styled-jsx (dev)', () => { ...@@ -38,6 +38,7 @@ describe('Ordering with styled-jsx (dev)', () => {
}) })
describe('Ordering with styled-jsx (prod)', () => { describe('Ordering with styled-jsx (prod)', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'with-styled-jsx') const appDir = join(fixturesDir, 'with-styled-jsx')
let appPort let appPort
...@@ -69,4 +70,5 @@ describe('Ordering with styled-jsx (prod)', () => { ...@@ -69,4 +70,5 @@ describe('Ordering with styled-jsx (prod)', () => {
) )
expect(currentColor).toMatchInlineSnapshot(`"rgb(0, 128, 0)"`) expect(currentColor).toMatchInlineSnapshot(`"rgb(0, 128, 0)"`)
}) })
})
}) })
...@@ -15,6 +15,7 @@ import { join } from 'path' ...@@ -15,6 +15,7 @@ import { join } from 'path'
const fixturesDir = join(__dirname, '../..', 'css-fixtures') const fixturesDir = join(__dirname, '../..', 'css-fixtures')
describe('CSS Support', () => { describe('CSS Support', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
describe('CSS Compilation and Prefixing', () => { describe('CSS Compilation and Prefixing', () => {
const appDir = join(fixturesDir, 'compilation-and-prefixing') const appDir = join(fixturesDir, 'compilation-and-prefixing')
...@@ -175,7 +176,9 @@ describe('CSS Support', () => { ...@@ -175,7 +176,9 @@ describe('CSS Support', () => {
const cssPreload = $('link[rel="preload"][as="style"]') const cssPreload = $('link[rel="preload"][as="style"]')
expect(cssPreload.length).toBe(1) 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"]') const cssSheet = $('link[rel="stylesheet"]')
expect(cssSheet.length).toBe(1) expect(cssSheet.length).toBe(1)
...@@ -213,7 +216,9 @@ describe('CSS Support', () => { ...@@ -213,7 +216,9 @@ describe('CSS Support', () => {
expect(cssFiles.length).toBe(1) expect(cssFiles.length).toBe(1)
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8') 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', () => { ...@@ -245,10 +250,12 @@ describe('CSS Support', () => {
).toMatchInlineSnapshot(`".other{color:blue}.test{color:red}"`) ).toMatchInlineSnapshot(`".other{color:blue}.test{color:red}"`)
}) })
}) })
})
}) })
// https://github.com/vercel/next.js/issues/15468 // https://github.com/vercel/next.js/issues/15468
describe('CSS Property Ordering', () => { describe('CSS Property Ordering', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'next-issue-15468') const appDir = join(fixturesDir, 'next-issue-15468')
let appPort let appPort
...@@ -285,4 +292,5 @@ describe('CSS Property Ordering', () => { ...@@ -285,4 +292,5 @@ describe('CSS Property Ordering', () => {
) )
expect(width2).toMatchInlineSnapshot(`"5px"`) expect(width2).toMatchInlineSnapshot(`"5px"`)
}) })
})
}) })
...@@ -15,6 +15,7 @@ import { join } from 'path' ...@@ -15,6 +15,7 @@ import { join } from 'path'
const fixturesDir = join(__dirname, '../..', 'css-fixtures') const fixturesDir = join(__dirname, '../..', 'css-fixtures')
describe('CSS Support', () => { describe('CSS Support', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
describe('CSS Import from node_modules', () => { describe('CSS Import from node_modules', () => {
const appDir = join(fixturesDir, 'npm-import-bad') const appDir = join(fixturesDir, 'npm-import-bad')
...@@ -30,6 +31,7 @@ describe('CSS Support', () => { ...@@ -30,6 +31,7 @@ describe('CSS Support', () => {
expect(stderr).not.toMatch(/Build error occurred/) expect(stderr).not.toMatch(/Build error occurred/)
}) })
}) })
})
// https://github.com/vercel/next.js/issues/18557 // https://github.com/vercel/next.js/issues/18557
describe('CSS page transition inject <style> with nonce so it works with CSP header', () => { describe('CSS page transition inject <style> with nonce so it works with CSP header', () => {
......
...@@ -11,6 +11,7 @@ let app ...@@ -11,6 +11,7 @@ let app
// TODO: re-enable with React 18 // TODO: re-enable with React 18
describe.skip('Custom error page exception', () => { describe.skip('Custom error page exception', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
await nextBuild(appDir, undefined, { await nextBuild(appDir, undefined, {
nodeArgs, nodeArgs,
...@@ -31,4 +32,5 @@ describe.skip('Custom error page exception', () => { ...@@ -31,4 +32,5 @@ describe.skip('Custom error page exception', () => {
/Application error: a client-side exception has occurred/ /Application error: a client-side exception has occurred/
) )
}) })
})
}) })
...@@ -143,6 +143,9 @@ describe.skip.each([ ...@@ -143,6 +143,9 @@ describe.skip.each([
}) })
describe('with generateEtags enabled', () => { describe('with generateEtags enabled', () => {
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
beforeAll(async () => { beforeAll(async () => {
await nextBuild(appDir) await nextBuild(appDir)
await startServer({ GENERATE_ETAGS: 'true', NODE_ENV: 'production' }) await startServer({ GENERATE_ETAGS: 'true', NODE_ENV: 'production' })
...@@ -150,9 +153,13 @@ describe.skip.each([ ...@@ -150,9 +153,13 @@ describe.skip.each([
afterAll(() => killApp(server)) afterAll(() => killApp(server))
it('response includes etag header', async () => { 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() expect(response.headers.get('etag')).toBeTruthy()
}) })
}
)
}) })
describe('with generateEtags disabled', () => { describe('with generateEtags disabled', () => {
...@@ -222,7 +229,9 @@ describe.skip.each([ ...@@ -222,7 +229,9 @@ describe.skip.each([
expect(html).toContain('made it to dashboard') expect(html).toContain('made it to dashboard')
expect(stderr).toContain('Cannot render page with path "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 () => { it('should warn in production mode', async () => {
const { code } = await nextBuild(appDir) const { code } = await nextBuild(appDir)
expect(code).toBe(0) expect(code).toBe(0)
...@@ -244,6 +253,8 @@ describe.skip.each([ ...@@ -244,6 +253,8 @@ describe.skip.each([
expect(html).toContain('made it to dashboard') expect(html).toContain('made it to dashboard')
expect(stderr).toContain('Cannot render page with path "dashboard"') expect(stderr).toContain('Cannot render page with path "dashboard"')
}) })
}
)
}) })
describe('compression handling', function () { describe('compression handling', function () {
......
...@@ -132,12 +132,9 @@ describe('GS(S)P Page Errors', () => { ...@@ -132,12 +132,9 @@ describe('GS(S)P Page Errors', () => {
describe('dev mode', () => { describe('dev mode', () => {
runTests(true) runTests(true)
}) })
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
describe('build mode', () => {
runTests() runTests()
})
describe('start mode', () => {
it('Error stack printed to stderr', async () => { it('Error stack printed to stderr', async () => {
try { try {
await fs.writeFile( await fs.writeFile(
......
...@@ -15,6 +15,7 @@ let appPort ...@@ -15,6 +15,7 @@ let appPort
let app let app
describe('De-dedupes scripts in _document', () => { describe('De-dedupes scripts in _document', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
appPort = await findPort() appPort = await findPort()
await nextBuild(appDir) await nextBuild(appDir)
...@@ -39,4 +40,5 @@ describe('De-dedupes scripts in _document', () => { ...@@ -39,4 +40,5 @@ describe('De-dedupes scripts in _document', () => {
} }
expect(foundDuplicate).toBe(false) expect(foundDuplicate).toBe(false)
}) })
})
}) })
...@@ -19,6 +19,9 @@ let app ...@@ -19,6 +19,9 @@ let app
describe('distDir', () => { describe('distDir', () => {
describe('With basic usage', () => { describe('With basic usage', () => {
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
beforeAll(async () => { beforeAll(async () => {
await fs.remove(join(appDir, '.next')) await fs.remove(join(appDir, '.next'))
await fs.remove(join(appDir, 'dist')) await fs.remove(join(appDir, 'dist'))
...@@ -41,6 +44,8 @@ describe('distDir', () => { ...@@ -41,6 +44,8 @@ describe('distDir', () => {
it('should not build the app within the default `.next` directory', async () => { it('should not build the app within the default `.next` directory', async () => {
expect(await fs.exists(join(__dirname, '/../.next'))).toBeFalsy() expect(await fs.exists(join(__dirname, '/../.next'))).toBeFalsy()
}) })
}
)
}) })
describe('dev mode', () => { describe('dev mode', () => {
...@@ -66,7 +71,7 @@ describe('distDir', () => { ...@@ -66,7 +71,7 @@ describe('distDir', () => {
expect(await fs.exists(join(__dirname, '/../.next'))).toBeFalsy() expect(await fs.exists(join(__dirname, '/../.next'))).toBeFalsy()
}) })
}) })
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should throw error with invalid distDir', async () => { it('should throw error with invalid distDir', async () => {
const origNextConfig = await fs.readFile(nextConfig, 'utf8') const origNextConfig = await fs.readFile(nextConfig, 'utf8')
await fs.writeFile(nextConfig, `module.exports = { distDir: '' }`) await fs.writeFile(nextConfig, `module.exports = { distDir: '' }`)
...@@ -89,4 +94,5 @@ describe('distDir', () => { ...@@ -89,4 +94,5 @@ describe('distDir', () => {
expect(stderr.length).toBe(0) expect(stderr.length).toBe(0)
}) })
})
}) })
...@@ -82,8 +82,13 @@ describe('Edge runtime code with imports', () => { ...@@ -82,8 +82,13 @@ describe('Edge runtime code with imports', () => {
beforeEach(() => init(importStatement)) beforeEach(() => init(importStatement))
describe('development mode', () => {
it('throws unsupported module error in dev at runtime and highlights the faulty line', async () => { 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) const res = await fetchViaHTTP(context.appPort, url)
expect(res.status).toBe(500) expect(res.status).toBe(500)
await check(async () => { await check(async () => {
...@@ -95,17 +100,26 @@ describe('Edge runtime code with imports', () => { ...@@ -95,17 +100,26 @@ describe('Edge runtime code with imports', () => {
return 'success' return 'success'
}, '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 () => { it('throws unsupported module error in production at runtime and prints error on logs', async () => {
const { stderr } = await nextBuild(context.appDir, undefined, { const { stderr } = await nextBuild(context.appDir, undefined, {
stderr: true, stderr: true,
}) })
expect(stderr).toContain(getUnsupportedModuleWarning(moduleName)) 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) const res = await fetchViaHTTP(context.appPort, url)
expect(res.status).toBe(500) expect(res.status).toBe(500)
expectUnsupportedModuleProdError(moduleName) expectUnsupportedModuleProdError(moduleName)
}) })
}
)
}) })
describe.each([ describe.each([
...@@ -154,6 +168,7 @@ describe('Edge runtime code with imports', () => { ...@@ -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 () => { it('throws unsupported module error in dev at runtime and highlights the faulty line', async () => {
context.app = await launchApp( context.app = await launchApp(
context.appDir, context.appDir,
...@@ -171,7 +186,10 @@ describe('Edge runtime code with imports', () => { ...@@ -171,7 +186,10 @@ describe('Edge runtime code with imports', () => {
return 'success' return 'success'
}, '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 () => { it('throws unsupported module error in production at runtime and prints error on logs', async () => {
const { stderr } = await nextBuild(context.appDir, undefined, { const { stderr } = await nextBuild(context.appDir, undefined, {
stderr: true, stderr: true,
...@@ -188,6 +206,8 @@ describe('Edge runtime code with imports', () => { ...@@ -188,6 +206,8 @@ describe('Edge runtime code with imports', () => {
}) })
} }
) )
}
)
describe.each([ describe.each([
{ {
...@@ -241,7 +261,9 @@ describe('Edge runtime code with imports', () => { ...@@ -241,7 +261,9 @@ describe('Edge runtime code with imports', () => {
return 'success' return 'success'
}, 'success') }, 'success')
}) })
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
it('does not build and reports', async () => { it('does not build and reports', async () => {
const { code, stderr } = await nextBuild(context.appDir, undefined, { const { code, stderr } = await nextBuild(context.appDir, undefined, {
ignoreFail: true, ignoreFail: true,
...@@ -251,6 +273,8 @@ describe('Edge runtime code with imports', () => { ...@@ -251,6 +273,8 @@ describe('Edge runtime code with imports', () => {
expect(code).toEqual(1) expect(code).toEqual(1)
expectModuleNotFoundProdError(moduleName, stderr) expectModuleNotFoundProdError(moduleName, stderr)
}) })
}
)
}) })
describe.each([ describe.each([
...@@ -299,18 +323,26 @@ describe('Edge runtime code with imports', () => { ...@@ -299,18 +323,26 @@ describe('Edge runtime code with imports', () => {
expect(res.headers.get('x-from-runtime')).toBeDefined() expect(res.headers.get('x-from-runtime')).toBeDefined()
expectNoError(moduleName) expectNoError(moduleName)
}) })
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
it('does not throw in production at runtime', async () => { it('does not throw in production at runtime', async () => {
const { stderr } = await nextBuild(context.appDir, undefined, { const { stderr } = await nextBuild(context.appDir, undefined, {
stderr: true, stderr: true,
}) })
expect(stderr).not.toContain(getUnsupportedModuleWarning(moduleName)) 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) const res = await fetchViaHTTP(context.appPort, url)
expect(res.status).toBe(200) expect(res.status).toBe(200)
expect(res.headers.get('x-from-runtime')).toBeDefined() expect(res.headers.get('x-from-runtime')).toBeDefined()
expectNoError(moduleName) expectNoError(moduleName)
}) })
}
)
}) })
describe.each([ describe.each([
...@@ -360,14 +392,22 @@ describe('Edge runtime code with imports', () => { ...@@ -360,14 +392,22 @@ describe('Edge runtime code with imports', () => {
expect(res.headers.get('x-from-runtime')).toBe('false') expect(res.headers.get('x-from-runtime')).toBe('false')
expectNoError(moduleName) expectNoError(moduleName)
}) })
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
it('does not throw in production at runtime', async () => { it('does not throw in production at runtime', async () => {
await nextBuild(context.appDir, undefined, { stderr: true }) 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) const res = await fetchViaHTTP(context.appPort, url)
expect(res.status).toBe(200) expect(res.status).toBe(200)
expect(res.headers.get('x-from-runtime')).toBe('false') expect(res.headers.get('x-from-runtime')).toBe('false')
expectNoError(moduleName) expectNoError(moduleName)
}) })
}
)
}) })
}) })
...@@ -95,17 +95,25 @@ describe('Edge runtime code with imports', () => { ...@@ -95,17 +95,25 @@ describe('Edge runtime code with imports', () => {
return 'success' return 'success'
}, '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 () => { it('throws unsupported module error in production at runtime and prints error on logs', async () => {
const { stderr } = await nextBuild(context.appDir, undefined, { const { stderr } = await nextBuild(context.appDir, undefined, {
stderr: true, stderr: true,
}) })
expect(stderr).toContain(getUnsupportedModuleWarning(moduleName)) 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) const res = await fetchViaHTTP(context.appPort, url)
expect(res.status).toBe(500) expect(res.status).toBe(500)
expectUnsupportedModuleProdError(moduleName) expectUnsupportedModuleProdError(moduleName)
}) })
}
)
}) })
describe.each([ describe.each([
...@@ -157,7 +165,9 @@ describe('Edge runtime code with imports', () => { ...@@ -157,7 +165,9 @@ describe('Edge runtime code with imports', () => {
return 'success' return 'success'
}, 'success') }, 'success')
}) })
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
it('does not build and reports module not found error', async () => { it('does not build and reports module not found error', async () => {
const { code, stderr } = await nextBuild(context.appDir, undefined, { const { code, stderr } = await nextBuild(context.appDir, undefined, {
ignoreFail: true, ignoreFail: true,
...@@ -167,6 +177,8 @@ describe('Edge runtime code with imports', () => { ...@@ -167,6 +177,8 @@ describe('Edge runtime code with imports', () => {
expect(code).toEqual(1) expect(code).toEqual(1)
expectModuleNotFoundProdError(moduleName, stderr) expectModuleNotFoundProdError(moduleName, stderr)
}) })
}
)
}) })
describe.each([ describe.each([
...@@ -221,7 +233,9 @@ describe('Edge runtime code with imports', () => { ...@@ -221,7 +233,9 @@ describe('Edge runtime code with imports', () => {
return 'success' return 'success'
}, 'success') }, 'success')
}) })
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
it('does not build and reports module not found error', async () => { it('does not build and reports module not found error', async () => {
const { code, stderr } = await nextBuild(context.appDir, undefined, { const { code, stderr } = await nextBuild(context.appDir, undefined, {
ignoreFail: true, ignoreFail: true,
...@@ -232,6 +246,8 @@ describe('Edge runtime code with imports', () => { ...@@ -232,6 +246,8 @@ describe('Edge runtime code with imports', () => {
expectModuleNotFoundProdError(moduleName, stderr) expectModuleNotFoundProdError(moduleName, stderr)
}) })
}
)
}) })
describe.each([ describe.each([
...@@ -279,16 +295,24 @@ describe('Edge runtime code with imports', () => { ...@@ -279,16 +295,24 @@ describe('Edge runtime code with imports', () => {
expect(res.status).toBe(200) expect(res.status).toBe(200)
expectNoError(moduleName) expectNoError(moduleName)
}) })
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
it('does not throw in production at runtime', async () => { it('does not throw in production at runtime', async () => {
const { stderr } = await nextBuild(context.appDir, undefined, { const { stderr } = await nextBuild(context.appDir, undefined, {
stderr: true, stderr: true,
}) })
expect(stderr).toContain(getUnsupportedModuleWarning(moduleName)) 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) const res = await fetchViaHTTP(context.appPort, url)
expect(res.status).toBe(200) expect(res.status).toBe(200)
expectNoError(moduleName) expectNoError(moduleName)
}) })
}
)
}) })
}) })
...@@ -72,17 +72,25 @@ describe('Edge runtime code with imports', () => { ...@@ -72,17 +72,25 @@ describe('Edge runtime code with imports', () => {
) )
expect(res.status).toBe(500) expect(res.status).toBe(500)
}) })
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
it(`${title} build test Response`, async () => { it(`${title} build test Response`, async () => {
await nextBuild(context.appDir, undefined, { await nextBuild(context.appDir, undefined, {
stderr: true, 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) const res = await fetchViaHTTP(context.appPort, url)
expect(context.logs.stderr).toContain( expect(context.logs.stderr).toContain(
'Expected an instance of Response to be returned' 'Expected an instance of Response to be returned'
) )
expect(res.status).toBe(500) expect(res.status).toBe(500)
}) })
}
)
}) })
}) })
...@@ -16,6 +16,7 @@ let app ...@@ -16,6 +16,7 @@ let app
let port let port
describe('Handles an Error in _error', () => { describe('Handles an Error in _error', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
await nextBuild(appDir) await nextBuild(appDir)
port = await findPort() port = await findPort()
...@@ -35,4 +36,5 @@ describe('Handles an Error in _error', () => { ...@@ -35,4 +36,5 @@ describe('Handles an Error in _error', () => {
const html = await browser.eval('document.body.innerHTML') const html = await browser.eval('document.body.innerHTML')
expect(html).toMatch(/Internal Server Error/i) expect(html).toMatch(/Internal Server Error/i)
}) })
})
}) })
...@@ -16,6 +16,7 @@ const appDir = join(__dirname, '..') ...@@ -16,6 +16,7 @@ const appDir = join(__dirname, '..')
let app let app
describe('Failing to load _error', () => { describe('Failing to load _error', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
afterAll(() => killApp(app)) afterAll(() => killApp(app))
it('handles failing to load _error correctly', async () => { it('handles failing to load _error correctly', async () => {
...@@ -60,4 +61,5 @@ describe('Failing to load _error', () => { ...@@ -60,4 +61,5 @@ describe('Failing to load _error', () => {
: 'fail' : 'fail'
}, /reloaded/) }, /reloaded/)
}) })
})
}) })
...@@ -8,9 +8,13 @@ const appDir = path.join(__dirname, '..') ...@@ -8,9 +8,13 @@ const appDir = path.join(__dirname, '..')
const nextConfig = path.join(appDir, 'next.config.js') const nextConfig = path.join(appDir, 'next.config.js')
describe('Errors on output to public', () => { describe('Errors on output to public', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('Throws error when `distDir` is set to public', async () => { it('Throws error when `distDir` is set to public', async () => {
await fs.writeFile(nextConfig, `module.exports = { distDir: 'public' }`) 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( expect(results.stdout + results.stderr).toMatch(
/The 'public' directory is reserved in Next\.js and can not be set as/ /The 'public' directory is reserved in Next\.js and can not be set as/
) )
...@@ -33,4 +37,5 @@ describe('Errors on output to public', () => { ...@@ -33,4 +37,5 @@ describe('Errors on output to public', () => {
/The 'public' directory is reserved in Next\.js and can not be used as/ /The 'public' directory is reserved in Next\.js and can not be used as/
) )
}) })
})
}) })
...@@ -8,6 +8,7 @@ const appDir = path.join(__dirname, '..') ...@@ -8,6 +8,7 @@ const appDir = path.join(__dirname, '..')
const nextConfig = path.join(appDir, 'next.config.js') const nextConfig = path.join(appDir, 'next.config.js')
describe('Errors on output to static', () => { describe('Errors on output to static', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('Throws error when export out dir is static', async () => { it('Throws error when export out dir is static', async () => {
await fs.remove(nextConfig) await fs.remove(nextConfig)
await nextBuild(appDir) await nextBuild(appDir)
...@@ -24,4 +25,5 @@ describe('Errors on output to static', () => { ...@@ -24,4 +25,5 @@ describe('Errors on output to static', () => {
/The 'static' directory is reserved in Next\.js and can not be used as/ /The 'static' directory is reserved in Next\.js and can not be used as/
) )
}) })
})
}) })
...@@ -40,6 +40,7 @@ const mjsCjsLinting = join(__dirname, '../mjs-cjs-linting') ...@@ -40,6 +40,7 @@ const mjsCjsLinting = join(__dirname, '../mjs-cjs-linting')
const dirTypescript = join(__dirname, '../with-typescript') const dirTypescript = join(__dirname, '../with-typescript')
describe('Next Build', () => { describe('Next Build', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
test('first time setup', async () => { test('first time setup', async () => {
const eslintrcJson = join(dirFirstTimeSetup, '.eslintrc.json') const eslintrcJson = join(dirFirstTimeSetup, '.eslintrc.json')
await fs.writeFile(eslintrcJson, '') await fs.writeFile(eslintrcJson, '')
...@@ -62,7 +63,9 @@ describe('Next Build', () => { ...@@ -62,7 +63,9 @@ describe('Next Build', () => {
}) })
const output = stdout + stderr 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( expect(output).toContain(
'Error: Comments inside children section of tag should be placed inside braces' 'Error: Comments inside children section of tag should be placed inside braces'
) )
...@@ -97,7 +100,9 @@ describe('Next Build', () => { ...@@ -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.' '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: 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( expect(output).toContain(
'Warning: `rel="preconnect"` is missing from Google Font' 'Warning: `rel="preconnect"` is missing from Google Font'
) )
...@@ -121,7 +126,9 @@ describe('Next Build', () => { ...@@ -121,7 +126,9 @@ describe('Next Build', () => {
expect(output).toContain( expect(output).toContain(
'Error: Comments inside children section of tag should be placed inside braces' '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 () => { test('invalid older eslint version', async () => {
...@@ -149,7 +156,9 @@ describe('Next Build', () => { ...@@ -149,7 +156,9 @@ describe('Next Build', () => {
const output = stdout + stderr const output = stdout + stderr
expect(output).not.toContain('Build error occurred') expect(output).not.toContain('Build error occurred')
expect(output).not.toContain('NoFilesFoundError') 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') expect(output).toContain('Compiled successfully')
}) })
...@@ -162,7 +171,9 @@ describe('Next Build', () => { ...@@ -162,7 +171,9 @@ describe('Next Build', () => {
const output = stdout + stderr const output = stdout + stderr
expect(output).not.toContain('Build error occurred') expect(output).not.toContain('Build error occurred')
expect(output).not.toContain('AllFilesIgnoredError') 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') expect(output).toContain('Compiled successfully')
}) })
...@@ -206,4 +217,5 @@ describe('Next Build', () => { ...@@ -206,4 +217,5 @@ describe('Next Build', () => {
expect(cacheExists).toBe(true) expect(cacheExists).toBe(true)
}) })
})
}) })
...@@ -19,6 +19,7 @@ const fileExist = (path) => ...@@ -19,6 +19,7 @@ const fileExist = (path) =>
// Issue #36855 // Issue #36855
// https://github.com/vercel/next.js/issues/36855 // https://github.com/vercel/next.js/issues/36855
describe('Static 404 Export', () => { describe('Static 404 Export', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('only export 404.html when trailingSlash: false', async () => { it('only export 404.html when trailingSlash: false', async () => {
await nextBuild(appDir) await nextBuild(appDir)
await nextExport(appDir, { outdir }) await nextExport(appDir, { outdir })
...@@ -38,9 +39,11 @@ describe('Static 404 Export', () => { ...@@ -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.html'))).toBe(false)
expect(await fileExist(join(outdir, '404.html'))).toBe(true) expect(await fileExist(join(outdir, '404.html'))).toBe(true)
}) })
})
}) })
describe('Export with a page named 404.js', () => { 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 () => { it('should export a custom 404.html instead of default 404.html', async () => {
await nextBuild(appDir) await nextBuild(appDir)
await nextExport(appDir, { outdir }) await nextExport(appDir, { outdir })
...@@ -48,4 +51,5 @@ describe('Export with a page named 404.js', () => { ...@@ -48,4 +51,5 @@ describe('Export with a page named 404.js', () => {
const html = await readFile(join(outdir, '404.html'), 'utf8') const html = await readFile(join(outdir, '404.html'), 'utf8')
expect(html).toMatch(/this is a 404 page override the default 404\.html/) expect(html).toMatch(/this is a 404 page override the default 404\.html/)
}) })
})
}) })
...@@ -10,6 +10,7 @@ const appDir = join(__dirname, '../') ...@@ -10,6 +10,7 @@ const appDir = join(__dirname, '../')
const outdir = join(appDir, 'out') const outdir = join(appDir, 'out')
describe('Export with default map', () => { describe('Export with default map', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
await nextBuild(appDir) await nextBuild(appDir)
await nextExport(appDir, { outdir }) await nextExport(appDir, { outdir })
...@@ -28,13 +29,17 @@ describe('Export with default map', () => { ...@@ -28,13 +29,17 @@ describe('Export with default map', () => {
it('should export hybrid amp page correctly', async () => { it('should export hybrid amp page correctly', async () => {
expect.assertions(2) expect.assertions(2)
await expect(access(join(outdir, 'some.html'))).resolves.toBe(undefined) 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 () => { it('should export nested hybrid amp page correctly', async () => {
expect.assertions(3) expect.assertions(3)
await expect(access(join(outdir, 'docs.html'))).resolves.toBe(undefined) 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 html = await readFile(join(outdir, 'docs.html'))
const $ = cheerio.load(html) const $ = cheerio.load(html)
...@@ -44,7 +49,9 @@ describe('Export with default map', () => { ...@@ -44,7 +49,9 @@ describe('Export with default map', () => {
it('should export nested hybrid amp page correctly with folder', async () => { it('should export nested hybrid amp page correctly with folder', async () => {
expect.assertions(3) expect.assertions(3)
await expect(access(join(outdir, 'info.html'))).resolves.toBe(undefined) 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 html = await readFile(join(outdir, 'info.html'))
const $ = cheerio.load(html) const $ = cheerio.load(html)
...@@ -62,4 +69,5 @@ describe('Export with default map', () => { ...@@ -62,4 +69,5 @@ describe('Export with default map', () => {
const $ = cheerio.load(html) const $ = cheerio.load(html)
expect($('link[rel=amphtml]').attr('href')).toBe('/index.amp') expect($('link[rel=amphtml]').attr('href')).toBe('/index.amp')
}) })
})
}) })
...@@ -14,9 +14,8 @@ import { ...@@ -14,9 +14,8 @@ import {
const appDir = join(__dirname, '../') const appDir = join(__dirname, '../')
const outdir = join(appDir, 'out') const outdir = join(appDir, 'out')
;(process.env.TURBOPACK ? describe.skip : describe)( describe('Export Dynamic Pages', () => {
'Export Dynamic Pages', ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
() => {
let server let server
let port let port
beforeAll(async () => { beforeAll(async () => {
...@@ -48,5 +47,5 @@ const outdir = join(appDir, 'out') ...@@ -48,5 +47,5 @@ const outdir = join(appDir, 'out')
await browser.close() await browser.close()
} }
}) })
} })
) })
...@@ -8,6 +8,7 @@ const appDir = join(__dirname, '../') ...@@ -8,6 +8,7 @@ const appDir = join(__dirname, '../')
const outdir = join(appDir, 'out') const outdir = join(appDir, 'out')
describe('Export error for fallback: true', () => { describe('Export error for fallback: true', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should build successfully', async () => { it('should build successfully', async () => {
await fs.remove(join(appDir, '.next')) await fs.remove(join(appDir, '.next'))
const { code } = await nextBuild(appDir) const { code } = await nextBuild(appDir)
...@@ -22,4 +23,5 @@ describe('Export error for fallback: true', () => { ...@@ -22,4 +23,5 @@ describe('Export error for fallback: true', () => {
) )
expect(stderr).toContain('/[slug]') expect(stderr).toContain('/[slug]')
}) })
})
}) })
...@@ -7,6 +7,7 @@ const appDir = join(__dirname, '../') ...@@ -7,6 +7,7 @@ const appDir = join(__dirname, '../')
const outdir = join(appDir, 'out') const outdir = join(appDir, 'out')
describe('Export with getInitialProps', () => { describe('Export with getInitialProps', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should show warning with next export', async () => { it('should show warning with next export', async () => {
await nextBuild(appDir) await nextBuild(appDir)
const { stderr } = await nextExport(appDir, { outdir }, { stderr: true }) const { stderr } = await nextExport(appDir, { outdir }, { stderr: true })
...@@ -14,4 +15,5 @@ describe('Export with getInitialProps', () => { ...@@ -14,4 +15,5 @@ describe('Export with getInitialProps', () => {
'https://nextjs.org/docs/messages/get-initial-props-export' 'https://nextjs.org/docs/messages/get-initial-props-export'
) )
}) })
})
}) })
...@@ -8,6 +8,7 @@ const appDir = join(__dirname, '../') ...@@ -8,6 +8,7 @@ const appDir = join(__dirname, '../')
const outdir = join(appDir, 'out') const outdir = join(appDir, 'out')
describe('Export with default loader next/image component', () => { describe('Export with default loader next/image component', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should build successfully', async () => { it('should build successfully', async () => {
await fs.remove(join(appDir, '.next')) await fs.remove(join(appDir, '.next'))
const { code } = await nextBuild(appDir) const { code } = await nextBuild(appDir)
...@@ -20,4 +21,5 @@ describe('Export with default loader next/image component', () => { ...@@ -20,4 +21,5 @@ describe('Export with default loader next/image component', () => {
'Image Optimization using the default loader is not compatible with export.' 'Image Optimization using the default loader is not compatible with export.'
) )
}) })
})
}) })
...@@ -11,6 +11,7 @@ const nextConfig = new File(join(appDir, 'next.config.js')) ...@@ -11,6 +11,7 @@ const nextConfig = new File(join(appDir, 'next.config.js'))
const pagesIndexJs = new File(join(appDir, 'pages', 'index.js')) const pagesIndexJs = new File(join(appDir, 'pages', 'index.js'))
describe('Export with cloudinary loader next/legacy/image component', () => { describe('Export with cloudinary loader next/legacy/image component', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
await nextConfig.replace( await nextConfig.replace(
'{ /* replaceme */ }', '{ /* replaceme */ }',
...@@ -42,9 +43,11 @@ describe('Export with cloudinary loader next/legacy/image component', () => { ...@@ -42,9 +43,11 @@ describe('Export with cloudinary loader next/legacy/image component', () => {
afterAll(async () => { afterAll(async () => {
await nextConfig.restore() await nextConfig.restore()
}) })
})
}) })
describe('Export with custom loader next/legacy/image component', () => { describe('Export with custom loader next/legacy/image component', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
await nextConfig.replace( await nextConfig.replace(
'{ /* replaceme */ }', '{ /* replaceme */ }',
...@@ -80,9 +83,11 @@ describe('Export with custom loader next/legacy/image component', () => { ...@@ -80,9 +83,11 @@ describe('Export with custom loader next/legacy/image component', () => {
await nextConfig.restore() await nextConfig.restore()
await pagesIndexJs.restore() await pagesIndexJs.restore()
}) })
})
}) })
describe('Export with custom loader config but no loader prop on next/legacy/image', () => { describe('Export with custom loader config but no loader prop on next/legacy/image', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
await nextConfig.replace( await nextConfig.replace(
'{ /* replaceme */ }', '{ /* replaceme */ }',
...@@ -106,9 +111,11 @@ describe('Export with custom loader config but no loader prop on next/legacy/ima ...@@ -106,9 +111,11 @@ describe('Export with custom loader config but no loader prop on next/legacy/ima
await nextConfig.restore() await nextConfig.restore()
await pagesIndexJs.restore() await pagesIndexJs.restore()
}) })
})
}) })
describe('Export with unoptimized next/legacy/image component', () => { describe('Export with unoptimized next/legacy/image component', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
await nextConfig.replace( await nextConfig.replace(
'{ /* replaceme */ }', '{ /* replaceme */ }',
...@@ -139,4 +146,5 @@ describe('Export with unoptimized next/legacy/image component', () => { ...@@ -139,4 +146,5 @@ describe('Export with unoptimized next/legacy/image component', () => {
afterAll(async () => { afterAll(async () => {
await nextConfig.restore() await nextConfig.restore()
}) })
})
}) })
...@@ -8,6 +8,7 @@ const appDir = join(__dirname, '../') ...@@ -8,6 +8,7 @@ const appDir = join(__dirname, '../')
const outdir = join(appDir, 'out') const outdir = join(appDir, 'out')
describe('Export index page with `notFound: true` in `getStaticProps`', () => { describe('Export index page with `notFound: true` in `getStaticProps`', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should build successfully', async () => { it('should build successfully', async () => {
await fs.remove(join(appDir, '.next')) await fs.remove(join(appDir, '.next'))
const { code } = await nextBuild(appDir) const { code } = await nextBuild(appDir)
...@@ -18,4 +19,5 @@ describe('Export index page with `notFound: true` in `getStaticProps`', () => { ...@@ -18,4 +19,5 @@ describe('Export index page with `notFound: true` in `getStaticProps`', () => {
const { code } = await nextExport(appDir, { outdir }) const { code } = await nextExport(appDir, { outdir })
if (code !== 0) throw new Error(`export failed with status ${code}`) if (code !== 0) throw new Error(`export failed with status ${code}`)
}) })
})
}) })
...@@ -6,6 +6,7 @@ import { nextBuild, nextExportDefault } from 'next-test-utils' ...@@ -6,6 +6,7 @@ import { nextBuild, nextExportDefault } from 'next-test-utils'
const appDir = join(__dirname, '../') const appDir = join(__dirname, '../')
describe('Export cli prints progress info', () => { describe('Export cli prints progress info', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
let buildStdout let buildStdout
let exportStdout let exportStdout
beforeAll(async () => { beforeAll(async () => {
...@@ -32,4 +33,5 @@ describe('Export cli prints progress info', () => { ...@@ -32,4 +33,5 @@ describe('Export cli prints progress info', () => {
expect(found).toBeTruthy() expect(found).toBeTruthy()
}) })
})
}) })
...@@ -10,6 +10,7 @@ const appDir = join(__dirname, '../') ...@@ -10,6 +10,7 @@ const appDir = join(__dirname, '../')
const outdir = join(appDir, 'out') const outdir = join(appDir, 'out')
describe('Export config#exportTrailingSlash set to false', () => { describe('Export config#exportTrailingSlash set to false', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
await nextBuild(appDir) await nextBuild(appDir)
await nextExport(appDir, { outdir }) await nextExport(appDir, { outdir })
...@@ -33,4 +34,5 @@ describe('Export config#exportTrailingSlash set to false', () => { ...@@ -33,4 +34,5 @@ describe('Export config#exportTrailingSlash set to false', () => {
const $single = cheerio.load(htmlSingle) const $single = cheerio.load(htmlSingle)
expect($single('p').text()).toBe('I am a single post') expect($single('p').text()).toBe('I am a single post')
}) })
})
}) })
...@@ -7,6 +7,7 @@ import { nextBuild } from 'next-test-utils' ...@@ -7,6 +7,7 @@ import { nextBuild } from 'next-test-utils'
const appDir = join(__dirname, '../') const appDir = join(__dirname, '../')
describe('bundle pages externals with config.experimental.bundlePagesExternals', () => { 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 () => { it('should have no externals with the config set', async () => {
await nextBuild(appDir, [], { stdout: true }) await nextBuild(appDir, [], { stdout: true })
const output = await fs.readFile( const output = await fs.readFile(
...@@ -15,4 +16,5 @@ describe('bundle pages externals with config.experimental.bundlePagesExternals', ...@@ -15,4 +16,5 @@ describe('bundle pages externals with config.experimental.bundlePagesExternals',
) )
expect(output).not.toContain('require("external-package")') expect(output).not.toContain('require("external-package")')
}) })
})
}) })
...@@ -7,7 +7,8 @@ import { join } from 'path' ...@@ -7,7 +7,8 @@ import { join } from 'path'
const fixturesDir = join(__dirname, '..', 'fixtures') const fixturesDir = join(__dirname, '..', 'fixtures')
describe('Build Output', () => { describe('Fallback Modules', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
describe('Crypto Application', () => { describe('Crypto Application', () => {
let stdout let stdout
const appDir = join(fixturesDir, 'with-crypto') const appDir = join(fixturesDir, 'with-crypto')
...@@ -51,4 +52,5 @@ describe('Build Output', () => { ...@@ -51,4 +52,5 @@ describe('Build Output', () => {
expect(indexFirstLoad.endsWith('kB')).toBe(true) expect(indexFirstLoad.endsWith('kB')).toBe(true)
}) })
}) })
})
}) })
...@@ -51,7 +51,7 @@ function runTests() { ...@@ -51,7 +51,7 @@ function runTests() {
} }
describe('Fetch polyfill with ky-universal', () => { describe('Fetch polyfill with ky-universal', () => {
describe('dev support', () => { describe('development mode', () => {
beforeAll(async () => { beforeAll(async () => {
appPort = await findPort() appPort = await findPort()
await startApiServer() await startApiServer()
...@@ -68,8 +68,7 @@ describe('Fetch polyfill with ky-universal', () => { ...@@ -68,8 +68,7 @@ describe('Fetch polyfill with ky-universal', () => {
runTests() runTests()
}) })
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
describe('Server support', () => {
beforeAll(async () => { beforeAll(async () => {
await startApiServer() await startApiServer()
await nextBuild(appDir, [], { await nextBuild(appDir, [], {
......
...@@ -70,7 +70,7 @@ function runTests() { ...@@ -70,7 +70,7 @@ function runTests() {
} }
describe('Fetch polyfill', () => { describe('Fetch polyfill', () => {
describe('dev support', () => { describe('development mode', () => {
beforeAll(async () => { beforeAll(async () => {
appPort = await findPort() appPort = await findPort()
await startApiServer() await startApiServer()
...@@ -87,8 +87,7 @@ describe('Fetch polyfill', () => { ...@@ -87,8 +87,7 @@ describe('Fetch polyfill', () => {
runTests() runTests()
}) })
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
describe('Server support', () => {
beforeAll(async () => { beforeAll(async () => {
await startApiServer() await startApiServer()
await nextBuild(appDir, [], { await nextBuild(appDir, [], {
......
...@@ -8,13 +8,17 @@ const appDir = path.join(__dirname, '..') ...@@ -8,13 +8,17 @@ const appDir = path.join(__dirname, '..')
const nextConfig = path.join(appDir, 'next.config.js') const nextConfig = path.join(appDir, 'next.config.js')
describe('Building Firebase', () => { describe('Building Firebase', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
// TODO: investigate re-enabling this test in node 12 environment // TODO: investigate re-enabling this test in node 12 environment
it.skip('Throws an error when building with firebase dependency with worker_threads', async () => { it.skip('Throws an error when building with firebase dependency with worker_threads', async () => {
await fs.writeFile( await fs.writeFile(
nextConfig, nextConfig,
`module.exports = { experimental: { workerThreads: true } }` `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(/Build error occurred/)
expect(results.stdout + results.stderr).toMatch( expect(results.stdout + results.stderr).toMatch(
/grpc_node\.node\. Module did not self-register\./ /grpc_node\.node\. Module did not self-register\./
...@@ -23,10 +27,16 @@ describe('Building Firebase', () => { ...@@ -23,10 +27,16 @@ describe('Building Firebase', () => {
it('Throws no error when building with firebase dependency without worker_threads', async () => { it('Throws no error when building with firebase dependency without worker_threads', async () => {
await fs.remove(nextConfig) await fs.remove(nextConfig)
const results = await nextBuild(appDir, [], { stdout: true, stderr: true }) const results = await nextBuild(appDir, [], {
expect(results.stdout + results.stderr).not.toMatch(/Build error occurred/) stdout: true,
stderr: true,
})
expect(results.stdout + results.stderr).not.toMatch(
/Build error occurred/
)
expect(results.stdout + results.stderr).not.toMatch( expect(results.stdout + results.stderr).not.toMatch(
/grpc_node\.node\. Module did not self-register\./ /grpc_node\.node\. Module did not self-register\./
) )
}) })
})
}) })
...@@ -15,6 +15,7 @@ let appPort ...@@ -15,6 +15,7 @@ let appPort
let app let app
describe('excludeDefaultMomentLocales', () => { describe('excludeDefaultMomentLocales', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
appPort = await findPort() appPort = await findPort()
await nextBuild(appDir) await nextBuild(appDir)
...@@ -31,4 +32,5 @@ describe('excludeDefaultMomentLocales', () => { ...@@ -31,4 +32,5 @@ describe('excludeDefaultMomentLocales', () => {
expect(locales.length).toBe(1) expect(locales.length).toBe(1)
await browser.close() await browser.close()
}) })
})
}) })
...@@ -18,6 +18,7 @@ let app ...@@ -18,6 +18,7 @@ let app
const fileNames = ['1', '2.ext', '3.html'] const fileNames = ['1', '2.ext', '3.html']
describe('GS(S)P with file extension', () => { describe('GS(S)P with file extension', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
await fs.remove(join(appDir, '.next')) await fs.remove(join(appDir, '.next'))
const { code } = await nextBuild(appDir) const { code } = await nextBuild(appDir)
...@@ -55,4 +56,5 @@ describe('GS(S)P with file extension', () => { ...@@ -55,4 +56,5 @@ describe('GS(S)P with file extension', () => {
expect(result.pageProps.value).toBe(fileNames[i]) expect(result.pageProps.value).toBe(fileNames[i])
) )
}) })
})
}) })
...@@ -499,7 +499,6 @@ describe('GS(S)P Redirect Support', () => { ...@@ -499,7 +499,6 @@ describe('GS(S)P Redirect Support', () => {
afterAll(() => killApp(app)) afterAll(() => killApp(app))
runTests() runTests()
})
it('should error for redirect during prerendering', async () => { it('should error for redirect during prerendering', async () => {
await fs.mkdirp(join(appDir, 'pages/invalid')) await fs.mkdirp(join(appDir, 'pages/invalid'))
...@@ -538,4 +537,5 @@ describe('GS(S)P Redirect Support', () => { ...@@ -538,4 +537,5 @@ describe('GS(S)P Redirect Support', () => {
'`redirect` can not be returned from getStaticProps during prerendering' '`redirect` can not be returned from getStaticProps during prerendering'
) )
}) })
})
}) })
...@@ -537,7 +537,6 @@ describe('GS(S)P Redirect Support', () => { ...@@ -537,7 +537,6 @@ describe('GS(S)P Redirect Support', () => {
it('should not have errors in output', async () => { it('should not have errors in output', async () => {
expect(output).not.toContain('Failed to update prerender files') expect(output).not.toContain('Failed to update prerender files')
}) })
})
it('should error for redirect during prerendering', async () => { it('should error for redirect during prerendering', async () => {
await fs.mkdirp(join(appDir, 'pages/invalid')) await fs.mkdirp(join(appDir, 'pages/invalid'))
...@@ -576,4 +575,5 @@ describe('GS(S)P Redirect Support', () => { ...@@ -576,4 +575,5 @@ describe('GS(S)P Redirect Support', () => {
'`redirect` can not be returned from getStaticProps during prerendering' '`redirect` can not be returned from getStaticProps during prerendering'
) )
}) })
})
}) })
...@@ -6,6 +6,7 @@ import { nextBuild } from 'next-test-utils' ...@@ -6,6 +6,7 @@ import { nextBuild } from 'next-test-utils'
const appDir = path.join(__dirname, '..') const appDir = path.join(__dirname, '..')
describe('Handles Errors During Export', () => { describe('Handles Errors During Export', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('Does not crash workers', async () => { it('Does not crash workers', async () => {
const { stdout, stderr } = await nextBuild(appDir, [], { const { stdout, stderr } = await nextBuild(appDir, [], {
stdout: true, stdout: true,
...@@ -24,4 +25,5 @@ describe('Handles Errors During Export', () => { ...@@ -24,4 +25,5 @@ describe('Handles Errors During Export', () => {
expect(stderr).toContain('/custom-error') expect(stderr).toContain('/custom-error')
expect(stderr).toContain('custom error message') expect(stderr).toContain('custom error message')
}) })
})
}) })
...@@ -9,6 +9,7 @@ let appPort ...@@ -9,6 +9,7 @@ let appPort
let server let server
describe('hydrate/render ordering', () => { describe('hydrate/render ordering', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
appPort = await findPort() appPort = await findPort()
await nextBuild(appDir, [], {}) await nextBuild(appDir, [], {})
...@@ -33,4 +34,5 @@ describe('hydrate/render ordering', () => { ...@@ -33,4 +34,5 @@ describe('hydrate/render ordering', () => {
await browser.close() await browser.close()
}) })
})
}) })
...@@ -78,6 +78,9 @@ describe('i18n Support basePath', () => { ...@@ -78,6 +78,9 @@ describe('i18n Support basePath', () => {
}) })
describe('with localeDetection disabled', () => { describe('with localeDetection disabled', () => {
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
beforeAll(async () => { beforeAll(async () => {
await fs.remove(join(appDir, '.next')) await fs.remove(join(appDir, '.next'))
nextConfig.replace('// localeDetection', 'localeDetection') nextConfig.replace('// localeDetection', 'localeDetection')
...@@ -173,5 +176,7 @@ describe('i18n Support basePath', () => { ...@@ -173,5 +176,7 @@ describe('i18n Support basePath', () => {
expect($('#router-as-path').text()).toBe('/') expect($('#router-as-path').text()).toBe('/')
} }
}) })
}
)
}) })
}) })
...@@ -88,6 +88,9 @@ describe('i18n Support', () => { ...@@ -88,6 +88,9 @@ describe('i18n Support', () => {
}) })
describe('with localeDetection disabled', () => { describe('with localeDetection disabled', () => {
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
beforeAll(async () => { beforeAll(async () => {
await fs.remove(join(appDir, '.next')) await fs.remove(join(appDir, '.next'))
nextConfig.replace('// localeDetection', 'localeDetection') nextConfig.replace('// localeDetection', 'localeDetection')
...@@ -205,6 +208,8 @@ describe('i18n Support', () => { ...@@ -205,6 +208,8 @@ describe('i18n Support', () => {
expect($('#router-as-path').text()).toBe('/') expect($('#router-as-path').text()).toBe('/')
} }
}) })
}
)
}) })
describe('with trailingSlash: true', () => { describe('with trailingSlash: true', () => {
...@@ -520,7 +525,7 @@ describe('i18n Support', () => { ...@@ -520,7 +525,7 @@ describe('i18n Support', () => {
} }
) )
}) })
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should show proper error for duplicate defaultLocales', async () => { it('should show proper error for duplicate defaultLocales', async () => {
nextConfig.write(` nextConfig.write(`
module.exports = { module.exports = {
...@@ -601,4 +606,5 @@ describe('i18n Support', () => { ...@@ -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` `i18n domain: "hello:3000" is invalid it should be a valid domain without protocol (https://) or port (:3000) e.g. example.vercel.sh`
) )
}) })
})
}) })
...@@ -483,6 +483,9 @@ describe('Image Optimizer', () => { ...@@ -483,6 +483,9 @@ describe('Image Optimizer', () => {
}) })
describe('Server support for headers in next.config.js', () => { 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 const size = 96 // defaults defined in server/config.ts
let app let app
let appPort let appPort
...@@ -536,7 +539,9 @@ describe('Image Optimizer', () => { ...@@ -536,7 +539,9 @@ describe('Image Optimizer', () => {
Object.keys(files).forEach((dir) => { Object.keys(files).forEach((dir) => {
if ( if (
Object.keys(files[dir]).some((file) => file.includes(`${maxAge}.`)) Object.keys(files[dir]).some((file) =>
file.includes(`${maxAge}.`)
)
) { ) {
found = true found = true
} }
...@@ -557,6 +562,8 @@ describe('Image Optimizer', () => { ...@@ -557,6 +562,8 @@ describe('Image Optimizer', () => {
`inline; filename="test.webp"` `inline; filename="test.webp"`
) )
}) })
}
)
}) })
describe('dev support next.config.js cloudinary loader', () => { describe('dev support next.config.js cloudinary loader', () => {
...@@ -619,6 +626,9 @@ describe('Image Optimizer', () => { ...@@ -619,6 +626,9 @@ describe('Image Optimizer', () => {
}) })
describe('External rewrite support with for serving static content in images', () => { describe('External rewrite support with for serving static content in images', () => {
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
let app let app
let appPort let appPort
...@@ -668,7 +678,9 @@ describe('Image Optimizer', () => { ...@@ -668,7 +678,9 @@ describe('Image Optimizer', () => {
Object.keys(files).forEach((dir) => { Object.keys(files).forEach((dir) => {
if ( if (
Object.keys(files[dir]).some((file) => file.includes(`${maxAge}.`)) Object.keys(files[dir]).some((file) =>
file.includes(`${maxAge}.`)
)
) { ) {
found = true found = true
} }
...@@ -677,6 +689,8 @@ describe('Image Optimizer', () => { ...@@ -677,6 +689,8 @@ describe('Image Optimizer', () => {
}, 'success') }, 'success')
await expectWidth(res, 64) await expectWidth(res, 64)
}) })
}
)
}) })
describe('dev support for dynamic blur placeholder', () => { describe('dev support for dynamic blur placeholder', () => {
......
...@@ -10,6 +10,7 @@ const nextConfigPath = join(appDir, 'next.config.js') ...@@ -10,6 +10,7 @@ const nextConfigPath = join(appDir, 'next.config.js')
const cleanUp = () => fs.remove(nextConfigPath) const cleanUp = () => fs.remove(nextConfigPath)
describe('Handles valid/invalid assetPrefix', () => { describe('Handles valid/invalid assetPrefix', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(() => cleanUp()) beforeAll(() => cleanUp())
afterAll(() => cleanUp()) afterAll(() => cleanUp())
...@@ -35,4 +36,5 @@ describe('Handles valid/invalid assetPrefix', () => { ...@@ -35,4 +36,5 @@ describe('Handles valid/invalid assetPrefix', () => {
const { stderr } = await nextBuild(appDir, undefined, { stderr: true }) const { stderr } = await nextBuild(appDir, undefined, { stderr: true })
expect(stderr).not.toMatch(/Specified assetPrefix is not a string/) expect(stderr).not.toMatch(/Specified assetPrefix is not a string/)
}) })
})
}) })
...@@ -8,6 +8,7 @@ const appDir = join(__dirname, '../') ...@@ -8,6 +8,7 @@ const appDir = join(__dirname, '../')
const nextConfig = new File(join(appDir, 'next.config.js')) const nextConfig = new File(join(appDir, 'next.config.js'))
describe('Invalid static image import in _document', () => { describe('Invalid static image import in _document', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
afterAll(() => nextConfig.restore()) afterAll(() => nextConfig.restore())
it('Should fail to build when no next.config.js', async () => { it('Should fail to build when no next.config.js', async () => {
...@@ -41,4 +42,5 @@ describe('Invalid static image import in _document', () => { ...@@ -41,4 +42,5 @@ describe('Invalid static image import in _document', () => {
/Images.*cannot.*be imported within.*pages[\\/]_document\.js/ /Images.*cannot.*be imported within.*pages[\\/]_document\.js/
) )
}) })
})
}) })
...@@ -7,6 +7,7 @@ import { nextBuild } from 'next-test-utils' ...@@ -7,6 +7,7 @@ import { nextBuild } from 'next-test-utils'
const appDir = path.join(__dirname, '..') const appDir = path.join(__dirname, '..')
describe('Invalid Page automatic static optimization', () => { describe('Invalid Page automatic static optimization', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('Fails softly with descriptive error', async () => { it('Fails softly with descriptive error', async () => {
const { stderr } = await nextBuild(appDir, [], { stderr: true }) const { stderr } = await nextBuild(appDir, [], { stderr: true })
...@@ -19,7 +20,10 @@ describe('Invalid Page automatic static optimization', () => { ...@@ -19,7 +20,10 @@ describe('Invalid Page automatic static optimization', () => {
it('handles non-error correctly', async () => { it('handles non-error correctly', async () => {
const testPage = path.join(appDir, 'pages/[slug].js') 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.ensureDir(path.join(appDir, 'pages'))
await fs.writeFile( await fs.writeFile(
...@@ -55,4 +59,5 @@ describe('Invalid Page automatic static optimization', () => { ...@@ -55,4 +59,5 @@ describe('Invalid Page automatic static optimization', () => {
) )
} }
}) })
})
}) })
...@@ -65,6 +65,9 @@ describe('TypeScript Features', () => { ...@@ -65,6 +65,9 @@ describe('TypeScript Features', () => {
}) })
describe('should build', () => { describe('should build', () => {
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
beforeAll(async () => { beforeAll(async () => {
await nextBuild(appDir) await nextBuild(appDir)
}) })
...@@ -73,11 +76,15 @@ describe('TypeScript Features', () => { ...@@ -73,11 +76,15 @@ describe('TypeScript Features', () => {
join(appDir, '.next/server/pages/hello.js.nft.json') join(appDir, '.next/server/pages/hello.js.nft.json')
) )
expect( expect(
helloTrace.files.some((file) => file.includes('components/world.js')) helloTrace.files.some((file) =>
file.includes('components/world.js')
)
).toBe(false) ).toBe(false)
expect( expect(
helloTrace.files.some((file) => file.includes('react/index.js')) helloTrace.files.some((file) => file.includes('react/index.js'))
).toBe(true) ).toBe(true)
}) })
}
)
}) })
}) })
...@@ -5,6 +5,7 @@ import { join } from 'path' ...@@ -5,6 +5,7 @@ import { join } from 'path'
const appDir = join(__dirname, '..') const appDir = join(__dirname, '..')
describe('Empty JSConfig Support', () => { describe('Empty JSConfig Support', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
test('should compile successfully', async () => { test('should compile successfully', async () => {
const { code, stdout } = await nextBuild(appDir, [], { const { code, stdout } = await nextBuild(appDir, [], {
stdout: true, stdout: true,
...@@ -12,4 +13,5 @@ describe('Empty JSConfig Support', () => { ...@@ -12,4 +13,5 @@ describe('Empty JSConfig Support', () => {
expect(code).toBe(0) expect(code).toBe(0)
expect(stdout).toMatch(/Compiled successfully/) expect(stdout).toMatch(/Compiled successfully/)
}) })
})
}) })
...@@ -85,6 +85,9 @@ function runTests() { ...@@ -85,6 +85,9 @@ function runTests() {
}) })
describe('should build', () => { describe('should build', () => {
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
beforeAll(async () => { beforeAll(async () => {
await nextBuild(appDir) await nextBuild(appDir)
}) })
...@@ -121,7 +124,9 @@ function runTests() { ...@@ -121,7 +124,9 @@ function runTests() {
) )
).toBe(false) ).toBe(false)
expect( expect(
resolveOrderTrace.files.some((file) => file.includes('lib/a/api.js')) resolveOrderTrace.files.some((file) =>
file.includes('lib/a/api.js')
)
).toBe(false) ).toBe(false)
expect( expect(
resolveOrderTrace.files.some((file) => resolveOrderTrace.files.some((file) =>
...@@ -139,6 +144,8 @@ function runTests() { ...@@ -139,6 +144,8 @@ function runTests() {
) )
).toBe(false) ).toBe(false)
}) })
}
)
}) })
} }
......
...@@ -7,6 +7,7 @@ import { nextBuild } from 'next-test-utils' ...@@ -7,6 +7,7 @@ import { nextBuild } from 'next-test-utils'
const appDir = join(__dirname, '..') const appDir = join(__dirname, '..')
describe('jsconfig.json', () => { describe('jsconfig.json', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should build normally', async () => { it('should build normally', async () => {
const res = await await nextBuild(appDir, [], { stdout: true }) const res = await await nextBuild(appDir, [], { stdout: true })
expect(res.stdout).toMatch(/Compiled successfully/) expect(res.stdout).toMatch(/Compiled successfully/)
...@@ -30,4 +31,5 @@ describe('jsconfig.json', () => { ...@@ -30,4 +31,5 @@ describe('jsconfig.json', () => {
}) })
} }
}) })
})
}) })
...@@ -7,9 +7,11 @@ jest.setTimeout(1000 * 60 * 2) ...@@ -7,9 +7,11 @@ jest.setTimeout(1000 * 60 * 2)
const appDir = join(__dirname, '..') const appDir = join(__dirname, '..')
describe('JSON Serialization', () => { describe('JSON Serialization', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
test('should fail with original error', async () => { test('should fail with original error', async () => {
const { code, stderr } = await nextBuild(appDir, [], { stderr: true }) const { code, stderr } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1) expect(code).toBe(1)
expect(stderr).toContain('Do not know how to serialize a BigInt') expect(stderr).toContain('Do not know how to serialize a BigInt')
}) })
})
}) })
...@@ -34,7 +34,7 @@ describe('dev mode', () => { ...@@ -34,7 +34,7 @@ describe('dev mode', () => {
}) })
// TODO enable that once turbopack supports middleware in 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 () => { beforeAll(async () => {
await nextBuild(appDir) await nextBuild(appDir)
......
...@@ -3,6 +3,7 @@ import { nextBuild } from 'next-test-utils' ...@@ -3,6 +3,7 @@ import { nextBuild } from 'next-test-utils'
import { join } from 'path' import { join } from 'path'
describe('Middleware validation during build', () => { describe('Middleware validation during build', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(__dirname, '..') const appDir = join(__dirname, '..')
const middlewareFile = join(appDir, 'middleware.js') const middlewareFile = join(appDir, 'middleware.js')
const middlewareError = 'Middleware is returning a response body' const middlewareError = 'Middleware is returning a response body'
...@@ -88,4 +89,5 @@ describe('Middleware validation during build', () => { ...@@ -88,4 +89,5 @@ describe('Middleware validation during build', () => {
expect(code).toBe(0) expect(code).toBe(0)
}) })
}) })
})
}) })
...@@ -14,6 +14,7 @@ const context = { ...@@ -14,6 +14,7 @@ const context = {
} }
describe('Middleware Production Prefetch', () => { describe('Middleware Production Prefetch', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
afterAll(() => killApp(context.app)) afterAll(() => killApp(context.app))
beforeAll(async () => { beforeAll(async () => {
const build = await nextBuild(context.appDir, undefined, { const build = await nextBuild(context.appDir, undefined, {
...@@ -72,4 +73,5 @@ describe('Middleware Production Prefetch', () => { ...@@ -72,4 +73,5 @@ describe('Middleware Production Prefetch', () => {
return attrs.find((src) => src.includes('/ssg-page-2')) ? 'nope' : 'yes' return attrs.find((src) => src.includes('/ssg-page-2')) ? 'nope' : 'yes'
}, 'yes') }, 'yes')
}) })
})
}) })
...@@ -264,6 +264,7 @@ async function hasImagePreloadBeforeCSSPreload() { ...@@ -264,6 +264,7 @@ async function hasImagePreloadBeforeCSSPreload() {
} }
describe('Image Component Tests', () => { describe('Image Component Tests', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
await nextBuild(appDir) await nextBuild(appDir)
appPort = await findPort() appPort = await findPort()
...@@ -311,7 +312,9 @@ describe('Image Component Tests', () => { ...@@ -311,7 +312,9 @@ describe('Image Component Tests', () => {
}) })
it('should add data-nimg data attribute based on layout', async () => { it('should add data-nimg data attribute based on layout', async () => {
expect( expect(
await browser.elementById('image-with-sizes').getAttribute('data-nimg') await browser
.elementById('image-with-sizes')
.getAttribute('data-nimg')
).toBe('responsive') ).toBe('responsive')
expect( expect(
await browser.elementById('basic-image').getAttribute('data-nimg') await browser.elementById('basic-image').getAttribute('data-nimg')
...@@ -396,4 +399,5 @@ describe('Image Component Tests', () => { ...@@ -396,4 +399,5 @@ describe('Image Component Tests', () => {
}) })
lazyLoadingTests() lazyLoadingTests()
}) })
})
}) })
...@@ -30,6 +30,7 @@ function runTests() { ...@@ -30,6 +30,7 @@ function runTests() {
} }
describe('Custom Resolver Tests', () => { describe('Custom Resolver Tests', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
await nextBuild(appDir) await nextBuild(appDir)
appPort = await findPort() appPort = await findPort()
...@@ -58,4 +59,5 @@ describe('Custom Resolver Tests', () => { ...@@ -58,4 +59,5 @@ describe('Custom Resolver Tests', () => {
}) })
runTests() runTests()
}) })
})
}) })
...@@ -25,6 +25,7 @@ function runTests() { ...@@ -25,6 +25,7 @@ function runTests() {
} }
describe('Image Component Tests In Prod Mode', () => { describe('Image Component Tests In Prod Mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
await nextBuild(appDir) await nextBuild(appDir)
appPort = await findPort() appPort = await findPort()
...@@ -35,6 +36,7 @@ describe('Image Component Tests In Prod Mode', () => { ...@@ -35,6 +36,7 @@ describe('Image Component Tests In Prod Mode', () => {
}) })
runTests() runTests()
})
}) })
describe('Image Component Tests In Dev Mode', () => { describe('Image Component Tests In Dev Mode', () => {
......
...@@ -15,6 +15,7 @@ let app ...@@ -15,6 +15,7 @@ let app
let browser let browser
describe('Image Component No IntersectionObserver test', () => { describe('Image Component No IntersectionObserver test', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
await nextBuild(appDir) await nextBuild(appDir)
appPort = await findPort() appPort = await findPort()
...@@ -68,4 +69,5 @@ describe('Image Component No IntersectionObserver test', () => { ...@@ -68,4 +69,5 @@ describe('Image Component No IntersectionObserver test', () => {
) )
}) })
}) })
})
}) })
...@@ -15,6 +15,7 @@ let appPort ...@@ -15,6 +15,7 @@ let appPort
let app let app
describe('Noscript Tests', () => { describe('Noscript Tests', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
await nextBuild(appDir) await nextBuild(appDir)
appPort = await findPort() appPort = await findPort()
...@@ -39,4 +40,5 @@ describe('Noscript Tests', () => { ...@@ -39,4 +40,5 @@ describe('Noscript Tests', () => {
) )
}) })
}) })
})
}) })
...@@ -15,7 +15,7 @@ let app ...@@ -15,7 +15,7 @@ let app
let devOutput let devOutput
describe('svgo-webpack with Image Component', () => { 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 () => { it('should not fail to build invalid usage of the Image component', async () => {
const { stderr, code } = await nextBuild(appDir, [], { stderr: true }) const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(stderr).toBeFalsy() expect(stderr).toBeFalsy()
...@@ -23,7 +23,7 @@ describe('svgo-webpack with Image Component', () => { ...@@ -23,7 +23,7 @@ describe('svgo-webpack with Image Component', () => {
}) })
}) })
describe('next dev', () => { describe('development mode', () => {
beforeAll(async () => { beforeAll(async () => {
devOutput = { stdout: '', stderr: '' } devOutput = { stdout: '', stderr: '' }
appPort = await findPort() appPort = await findPort()
......
...@@ -21,7 +21,7 @@ const handleOutput = (msg) => { ...@@ -21,7 +21,7 @@ const handleOutput = (msg) => {
} }
describe('TypeScript Image Component', () => { 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 () => { it('should fail to build invalid usage of the Image component', async () => {
const { stderr, code } = await nextBuild(appDir, [], { stderr: true }) const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(stderr).toMatch(/Failed to compile/) expect(stderr).toMatch(/Failed to compile/)
...@@ -47,7 +47,7 @@ describe('TypeScript Image Component', () => { ...@@ -47,7 +47,7 @@ describe('TypeScript Image Component', () => {
}) })
}) })
describe('next dev', () => { describe('development mode', () => {
beforeAll(async () => { beforeAll(async () => {
output = '' output = ''
appPort = await findPort() appPort = await findPort()
...@@ -75,6 +75,7 @@ describe('TypeScript Image Component', () => { ...@@ -75,6 +75,7 @@ describe('TypeScript Image Component', () => {
}) })
}) })
describe('development mode 2', () => {
it('should remove global image types when disabled (dev)', async () => { it('should remove global image types when disabled (dev)', async () => {
const content = await fs.readFile(nextConfig, 'utf8') const content = await fs.readFile(nextConfig, 'utf8')
await fs.writeFile( await fs.writeFile(
...@@ -87,4 +88,5 @@ describe('TypeScript Image Component', () => { ...@@ -87,4 +88,5 @@ describe('TypeScript Image Component', () => {
const envTypes = await fs.readFile(join(appDir, 'next-env.d.ts'), 'utf8') const envTypes = await fs.readFile(join(appDir, 'next-env.d.ts'), 'utf8')
expect(envTypes).not.toContain('image-types/global') expect(envTypes).not.toContain('image-types/global')
}) })
})
}) })
...@@ -15,7 +15,7 @@ let app ...@@ -15,7 +15,7 @@ let app
let devOutput let devOutput
describe('svgo-webpack with Image Component', () => { 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 () => { it('should not fail to build invalid usage of the Image component', async () => {
const { stderr, code } = await nextBuild(appDir, [], { stderr: true }) const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
const errors = stderr const errors = stderr
...@@ -26,7 +26,7 @@ describe('svgo-webpack with Image Component', () => { ...@@ -26,7 +26,7 @@ describe('svgo-webpack with Image Component', () => {
}) })
}) })
describe('next dev', () => { describe('development mode', () => {
beforeAll(async () => { beforeAll(async () => {
devOutput = { stdout: '', stderr: '' } devOutput = { stdout: '', stderr: '' }
appPort = await findPort() appPort = await findPort()
......
...@@ -21,7 +21,7 @@ const handleOutput = (msg) => { ...@@ -21,7 +21,7 @@ const handleOutput = (msg) => {
} }
describe('TypeScript Image Component', () => { 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 () => { it('should fail to build invalid usage of the Image component', async () => {
const { stderr, code } = await nextBuild(appDir, [], { stderr: true }) const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(stderr).toMatch(/Failed to compile/) expect(stderr).toMatch(/Failed to compile/)
...@@ -47,7 +47,7 @@ describe('TypeScript Image Component', () => { ...@@ -47,7 +47,7 @@ describe('TypeScript Image Component', () => {
}) })
}) })
describe('next dev', () => { describe('development mode', () => {
beforeAll(async () => { beforeAll(async () => {
output = '' output = ''
appPort = await findPort() appPort = await findPort()
......
...@@ -5,6 +5,7 @@ import { nextBuild, readNextBuildServerPageFile } from 'next-test-utils' ...@@ -5,6 +5,7 @@ import { nextBuild, readNextBuildServerPageFile } from 'next-test-utils'
const appDir = path.join(__dirname, '../app') const appDir = path.join(__dirname, '../app')
describe('Non-Next externalization', () => { describe('Non-Next externalization', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
await nextBuild(appDir) await nextBuild(appDir)
}) })
...@@ -13,4 +14,5 @@ describe('Non-Next externalization', () => { ...@@ -13,4 +14,5 @@ describe('Non-Next externalization', () => {
const content = readNextBuildServerPageFile(appDir, '/') const content = readNextBuildServerPageFile(appDir, '/')
expect(content).not.toContain('BrokenExternalMarker') expect(content).not.toContain('BrokenExternalMarker')
}) })
})
}) })
...@@ -79,7 +79,7 @@ describe('Non-Standard NODE_ENV', () => { ...@@ -79,7 +79,7 @@ describe('Non-Standard NODE_ENV', () => {
await killApp(app) await killApp(app)
expect(output).not.toContain(warningText) expect(output).not.toContain(warningText)
}) })
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should still DCE NODE_ENV specific code', async () => { it('should still DCE NODE_ENV specific code', async () => {
await nextBuild(appDir, undefined, { await nextBuild(appDir, undefined, {
env: { env: {
...@@ -103,6 +103,34 @@ describe('Non-Standard NODE_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 () => { it('should show the warning with NODE_ENV set to invalid value', async () => {
let output = '' let output = ''
...@@ -152,31 +180,4 @@ describe('Non-Standard NODE_ENV', () => { ...@@ -152,31 +180,4 @@ describe('Non-Standard NODE_ENV', () => {
await killApp(app) await killApp(app)
expect(output).toContain(warningText) 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)
})
}) })
...@@ -6,6 +6,7 @@ import { join } from 'path' ...@@ -6,6 +6,7 @@ import { join } from 'path'
const appDir = join(__dirname, '../') const appDir = join(__dirname, '../')
describe('Numeric Separator Support', () => { describe('Numeric Separator Support', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should successfully build for a JavaScript file', async () => { it('should successfully build for a JavaScript file', async () => {
const { code, stdout, stderr } = await nextBuild(appDir, [], { const { code, stdout, stderr } = await nextBuild(appDir, [], {
stdout: true, stdout: true,
...@@ -17,4 +18,5 @@ describe('Numeric Separator Support', () => { ...@@ -17,4 +18,5 @@ describe('Numeric Separator Support', () => {
expect(stdout).toContain('Compiled successfully') expect(stdout).toContain('Compiled successfully')
expect(stderr).not.toContain('Failed to compile') expect(stderr).not.toContain('Failed to compile')
}) })
})
}) })
...@@ -17,6 +17,7 @@ async function uncommentExport(page) { ...@@ -17,6 +17,7 @@ async function uncommentExport(page) {
} }
describe('Page Config', () => { describe('Page Config', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('builds without error when export const config is used outside page', async () => { it('builds without error when export const config is used outside page', async () => {
const { stderr } = await nextBuild(appDir, undefined, { stderr: true }) const { stderr } = await nextBuild(appDir, undefined, { stderr: true })
expect(stderr).not.toMatch(/Failed to compile\./) expect(stderr).not.toMatch(/Failed to compile\./)
...@@ -98,4 +99,5 @@ describe('Page Config', () => { ...@@ -98,4 +99,5 @@ describe('Page Config', () => {
await reset() await reset()
} }
}) })
})
}) })
...@@ -5,7 +5,7 @@ import { renderViaHTTP, findPort, launchApp, killApp } from 'next-test-utils' ...@@ -5,7 +5,7 @@ import { renderViaHTTP, findPort, launchApp, killApp } from 'next-test-utils'
const context = {} const context = {}
describe('Configuration', () => { describe('MDX-rs Configuration', () => {
beforeAll(async () => { beforeAll(async () => {
context.appPort = await findPort() context.appPort = await findPort()
context.server = await launchApp(join(__dirname, '../'), context.appPort) context.server = await launchApp(join(__dirname, '../'), context.appPort)
......
...@@ -22,6 +22,7 @@ let proxyServer ...@@ -22,6 +22,7 @@ let proxyServer
let nextDataRequests = [] let nextDataRequests = []
describe('Prefetching Links in viewport', () => { describe('Prefetching Links in viewport', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => { beforeAll(async () => {
await nextBuild(appDir) await nextBuild(appDir)
const port = await findPort() const port = await findPort()
...@@ -85,7 +86,9 @@ describe('Prefetching Links in viewport', () => { ...@@ -85,7 +86,9 @@ describe('Prefetching Links in viewport', () => {
.click() .click()
.waitForElementByCss('#another') .waitForElementByCss('#another')
expect(await browser.elementByCss('#another').text()).toBe('Hello world') expect(await browser.elementByCss('#another').text()).toBe(
'Hello world'
)
} finally { } finally {
stallJs = false stallJs = false
} }
...@@ -420,7 +423,9 @@ describe('Prefetching Links in viewport', () => { ...@@ -420,7 +423,9 @@ describe('Prefetching Links in viewport', () => {
console.log({ linkHrefs, scriptSrcs }) console.log({ linkHrefs, scriptSrcs })
expect(scriptSrcs.some((src) => src.includes('pages/index-'))).toBe(true) 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 () => { it('should not duplicate prefetches', async () => {
...@@ -554,4 +559,5 @@ describe('Prefetching Links in viewport', () => { ...@@ -554,4 +559,5 @@ describe('Prefetching Links in viewport', () => {
'/_next/data/test-build/ssg/dynamic/two.json', '/_next/data/test-build/ssg/dynamic/two.json',
]) ])
}) })
})
}) })
...@@ -6,6 +6,7 @@ import { nextBuild } from 'next-test-utils' ...@@ -6,6 +6,7 @@ import { nextBuild } from 'next-test-utils'
const appDir = join(__dirname, '..') const appDir = join(__dirname, '..')
describe('Invalid Prerender Catchall Params', () => { describe('Invalid Prerender Catchall Params', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should fail the build', async () => { it('should fail the build', async () => {
const out = await nextBuild(appDir, [], { stderr: true }) const out = await nextBuild(appDir, [], { stderr: true })
expect(out.stderr).toMatch(`Build error occurred`) expect(out.stderr).toMatch(`Build error occurred`)
...@@ -13,4 +14,5 @@ describe('Invalid Prerender Catchall Params', () => { ...@@ -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]' 'A required parameter (slug) was not provided as an array received string in getStaticPaths for /[...slug]'
) )
}) })
})
}) })
...@@ -6,6 +6,7 @@ import { nextBuild } from 'next-test-utils' ...@@ -6,6 +6,7 @@ import { nextBuild } from 'next-test-utils'
const appDir = join(__dirname, '..') const appDir = join(__dirname, '..')
describe('Legacy Prerender', () => { describe('Legacy Prerender', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
describe('handles old getStaticParams', () => { describe('handles old getStaticParams', () => {
it('should fail the build', async () => { it('should fail the build', async () => {
const out = await nextBuild(appDir, [], { stderr: true }) const out = await nextBuild(appDir, [], { stderr: true })
...@@ -15,4 +16,5 @@ describe('Legacy Prerender', () => { ...@@ -15,4 +16,5 @@ describe('Legacy Prerender', () => {
expect(out.stderr).toMatch('Keys that need to be moved: foo, baz.') expect(out.stderr).toMatch('Keys that need to be moved: foo, baz.')
}) })
}) })
})
}) })
...@@ -96,6 +96,9 @@ describe('SSG Prerender Revalidate', () => { ...@@ -96,6 +96,9 @@ describe('SSG Prerender Revalidate', () => {
// Regression test for https://github.com/vercel/next.js/issues/24806 // Regression test for https://github.com/vercel/next.js/issues/24806
describe('[regression] production mode and incremental cache size exceeded', () => { describe('[regression] production mode and incremental cache size exceeded', () => {
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
beforeAll(async () => { beforeAll(async () => {
await fs.remove(join(appDir, '.next')) await fs.remove(join(appDir, '.next'))
await nextBuild(appDir, []) await nextBuild(appDir, [])
...@@ -113,5 +116,7 @@ describe('SSG Prerender Revalidate', () => { ...@@ -113,5 +116,7 @@ describe('SSG Prerender Revalidate', () => {
runTests('/named', '/named') runTests('/named', '/named')
runTests('/nested', '/nested') runTests('/nested', '/nested')
runTests('/nested/named', '/nested/named') runTests('/nested/named', '/nested/named')
}
)
}) })
}) })
...@@ -265,7 +265,7 @@ describe('SSG Prerender', () => { ...@@ -265,7 +265,7 @@ describe('SSG Prerender', () => {
} }
}) })
}) })
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
describe('export mode', () => { describe('export mode', () => {
// disable fallback: true since this is an error during `next export` // disable fallback: true since this is an error during `next export`
const fallbackTruePages = [ const fallbackTruePages = [
...@@ -319,7 +319,10 @@ describe('SSG Prerender', () => { ...@@ -319,7 +319,10 @@ describe('SSG Prerender', () => {
for (const page of fallbackBlockingPages) { for (const page of fallbackBlockingPages) {
const pagePath = join(appDir, 'pages', page) const pagePath = join(appDir, 'pages', page)
fallbackBlockingPageContents[page] = await fs.readFile(pagePath, 'utf8') fallbackBlockingPageContents[page] = await fs.readFile(
pagePath,
'utf8'
)
await fs.writeFile( await fs.writeFile(
pagePath, pagePath,
fallbackBlockingPageContents[page].replace( fallbackBlockingPageContents[page].replace(
...@@ -374,10 +377,13 @@ describe('SSG Prerender', () => { ...@@ -374,10 +377,13 @@ describe('SSG Prerender', () => {
for (const route of routes) { for (const route of routes) {
await fs.access(join(exportDir, `${route}/index.html`)) 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() navigateTest()
}) })
})
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment