@@ -409,7 +409,7 @@ function runTestFile(path, root, inspectPort, filesWatcher, testNamePatterns) {
409409 return subtest . start ( ) ;
410410}
411411
412- function watchFiles ( testFiles , root , inspectPort , testNamePatterns ) {
412+ function watchFiles ( testFiles , root , inspectPort , signal , testNamePatterns ) {
413413 const filesWatcher = new FilesWatcher ( { throttle : 500 , mode : 'filter' } ) ;
414414 filesWatcher . on ( 'changed' , ( { owners } ) => {
415415 filesWatcher . unfilterFilesOwnedBy ( owners ) ;
@@ -432,6 +432,10 @@ function watchFiles(testFiles, root, inspectPort, testNamePatterns) {
432432 triggerUncaughtException ( error , true /* fromPromise */ ) ;
433433 } ) ) ;
434434 } ) ;
435+ signal ?. addEventListener ( 'abort' , ( ) => {
436+ filesWatcher . clear ( ) ;
437+ root . postRun ( ) ;
438+ } , { __proto__ : null , once : true } ) ;
435439 return filesWatcher ;
436440}
437441
@@ -474,7 +478,7 @@ function run(options) {
474478 let postRun = ( ) => root . postRun ( ) ;
475479 let filesWatcher ;
476480 if ( watch ) {
477- filesWatcher = watchFiles ( testFiles , root , inspectPort , testNamePatterns ) ;
481+ filesWatcher = watchFiles ( testFiles , root , inspectPort , signal , testNamePatterns ) ;
478482 postRun = undefined ;
479483 }
480484 const runFiles = ( ) => {
0 commit comments