@@ -395,16 +395,17 @@ class TestRunner {
395
395
this . _result = new Result ( ) ;
396
396
this . _result . runs = testRuns ;
397
397
398
+ const terminationPromises = [ ] ;
398
399
const handleSIGINT = ( ) => this . _terminate ( TestResult . Terminated , 'SIGINT received' , false , null ) ;
399
400
const handleSIGHUP = ( ) => this . _terminate ( TestResult . Terminated , 'SIGHUP received' , false , null ) ;
400
401
const handleSIGTERM = ( ) => this . _terminate ( TestResult . Terminated , 'SIGTERM received' , true , null ) ;
401
402
const handleRejection = e => {
402
403
const { message, error } = this . _toError ( 'UNHANDLED PROMISE REJECTION' , e ) ;
403
- this . _terminate ( TestResult . Crashed , message , false , error ) ;
404
+ terminationPromises . push ( this . _terminate ( TestResult . Crashed , message , false , error ) ) ;
404
405
} ;
405
406
const handleException = e => {
406
407
const { message, error } = this . _toError ( 'UNHANDLED ERROR' , e ) ;
407
- this . _terminate ( TestResult . Crashed , message , false , error ) ;
408
+ terminationPromises . push ( this . _terminate ( TestResult . Crashed , message , false , error ) ) ;
408
409
} ;
409
410
process . on ( 'SIGINT' , handleSIGINT ) ;
410
411
process . on ( 'SIGHUP' , handleSIGHUP ) ;
@@ -415,7 +416,7 @@ class TestRunner {
415
416
let timeoutId ;
416
417
if ( totalTimeout ) {
417
418
timeoutId = setTimeout ( ( ) => {
418
- this . _terminate ( TestResult . Terminated , `Total timeout of ${ totalTimeout } ms reached.` , true /* force */ , null /* error */ ) ;
419
+ terminationPromises . push ( this . _terminate ( TestResult . Terminated , `Total timeout of ${ totalTimeout } ms reached.` , true /* force */ , null /* error */ ) ) ;
419
420
} , totalTimeout ) ;
420
421
}
421
422
await this . _runDelegateCallback ( this . _delegate . onStarted , [ testRuns ] ) ;
@@ -427,6 +428,7 @@ class TestRunner {
427
428
workerPromises . push ( this . _runWorker ( initialTestRunIndex , testRuns , i ) ) ;
428
429
}
429
430
await Promise . all ( workerPromises ) ;
431
+ await Promise . all ( terminationPromises ) ;
430
432
431
433
if ( testRuns . some ( run => run . isFailure ( ) ) )
432
434
this . _result . setResult ( TestResult . Failed , '' ) ;
0 commit comments