@@ -193,8 +193,8 @@ class SuiteContext {
193193}
194194
195195class Test extends AsyncResource {
196- # abortController;
197- # outerSignal;
196+ abortController ;
197+ outerSignal ;
198198 #reportedSubtest;
199199
200200constructor ( options ) {
@@ -292,16 +292,16 @@ class Test extends AsyncResource {
292292fn = 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
299299validateAbortSignal ( signal , 'options.signal' ) ;
300300if ( signal ) {
301301kResistStopPropagation ??= require ( 'internal/event_target' ) . kResistStopPropagation ;
302302}
303303
304- this . # outerSignal?. addEventListener (
304+ this . outerSignal ?. addEventListener (
305305'abort' ,
306306this . #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' ) ;
445445error . failureType = kAborted ;
446446this . #cancel( error ) ;
447447} ;
@@ -459,7 +459,7 @@ class Test extends AsyncResource {
459459) ;
460460this . startTime = this . startTime || this . endTime ; // If a test was canceled before it was started, e.g inside a hook
461461this . cancelled = true ;
462- this . # abortController. abort ( ) ;
462+ this . abortController . abort ( ) ;
463463}
464464
465465createHook ( name , fn , options ) {
@@ -527,7 +527,7 @@ class Test extends AsyncResource {
527527if ( this . signal . aborted ) {
528528return true ;
529529}
530- if ( this . # outerSignal?. aborted ) {
530+ if ( this . outerSignal ?. aborted ) {
531531this . #abortHandler( ) ;
532532return 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.
641641if ( this . parent !== null ) {
642- this . # abortController. abort ( ) ;
642+ this . abortController . abort ( ) ;
643643}
644644}
645645
@@ -679,7 +679,7 @@ class Test extends AsyncResource {
679679this . fail ( new ERR_TEST_FAILURE ( msg , kSubtestsFailed ) ) ;
680680}
681681
682- this . # outerSignal?. removeEventListener ( 'abort' , this . #abortHandler) ;
682+ this . outerSignal ?. removeEventListener ( 'abort' , this . #abortHandler) ;
683683this . mock ?. reset ( ) ;
684684
685685if ( this . parent !== null ) {
@@ -795,6 +795,14 @@ class TestHook extends Test {
795795super ( { __proto__ : null , fn, timeout, signal } ) ;
796796}
797797run ( 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+
798806this . #args = args ;
799807return super . run ( ) ;
800808}
0 commit comments