Skip to content

Commit 2e36e7d

Browse files
authored
Fix middleware-general test for Turbopack (vercel#56211)
This test failed for Turbopack because of the rename from `i18n` to `__i18n` to not use that config. Turbopack does checking of config options to ensure it doesn't run when an option is not implemented, so that caused the test run to bail out.
1 parent 55a638b commit 2e36e7d

File tree

2 files changed

+46
-59
lines changed

2 files changed

+46
-59
lines changed

test/e2e/middleware-general/app/next.config.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

test/e2e/middleware-general/test/index.test.ts

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,47 +18,72 @@ describe('Middleware Runtime', () => {
1818
let next: NextInstance
1919

2020
const setup = ({ i18n }: { i18n: boolean }) => {
21-
let nextConfigContent = ''
22-
const nextConfigPath = join(__dirname, '../app/next.config.js')
23-
2421
afterAll(async () => {
2522
await next.destroy()
26-
27-
if (nextConfigContent) {
28-
await fs.writeFile(nextConfigPath, nextConfigContent)
29-
}
3023
})
3124
beforeAll(async () => {
32-
if (!i18n) {
33-
nextConfigContent = await fs.readFile(nextConfigPath, 'utf8')
34-
await fs.writeFile(
35-
nextConfigPath,
36-
nextConfigContent.replace('i18n', '__i18n')
37-
)
38-
}
3925
next = await createNext({
4026
files: {
41-
'next.config.js': new FileRef(
42-
join(__dirname, '../app/next.config.js')
43-
),
4427
'middleware.js': new FileRef(join(__dirname, '../app/middleware.js')),
4528
pages: new FileRef(join(__dirname, '../app/pages')),
4629
'shared-package': new FileRef(
4730
join(__dirname, '../app/node_modules/shared-package')
4831
),
4932
},
33+
nextConfig: {
34+
experimental: {
35+
webpackBuildWorker: true,
36+
},
37+
...(i18n
38+
? {
39+
i18n: {
40+
locales: ['en', 'fr', 'nl'],
41+
defaultLocale: 'en',
42+
},
43+
}
44+
: {}),
45+
async redirects() {
46+
return [
47+
{
48+
source: '/redirect-1',
49+
destination: '/somewhere/else',
50+
permanent: false,
51+
},
52+
]
53+
},
54+
async rewrites() {
55+
return [
56+
{
57+
source: '/rewrite-1',
58+
destination: '/ssr-page?from=config',
59+
},
60+
{
61+
source: '/rewrite-2',
62+
destination: '/about/a?from=next-config',
63+
},
64+
{
65+
source: '/sha',
66+
destination: '/shallow',
67+
},
68+
{
69+
source: '/rewrite-3',
70+
destination: '/blog/middleware-rewrite?hello=config',
71+
},
72+
]
73+
},
74+
},
5075
packageJson: {
5176
scripts: {
5277
setup: `cp -r ./shared-package ./node_modules`,
53-
build: 'yarn setup && next build',
54-
dev: `yarn setup && next ${
78+
build: 'pnpm run setup && next build',
79+
dev: `pnpm run setup && next ${
5580
shouldRunTurboDevTest() ? 'dev --turbo' : 'dev'
5681
}`,
5782
start: 'next start',
5883
},
5984
},
60-
startCommand: (global as any).isNextDev ? 'yarn dev' : 'yarn start',
61-
buildCommand: 'yarn build',
85+
startCommand: (global as any).isNextDev ? 'pnpm dev' : 'pnpm start',
86+
buildCommand: 'pnpm run build',
6287
env: {
6388
ANOTHER_MIDDLEWARE_TEST: 'asdf2',
6489
STRING_ENV_VAR: 'asdf3',

0 commit comments

Comments
 (0)