Unverified Commit 525ffb43 authored by Steven's avatar Steven Committed by GitHub

chore: remove experimental `appDir: true` from tests (#52291)

The experimental flag is no longer needed.

https://nextjs.org/blog/next-13-4
parent 8ed2b275
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
appDir: true,
},
}
module.exports = nextConfig
module.exports = { module.exports = {
experimental: { experimental: {
appDir: true,
serverComponentsExternalPackages: ['package'], serverComponentsExternalPackages: ['package'],
}, },
} }
/**
* @type {import('next').NextConfig}
*/
module.exports = {
experimental: {
appDir: true,
},
}
module.exports = {
experimental: {
appDir: true,
},
}
...@@ -79,9 +79,6 @@ module.exports = { ...@@ -79,9 +79,6 @@ module.exports = {
path: 'next.config.js', path: 'next.config.js',
content: ` content: `
module.exports = { module.exports = {
experimental: {
appDir: true,
},
generateBuildId: () => 'BUILD_ID', generateBuildId: () => 'BUILD_ID',
webpack(config) { webpack(config) {
config.optimization.minimize = false config.optimization.minimize = false
...@@ -99,9 +96,6 @@ module.exports = { ...@@ -99,9 +96,6 @@ module.exports = {
path: 'next.config.js', path: 'next.config.js',
content: ` content: `
module.exports = { module.exports = {
experimental: {
appDir: true,
},
generateBuildId: () => 'BUILD_ID' generateBuildId: () => 'BUILD_ID'
} }
`, `,
......
...@@ -345,7 +345,6 @@ describe('ReactRefreshRegression app', () => { ...@@ -345,7 +345,6 @@ describe('ReactRefreshRegression app', () => {
}); });
module.exports = withMDX({ module.exports = withMDX({
pageExtensions: ["js", "mdx"], pageExtensions: ["js", "mdx"],
experimental: { appDir: true },
}); });
` `
) )
......
...@@ -5,7 +5,6 @@ import { sandbox } from 'development-sandbox' ...@@ -5,7 +5,6 @@ import { sandbox } from 'development-sandbox'
import { outdent } from 'outdent' import { outdent } from 'outdent'
const initialFiles = new Map([ const initialFiles = new Map([
['next.config.js', 'module.exports = { experimental: { appDir: true } }'],
['app/_.js', ''], // app dir need to exists, otherwise the SWC RSC checks will not run ['app/_.js', ''], // app dir need to exists, otherwise the SWC RSC checks will not run
[ [
'pages/index.js', 'pages/index.js',
......
...@@ -30,16 +30,6 @@ const appDirFiles: File[] = [ ...@@ -30,16 +30,6 @@ const appDirFiles: File[] = [
} }
`, `,
}, },
{
filename: 'next.config.js',
content: `
module.exports = {
experimental: {
appDir: true
}
}
`,
},
] ]
const pagesFiles: File[] = [ const pagesFiles: File[] = [
{ {
...@@ -65,7 +55,6 @@ it.each([ ...@@ -65,7 +55,6 @@ it.each([
content: ` content: `
module.exports = { module.exports = {
experimental: { experimental: {
appDir: true,
webpackBuildWorker: true, webpackBuildWorker: true,
} }
} }
......
module.exports = {
experimental: {
appDir: false,
},
}
...@@ -81,51 +81,7 @@ describe('Next Build', () => { ...@@ -81,51 +81,7 @@ describe('Next Build', () => {
) )
}) })
// Consolidate two tests below when the `appDir` is released.
test('base directories are linted by default during builds', async () => { test('base directories are linted by default during builds', async () => {
dirBaseDirectoriesConfigFile.write(`
module.exports = {
experimental: {
appDir: false,
}
}
`)
const { stdout, stderr } = await nextBuild(dirBaseDirectories, [], {
stdout: true,
stderr: true,
})
const output = stdout + stderr
expect(output).toContain('Failed to compile')
expect(output).toContain(
'Error: `next/head` should not be imported in `pages/_document.js`. Use `<Head />` from `next/document` instead'
)
expect(output).toContain(
'Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images.'
)
expect(output).toContain('Warning: Do not include stylesheets manually')
expect(output).toContain('Warning: Synchronous scripts should not be used')
expect(output).not.toContain(
'Warning: `rel="preconnect"` is missing from Google Font'
)
// Files in pages, components, lib, and src directories are linted
expect(output).toContain('pages/_document.js')
expect(output).toContain('components/bar.js')
expect(output).toContain('lib/foo.js')
expect(output).toContain('src/index.js')
expect(output).not.toContain('app/layout.js')
})
test('base directories with appDir flag are linted by default during builds', async () => {
dirBaseDirectoriesConfigFile.write(`
module.exports = {
experimental: {
appDir: true,
}
}
`)
const { stdout, stderr } = await nextBuild(dirBaseDirectories, [], { const { stdout, stderr } = await nextBuild(dirBaseDirectories, [], {
stdout: true, stdout: true,
stderr: true, stderr: true,
...@@ -146,7 +102,7 @@ describe('Next Build', () => { ...@@ -146,7 +102,7 @@ describe('Next Build', () => {
'Warning: `rel="preconnect"` is missing from Google Font' 'Warning: `rel="preconnect"` is missing from Google Font'
) )
// Files in pages, app, components, lib, and src directories are linted // Files in app, pages, components, lib, and src directories are linted
expect(output).toContain('pages/_document.js') expect(output).toContain('pages/_document.js')
expect(output).toContain('components/bar.js') expect(output).toContain('components/bar.js')
expect(output).toContain('lib/foo.js') expect(output).toContain('lib/foo.js')
......
...@@ -19,9 +19,6 @@ const dirPluginCoreWebVitalsConfig = join( ...@@ -19,9 +19,6 @@ const dirPluginCoreWebVitalsConfig = join(
) )
const dirIgnoreDuringBuilds = join(__dirname, '../ignore-during-builds') const dirIgnoreDuringBuilds = join(__dirname, '../ignore-during-builds')
const dirBaseDirectories = join(__dirname, '../base-directories') const dirBaseDirectories = join(__dirname, '../base-directories')
const dirBaseDirectoriesConfigFile = new File(
join(dirBaseDirectories, '/next.config.js')
)
const dirCustomDirectories = join(__dirname, '../custom-directories') const dirCustomDirectories = join(__dirname, '../custom-directories')
const dirConfigInPackageJson = join(__dirname, '../config-in-package-json') const dirConfigInPackageJson = join(__dirname, '../config-in-package-json')
const dirInvalidOlderEslintVersion = join( const dirInvalidOlderEslintVersion = join(
...@@ -182,49 +179,7 @@ describe('Next Lint', () => { ...@@ -182,49 +179,7 @@ describe('Next Lint', () => {
) )
}) })
// Consolidate two tests below when the `appDir` is released.
test('base directories are linted by default', async () => { test('base directories are linted by default', async () => {
dirBaseDirectoriesConfigFile.write(`
module.exports = {
experimental: {
appDir: false,
}
}
`)
const { stdout, stderr } = await nextLint(dirBaseDirectories, [], {
stdout: true,
stderr: true,
})
const output = stdout + stderr
expect(output).toContain(
'Error: `next/head` should not be imported in `pages/_document.js`. Use `<Head />` from `next/document` instead'
)
expect(output).toContain(
'Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images.'
)
expect(output).toContain('Warning: Do not include stylesheets manually')
expect(output).toContain('Warning: Synchronous scripts should not be used')
expect(output).not.toContain(
'Warning: `rel="preconnect"` is missing from Google Font'
)
// Files in pages, components, lib, and src directories are linted
expect(output).toContain('pages/_document.js')
expect(output).toContain('components/bar.js')
expect(output).toContain('lib/foo.js')
expect(output).toContain('src/index.js')
expect(output).not.toContain('app/layout.js')
})
test('base directories with appDir flag are linted by default', async () => {
dirBaseDirectoriesConfigFile.write(`
module.exports = {
experimental: {
appDir: true,
}
}
`)
const { stdout, stderr } = await nextLint(dirBaseDirectories, [], { const { stdout, stderr } = await nextLint(dirBaseDirectories, [], {
stdout: true, stdout: true,
stderr: true, stderr: true,
...@@ -243,7 +198,7 @@ describe('Next Lint', () => { ...@@ -243,7 +198,7 @@ describe('Next Lint', () => {
'Warning: `rel="preconnect"` is missing from Google Font' 'Warning: `rel="preconnect"` is missing from Google Font'
) )
// Files in pages, app, components, lib, and src directories are linted // Files in app, pages, components, lib, and src directories are linted
expect(output).toContain('pages/_document.js') expect(output).toContain('pages/_document.js')
expect(output).toContain('components/bar.js') expect(output).toContain('components/bar.js')
expect(output).toContain('lib/foo.js') expect(output).toContain('lib/foo.js')
......
...@@ -5,10 +5,6 @@ import { check, findPort, killApp, launchApp, nextBuild } from 'next-test-utils' ...@@ -5,10 +5,6 @@ import { check, findPort, killApp, launchApp, nextBuild } from 'next-test-utils'
const appDir = path.join(__dirname, '..') const appDir = path.join(__dirname, '..')
const setupAppDir = async () => { const setupAppDir = async () => {
await fs.writeFile(
path.join(__dirname, '../next.config.js'),
'module.exports = { experimental: { appDir: true } }'
)
await fs.mkdir(path.join(__dirname, '../app')) await fs.mkdir(path.join(__dirname, '../app'))
await fs.writeFile( await fs.writeFile(
path.join(__dirname, '../app/layout.js'), path.join(__dirname, '../app/layout.js'),
...@@ -29,7 +25,6 @@ const setupAppDir = async () => { ...@@ -29,7 +25,6 @@ const setupAppDir = async () => {
return async function teardownAppDir() { return async function teardownAppDir() {
await fs.remove(path.join(__dirname, '../app')) await fs.remove(path.join(__dirname, '../app'))
await fs.remove(path.join(__dirname, '../next.config.js'))
} }
} }
......
...@@ -47,11 +47,6 @@ describe('app-dir edge runtime with wasm', () => { ...@@ -47,11 +47,6 @@ describe('app-dir edge runtime with wasm', () => {
react: 'experimental', react: 'experimental',
'react-dom': 'experimental', 'react-dom': 'experimental',
}, },
nextConfig: {
experimental: {
appDir: true,
},
},
}) })
}) })
afterAll(() => next.destroy()) afterAll(() => next.destroy())
......
...@@ -39,9 +39,6 @@ describe('should set-up next', () => { ...@@ -39,9 +39,6 @@ describe('should set-up next', () => {
eslint: { eslint: {
ignoreDuringBuilds: true, ignoreDuringBuilds: true,
}, },
experimental: {
appDir: true,
},
output: 'standalone', output: 'standalone',
}, },
}) })
......
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