mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
## What? Converts existing `createNext()` usage into `nextTestSetup()`. `createNext()` was the setup step we had before `nextTestSetup()` was added. This PR focused on the simple conversion cases. There will be a follow-up to complete the last few. --------- Co-authored-by: Cursor <[email protected]>
86 lines
1.9 KiB
TypeScript
86 lines
1.9 KiB
TypeScript
import { FileRef, nextTestSetup } from 'e2e-utils'
|
|
import { join } from 'path'
|
|
|
|
describe('fallback export error', () => {
|
|
const { next } = nextTestSetup({
|
|
files: {
|
|
pages: new FileRef(join(__dirname, 'pages')),
|
|
},
|
|
nextConfig: {
|
|
output: 'export',
|
|
},
|
|
skipStart: true,
|
|
})
|
|
|
|
it('should have built', async () => {
|
|
const result = await next.build()
|
|
expect(result.exitCode).toBe(0)
|
|
})
|
|
|
|
it('should not error with default exportPathMap', async () => {
|
|
const result = await next.build()
|
|
console.log(result.cliOutput)
|
|
|
|
expect(result.exitCode).toBe(0)
|
|
expect(result.cliOutput).not.toContain(
|
|
'Found pages with `fallback` enabled'
|
|
)
|
|
})
|
|
|
|
it('should not error with valid exportPathMap', async () => {
|
|
await next.patchFile(
|
|
'next.config.js',
|
|
`
|
|
module.exports = {
|
|
output: 'export',
|
|
exportPathMap() {
|
|
return {
|
|
'/': { page: '/' },
|
|
}
|
|
}
|
|
}
|
|
`
|
|
)
|
|
|
|
try {
|
|
const result = await next.build()
|
|
console.log(result.cliOutput)
|
|
|
|
expect(result.exitCode).toBe(0)
|
|
expect(result.cliOutput).not.toContain(
|
|
'Found pages with `fallback` enabled'
|
|
)
|
|
} finally {
|
|
await next.deleteFile('next.config.js')
|
|
}
|
|
})
|
|
|
|
it('should error with invalid exportPathMap', async () => {
|
|
await next.stop()
|
|
await next.patchFile(
|
|
'next.config.js',
|
|
`
|
|
module.exports = {
|
|
output: 'export',
|
|
exportPathMap() {
|
|
return {
|
|
'/': { page: '/' },
|
|
'/second': { page: '/[...slug]' }
|
|
}
|
|
}
|
|
}
|
|
`
|
|
)
|
|
|
|
try {
|
|
const result = await next.build()
|
|
console.log(result.cliOutput)
|
|
|
|
expect(result.exitCode).toBe(1)
|
|
expect(result.cliOutput).toContain('Found pages with `fallback` enabled')
|
|
} finally {
|
|
await next.deleteFile('next.config.js')
|
|
}
|
|
})
|
|
})
|