@@ -18,47 +18,72 @@ describe('Middleware Runtime', () => {
18
18
let next : NextInstance
19
19
20
20
const setup = ( { i18n } : { i18n : boolean } ) => {
21
- let nextConfigContent = ''
22
- const nextConfigPath = join ( __dirname , '../app/next.config.js' )
23
-
24
21
afterAll ( async ( ) => {
25
22
await next . destroy ( )
26
-
27
- if ( nextConfigContent ) {
28
- await fs . writeFile ( nextConfigPath , nextConfigContent )
29
- }
30
23
} )
31
24
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
- }
39
25
next = await createNext ( {
40
26
files : {
41
- 'next.config.js' : new FileRef (
42
- join ( __dirname , '../app/next.config.js' )
43
- ) ,
44
27
'middleware.js' : new FileRef ( join ( __dirname , '../app/middleware.js' ) ) ,
45
28
pages : new FileRef ( join ( __dirname , '../app/pages' ) ) ,
46
29
'shared-package' : new FileRef (
47
30
join ( __dirname , '../app/node_modules/shared-package' )
48
31
) ,
49
32
} ,
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
+ } ,
50
75
packageJson : {
51
76
scripts : {
52
77
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 ${
55
80
shouldRunTurboDevTest ( ) ? 'dev --turbo' : 'dev'
56
81
} `,
57
82
start : 'next start' ,
58
83
} ,
59
84
} ,
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' ,
62
87
env : {
63
88
ANOTHER_MIDDLEWARE_TEST : 'asdf2' ,
64
89
STRING_ENV_VAR : 'asdf3' ,
0 commit comments