Skip to content

Commit

Permalink
test(config): add intergration case for vercel#37755
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Jun 17, 2022
1 parent 01f2aa6 commit 17e66c8
Showing 1 changed file with 70 additions and 9 deletions.
79 changes: 70 additions & 9 deletions test/integration/config-experimental-warning/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ describe('Config Experimental Warning', () => {
module.exports = {
target: 'server',
experimental: {
something: true
newNextLinkBehavior: true
}
}
`)
const { stderr } = await nextBuild(appDir, [], { stderr: true })
expect(stderr).toMatch(
'You have enabled experimental feature (something) in next.config.js.'
'You have enabled experimental feature (newNextLinkBehavior) in next.config.js.'
)
})

Expand All @@ -59,43 +59,104 @@ describe('Config Experimental Warning', () => {
module.exports = (phase) => ({
target: 'server',
experimental: {
something: true
newNextLinkBehavior: true
}
})
`)
const { stderr } = await nextBuild(appDir, [], { stderr: true })
expect(stderr).toMatch(
'You have enabled experimental feature (something) in next.config.js.'
'You have enabled experimental feature (newNextLinkBehavior) in next.config.js.'
)
})

it('should not show warning with default value', async () => {
configFile.write(`
module.exports = (phase) => ({
target: 'server',
experimental: {
newNextLinkBehavior: false
}
})
`)
const { stderr } = await nextBuild(appDir, [], { stderr: true })
expect(stderr).not.toMatch(
'You have enabled experimental feature (newNextLinkBehavior) in next.config.js.'
)
})

it('should show warning with config from object with experimental and multiple keys', async () => {
configFile.write(`
module.exports = {
experimental: {
something: true,
another: 1,
newNextLinkBehavior: true,
legacyBrowsers: false,
}
}
`)
const { stderr } = await nextBuild(appDir, [], { stderr: true })
expect(stderr).toMatch(
'You have enabled experimental features (something, another) in next.config.js.'
'You have enabled experimental features (newNextLinkBehavior, legacyBrowsers) in next.config.js.'
)
})

it('should show warning with next.config.mjs from object with experimental', async () => {
configFileMjs.write(`
const config = {
experimental: {
something: true,
newNextLinkBehavior: true,
}
}
export default config
`)
const { stderr } = await nextBuild(appDir, [], { stderr: true })
expect(stderr).toMatch(
'You have enabled experimental feature (something) in next.config.mjs.'
'You have enabled experimental feature (newNextLinkBehavior) in next.config.mjs.'
)
})

it('should show warning with next.config.js from object with non-exist experimental', async () => {
configFile.write(`
const config = {
experimental: {
foo: true
}
}
module.exports = config
`)
const { stderr } = await nextBuild(appDir, [], { stderr: true })
expect(stderr).toMatch(
'You have defined experimental feature (foo) in next.config.js that does not exists in this version'
)
})

it('should show warning with next.config.mjs from object with non-exist experimental', async () => {
configFileMjs.write(`
const config = {
experimental: {
foo: true
}
}
export default config
`)
const { stderr } = await nextBuild(appDir, [], { stderr: true })
expect(stderr).toMatch(
'You have defined experimental feature (foo) in next.config.mjs that does not exists in this version'
)
})

it('should show warning with next.config.js from object with multiple non-exist experimental', async () => {
configFile.write(`
const config = {
experimental: {
foo: true,
bar: false
}
}
module.exports = config
`)
const { stderr } = await nextBuild(appDir, [], { stderr: true })
expect(stderr).toMatch(
'You have defined experimental features (foo, bar) in next.config.js that do not exist in this version'
)
})
})

0 comments on commit 17e66c8

Please sign in to comment.