@@ -193,8 +193,8 @@ class SuiteContext {
193193}
194194
195195class Test extends AsyncResource {
196- # abortController;
197- # outerSignal;
196+ abortController ;
197+ outerSignal ;
198198 #reportedSubtest;
199199
200200 constructor ( options ) {
@@ -292,16 +292,16 @@ class Test extends AsyncResource {
292292 fn = noop ;
293293 }
294294
295- this . # abortController = new AbortController ( ) ;
296- this . # outerSignal = signal ;
297- this . signal = this . # abortController. signal ;
295+ this . abortController = new AbortController ( ) ;
296+ this . outerSignal = signal ;
297+ this . signal = this . abortController . signal ;
298298
299299 validateAbortSignal ( signal , 'options.signal' ) ;
300300 if ( signal ) {
301301 kResistStopPropagation ??= require ( 'internal/event_target' ) . kResistStopPropagation ;
302302 }
303303
304- this . # outerSignal?. addEventListener (
304+ this . outerSignal ?. addEventListener (
305305 'abort' ,
306306 this . #abortHandler,
307307 { __proto__ : null , [ kResistStopPropagation ] : true } ,
@@ -441,7 +441,7 @@ class Test extends AsyncResource {
441441 }
442442
443443 #abortHandler = ( ) => {
444- const error = this . # outerSignal?. reason || new AbortError ( 'The test was aborted' ) ;
444+ const error = this . outerSignal ?. reason || new AbortError ( 'The test was aborted' ) ;
445445 error . failureType = kAborted ;
446446 this . #cancel( error ) ;
447447 } ;
@@ -459,7 +459,7 @@ class Test extends AsyncResource {
459459 ) ;
460460 this . startTime = this . startTime || this . endTime ; // If a test was canceled before it was started, e.g inside a hook
461461 this . cancelled = true ;
462- this . # abortController. abort ( ) ;
462+ this . abortController . abort ( ) ;
463463 }
464464
465465 createHook ( name , fn , options ) {
@@ -527,7 +527,7 @@ class Test extends AsyncResource {
527527 if ( this . signal . aborted ) {
528528 return true ;
529529 }
530- if ( this . # outerSignal?. aborted ) {
530+ if ( this . outerSignal ?. aborted ) {
531531 this . #abortHandler( ) ;
532532 return true ;
533533 }
@@ -639,7 +639,7 @@ class Test extends AsyncResource {
639639 // Do not abort hooks and the root test as hooks instance are shared between tests suite so aborting them will
640640 // cause them to not run for further tests.
641641 if ( this . parent !== null ) {
642- this . # abortController. abort ( ) ;
642+ this . abortController . abort ( ) ;
643643 }
644644 }
645645
@@ -679,7 +679,7 @@ class Test extends AsyncResource {
679679 this . fail ( new ERR_TEST_FAILURE ( msg , kSubtestsFailed ) ) ;
680680 }
681681
682- this . # outerSignal?. removeEventListener ( 'abort' , this . #abortHandler) ;
682+ this . outerSignal ?. removeEventListener ( 'abort' , this . #abortHandler) ;
683683 this . mock ?. reset ( ) ;
684684
685685 if ( this . parent !== null ) {
@@ -795,6 +795,14 @@ class TestHook extends Test {
795795 super ( { __proto__ : null , fn, timeout, signal } ) ;
796796 }
797797 run ( args ) {
798+ if ( this . error && ! this . outerSignal ?. aborted ) {
799+ this . passed = false ;
800+ this . error = null ;
801+ this . abortController . abort ( ) ;
802+ this . abortController = new AbortController ( ) ;
803+ this . signal = this . abortController . signal ;
804+ }
805+
798806 this . #args = args ;
799807 return super . run ( ) ;
800808 }
0 commit comments