@@ -58,17 +58,31 @@ afterEach(async () => {
5858} )
5959
6060const DUMMY_PACKAGE_JSON = { name : 'dummy' , version : '1.0.0' }
61+ const netlifyConfig = { build : { } }
6162
6263describe ( 'preBuild()' , ( ) => {
6364 test ( 'fail build if the app has static html export in npm script' , async ( ) => {
6465 await expect (
6566 plugin . onPreBuild ( {
66- netlifyConfig : { } ,
67+ netlifyConfig : { build : { command : 'npm run build' } } ,
6768 packageJson : { ...DUMMY_PACKAGE_JSON , scripts : { build : 'next export' } } ,
6869 utils,
6970 constants : { FUNCTIONS_SRC : 'out_functions' } ,
7071 } ) ,
71- ) . rejects . toThrow ( '** Static HTML export next.js projects do not require this plugin **' )
72+ ) . rejects . toThrow (
73+ `Static HTML export Next.js projects do not require this plugin. Check your project's build command for 'next export'.` ,
74+ )
75+ } )
76+
77+ test ( 'do not fail build if the app has next export in an unused script' , async ( ) => {
78+ await expect (
79+ plugin . onPreBuild ( {
80+ netlifyConfig,
81+ packageJson : { ...DUMMY_PACKAGE_JSON , scripts : { export : 'next export' } } ,
82+ utils,
83+ constants : { } ,
84+ } ) ,
85+ ) . resolves
7286 } )
7387
7488 test ( 'fail build if the app has static html export in toml/ntl config' , async ( ) => {
@@ -79,7 +93,9 @@ describe('preBuild()', () => {
7993 utils,
8094 constants : { FUNCTIONS_SRC : 'out_functions' } ,
8195 } ) ,
82- ) . rejects . toThrow ( '** Static HTML export next.js projects do not require this plugin **' )
96+ ) . rejects . toThrow (
97+ `Static HTML export Next.js projects do not require this plugin. Check your project's build command for 'next export'.` ,
98+ )
8399 } )
84100
85101 test ( 'fail build if app has next-on-netlify installed' , async ( ) => {
@@ -88,7 +104,7 @@ describe('preBuild()', () => {
88104 }
89105 await expect (
90106 plugin . onPreBuild ( {
91- netlifyConfig : { } ,
107+ netlifyConfig,
92108 packageJson,
93109 utils,
94110 } ) ,
@@ -103,7 +119,7 @@ describe('preBuild()', () => {
103119 }
104120 await expect (
105121 plugin . onPreBuild ( {
106- netlifyConfig : { } ,
122+ netlifyConfig,
107123 packageJson,
108124 utils,
109125 } ) ,
@@ -115,7 +131,7 @@ describe('preBuild()', () => {
115131 test ( 'fail build if the app has no package.json' , async ( ) => {
116132 await expect (
117133 plugin . onPreBuild ( {
118- netlifyConfig : { } ,
134+ netlifyConfig,
119135 packageJson : { } ,
120136 utils,
121137 constants : { FUNCTIONS_SRC : 'out_functions' } ,
@@ -125,7 +141,7 @@ describe('preBuild()', () => {
125141
126142 test ( 'create next.config.js with correct target if file does not exist' , async ( ) => {
127143 await plugin . onPreBuild ( {
128- netlifyConfig : { } ,
144+ netlifyConfig,
129145 packageJson : DUMMY_PACKAGE_JSON ,
130146 utils,
131147 constants : { FUNCTIONS_SRC : 'out_functions' } ,
@@ -140,7 +156,7 @@ describe('preBuild()', () => {
140156 await useFixture ( fixtureName )
141157 await expect (
142158 plugin . onPreBuild ( {
143- netlifyConfig : { } ,
159+ netlifyConfig,
144160 packageJson : DUMMY_PACKAGE_JSON ,
145161 utils,
146162 constants : { FUNCTIONS_SRC : 'out_functions' } ,
0 commit comments