File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -207,6 +207,10 @@ class Compiler extends Tapable {
207
207
const finalCallback = ( err , stats ) => {
208
208
this . running = false ;
209
209
210
+ if ( err ) {
211
+ this . hooks . failed . call ( err ) ;
212
+ }
213
+
210
214
if ( callback !== undefined ) return callback ( err , stats ) ;
211
215
} ;
212
216
Original file line number Diff line number Diff line change @@ -493,4 +493,25 @@ describe("Compiler", () => {
493
493
} ) ;
494
494
} ) ;
495
495
} ) ;
496
+ it ( "should call the failed-hook on error" , done => {
497
+ const failedSpy = jest . fn ( ) ;
498
+ const compiler = webpack ( {
499
+ bail : true ,
500
+ context : __dirname ,
501
+ mode : "production" ,
502
+ entry : "./missing" ,
503
+ output : {
504
+ path : "/" ,
505
+ filename : "bundle.js"
506
+ } ,
507
+ } ) ;
508
+ compiler . hooks . failed . tap ( 'CompilerTest' , failedSpy ) ;
509
+ compiler . outputFileSystem = new MemoryFs ( ) ;
510
+ compiler . run ( ( err , stats ) => {
511
+ expect ( err ) . toBeTruthy ( ) ;
512
+ expect ( failedSpy ) . toHaveBeenCalledTimes ( 1 ) ;
513
+ expect ( failedSpy ) . toHaveBeenCalledWith ( err ) ;
514
+ done ( ) ;
515
+ } ) ;
516
+ } ) ;
496
517
} ) ;
You can’t perform that action at this time.
0 commit comments