File size: 1,618 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 |
import stripAnsi from 'strip-ansi'
import { nextTestSetup } from 'e2e-utils'
import { check } from 'next-test-utils'
describe('next.config.js schema validating - defaultConfig', () => {
const { next, skipped } = nextTestSetup({
files: {
'pages/index.js': `
export default function Page() {
return <p>hello world</p>
}
`,
'next.config.js': `
module.exports = (phase, { defaultConfig }) => {
return defaultConfig
}
`,
},
skipDeployment: true,
})
if (skipped) {
return
}
it('should validate against defaultConfig', async () => {
const output = stripAnsi(next.cliOutput)
expect(output).not.toContain('Invalid next.config.js options detected')
})
})
describe('next.config.js schema validating - invalid config', () => {
const { next, isNextStart, skipped } = nextTestSetup({
files: {
'pages/index.js': `
export default function Page() {
return <p>hello world</p>
}
`,
'next.config.js': `
module.exports = {
badKey: 'badValue'
}
`,
},
skipDeployment: true,
})
if (skipped) {
return
}
it('should warn the invalid next config', async () => {
await check(() => {
const output = stripAnsi(next.cliOutput)
const warningTimes = output.split('badKey').length - 1
expect(output).toContain('Invalid next.config.js options detected')
expect(output).toContain('badKey')
// for next start and next build we both display the warnings
expect(warningTimes).toBe(isNextStart ? 2 : 1)
return 'success'
}, 'success')
})
})
|