@@ -208,11 +208,26 @@ describe('onBuild()', () => {
208208 test ( "fails if BUILD_ID doesn't exist" , async ( ) => {
209209 await moveNextDist ( )
210210 await unlink ( path . join ( process . cwd ( ) , '.next/BUILD_ID' ) )
211- const failBuild = jest . fn ( ) . mockImplementation ( ( ) => {
212- throw new Error ( 'BUILD_ID does not exist' )
211+ const failBuild = jest . fn ( ) . mockImplementation ( ( err ) => {
212+ throw new Error ( err )
213213 } )
214+ expect ( ( ) => plugin . onBuild ( { ...defaultArgs , utils : { ...utils , build : { failBuild } } } ) ) . rejects . toThrow (
215+ `In most cases it should be set to ".next", unless you have chosen a custom "distDir" in your Next config.` ,
216+ )
217+ expect ( failBuild ) . toHaveBeenCalled ( )
218+ } )
219+
220+ test ( "fails with helpful warning if BUILD_ID doesn't exist and publish is 'out'" , async ( ) => {
221+ await moveNextDist ( )
222+ await unlink ( path . join ( process . cwd ( ) , '.next/BUILD_ID' ) )
223+ const failBuild = jest . fn ( ) . mockImplementation ( ( err ) => {
224+ throw new Error ( err )
225+ } )
226+ netlifyConfig . build . publish = path . resolve ( 'out' )
214227
215- expect ( ( ) => plugin . onBuild ( { ...defaultArgs , utils : { ...utils , build : { failBuild } } } ) ) . rejects . toThrow ( )
228+ expect ( ( ) => plugin . onBuild ( { ...defaultArgs , utils : { ...utils , build : { failBuild } } } ) ) . rejects . toThrow (
229+ `Your publish directory is set to "out", but in most cases it should be ".next".` ,
230+ )
216231 expect ( failBuild ) . toHaveBeenCalled ( )
217232 } )
218233
0 commit comments