File size: 2,071 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'e2e-utils'
import { join } from 'path'
describe('fallback export error', () => {
let next: NextInstance
beforeAll(async () => {
next = await createNext({
files: {
pages: new FileRef(join(__dirname, 'pages')),
},
nextConfig: {
output: 'export',
},
skipStart: true,
})
})
afterAll(() => next.destroy())
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')
}
})
})
|