@@ -79,21 +79,21 @@ beforeEach(async () => {
79
79
afterEach ( async ( ) => {
80
80
jest . clearAllMocks ( )
81
81
jest . resetAllMocks ( )
82
-
82
+ delete process . env . NEXT_PRIVATE_TARGET
83
83
// Cleans up the temporary directory from `getTmpDir()` and do not make it
84
84
// the current directory anymore
85
85
this . restoreCwd ( )
86
86
await this . cleanup ( )
87
87
} )
88
88
89
- const DUMMY_PACKAGE_JSON = { name : 'dummy' , version : '1.0.0' }
90
- const netlifyConfig = { build : { command : 'next build' } }
89
+ const DUMMY_PACKAGE_JSON = { name : 'dummy' , version : '1.0.0' , scripts : { build : 'next build' } }
90
+ const netlifyConfig = { build : { command : 'npm run build' } }
91
91
92
92
describe ( 'preBuild()' , ( ) => {
93
93
test ( 'do nothing if the app has no build command' , async ( ) => {
94
94
await plugin . onPreBuild ( {
95
95
netlifyConfig : { build : { command : '' } } ,
96
- packageJson : { ... DUMMY_PACKAGE_JSON , scripts : { build : 'next build' } } ,
96
+ packageJson : DUMMY_PACKAGE_JSON ,
97
97
utils,
98
98
constants : { FUNCTIONS_SRC : 'out_functions' } ,
99
99
} )
@@ -115,7 +115,7 @@ describe('preBuild()', () => {
115
115
test ( 'run plugin if the app has next export in an unused script' , async ( ) => {
116
116
await plugin . onPreBuild ( {
117
117
netlifyConfig,
118
- packageJson : { ...DUMMY_PACKAGE_JSON , scripts : { export : 'next export' } } ,
118
+ packageJson : { ...DUMMY_PACKAGE_JSON , scripts : { export : 'next export' , build : 'next build' } } ,
119
119
utils,
120
120
constants : { } ,
121
121
} )
@@ -135,6 +135,7 @@ describe('preBuild()', () => {
135
135
136
136
test ( 'do nothing if app has next-on-netlify installed' , async ( ) => {
137
137
const packageJson = {
138
+ ...DUMMY_PACKAGE_JSON ,
138
139
dependencies : { 'next-on-netlify' : '123' } ,
139
140
}
140
141
await plugin . onPreBuild ( {
@@ -148,7 +149,7 @@ describe('preBuild()', () => {
148
149
149
150
test ( 'do nothing if app has next-on-netlify postbuild script' , async ( ) => {
150
151
const packageJson = {
151
- scripts : { postbuild : 'next-on-netlify' } ,
152
+ scripts : { build : 'next build' , postbuild : 'next-on-netlify' } ,
152
153
}
153
154
await plugin . onPreBuild ( {
154
155
netlifyConfig,
@@ -180,7 +181,7 @@ describe('preBuild()', () => {
180
181
test ( 'run plugin if app has build-storybook in an unused script' , async ( ) => {
181
182
await plugin . onPreBuild ( {
182
183
netlifyConfig,
183
- packageJson : { ...DUMMY_PACKAGE_JSON , scripts : { storybook : 'build-storybook' } } ,
184
+ packageJson : { ...DUMMY_PACKAGE_JSON , scripts : { storybook : 'build-storybook' , build : 'next build' } } ,
184
185
utils,
185
186
} )
186
187
expect ( process . env . NEXT_PRIVATE_TARGET ) . toBe ( 'serverless' )
@@ -237,7 +238,7 @@ describe('preBuild()', () => {
237
238
describe ( 'onBuild()' , ( ) => {
238
239
test ( 'does not run onBuild if using next-on-netlify' , async ( ) => {
239
240
const packageJson = {
240
- scripts : { postbuild : 'next-on-netlify' } ,
241
+ scripts : { postbuild : 'next-on-netlify' , build : 'next build' } ,
241
242
}
242
243
await useFixture ( 'publish_copy_files' )
243
244
await moveNextDist ( )
0 commit comments