Commit 3eca8860 authored by Adam Misiorny's avatar Adam Misiorny Committed by Joe Haddad

Prevent false positive experimental warning (#8284)

* Prevent false positive experimental warning

* Add tests for experimental warning
parent fc7e235f
......@@ -56,7 +56,11 @@ const experimentalWarning = execOnce(() => {
function assignDefaults(userConfig: { [key: string]: any }) {
Object.keys(userConfig).forEach((key: string) => {
if (key === 'experimental' && userConfig[key]) {
if (
key === 'experimental' &&
userConfig[key] &&
userConfig[key] !== defaultConfig[key]
) {
experimentalWarning()
}
......
/* eslint-env jest */
/* global jasmine */
import { join } from 'path'
import { nextBuild, File } from 'next-test-utils'
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 30
const appDir = join(__dirname, '..')
const configFile = new File(join(appDir, '/next.config.js'))
describe('Promise in next config', () => {
afterAll(() => configFile.delete())
it('should not show warning with default config from function', async () => {
configFile.write(`
module.exports = (phase, { defaultConfig }) => {
return {
target: 'server',
...defaultConfig,
}
}
`)
const { stderr } = await nextBuild(appDir, [], { stderr: true })
expect(stderr).not.toMatch(/Found experimental config:/)
})
it('should not show warning with config from object', async () => {
configFile.write(`
module.exports = {
target: 'server'
}
`)
const { stderr } = await nextBuild(appDir, [], { stderr: true })
expect(stderr).not.toMatch(/Found experimental config:/)
})
it('should show warning with config from object with experimental', async () => {
configFile.write(`
module.exports = {
target: 'server',
experimental: {
publicDirectory: true
}
}
`)
const { stderr } = await nextBuild(appDir, [], { stderr: true })
expect(stderr).toMatch(/Found experimental config:/)
})
it('should show warning with config from function with experimental', async () => {
configFile.write(`
module.exports = (phase) => ({
target: 'server',
experimental: {
publicDirectory: true
}
})
`)
const { stderr } = await nextBuild(appDir, [], { stderr: true })
expect(stderr).toMatch(/Found experimental config:/)
})
})
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