@@ -75,7 +75,6 @@ const testNamePatterns = testNamePatternFlag?.length > 0 ?
7575 ( re ) => convertStringToRegExp ( re , '--test-name-pattern' )
7676 ) : null ;
7777const kShouldAbort = Symbol ( 'kShouldAbort' ) ;
78- const kRunHook = Symbol ( 'kRunHook' ) ;
7978const kHookNames = ObjectSeal ( [ 'before' , 'after' , 'beforeEach' , 'afterEach' ] ) ;
8079const kUnwrapErrors = new SafeSet ( )
8180 . add ( kTestCodeFailure ) . add ( kHookFailure )
@@ -476,7 +475,7 @@ class Test extends AsyncResource {
476475 return { ctx, args : [ ctx ] } ;
477476 }
478477
479- async [ kRunHook ] ( hook , args ) {
478+ async runHook ( hook , args ) {
480479 validateOneOf ( hook , 'hook name' , kHookNames ) ;
481480 try {
482481 await ArrayPrototypeReduce ( this . hooks [ hook ] , async ( prev , hook ) => {
@@ -507,13 +506,13 @@ class Test extends AsyncResource {
507506 const { args, ctx } = this . getRunArgs ( ) ;
508507 const afterEach = runOnce ( async ( ) => {
509508 if ( this . parent ?. hooks . afterEach . length > 0 ) {
510- await this . parent [ kRunHook ] ( 'afterEach' , { args, ctx } ) ;
509+ await this . parent . runHook ( 'afterEach' , { args, ctx } ) ;
511510 }
512511 } ) ;
513512
514513 try {
515514 if ( this . parent ?. hooks . beforeEach . length > 0 ) {
516- await this . parent [ kRunHook ] ( 'beforeEach' , { args, ctx } ) ;
515+ await this . parent . runHook ( 'beforeEach' , { args, ctx } ) ;
517516 }
518517 const stopPromise = stopTest ( this . timeout , this . signal ) ;
519518 const runArgs = ArrayPrototypeSlice ( args ) ;
@@ -761,9 +760,10 @@ class Suite extends Test {
761760 const hookArgs = this . getRunArgs ( ) ;
762761 const afterEach = runOnce ( async ( ) => {
763762 if ( this . parent ?. hooks . afterEach . length > 0 ) {
764- await this . parent [ kRunHook ] ( 'afterEach' , hookArgs ) ;
763+ await this . parent . runHook ( 'afterEach' , hookArgs ) ;
765764 }
766765 } ) ;
766+
767767 try {
768768 this . parent . activeSubtests ++ ;
769769 await this . buildSuite ;
@@ -775,19 +775,18 @@ class Suite extends Test {
775775 return ;
776776 }
777777
778-
779778 if ( this . parent ?. hooks . beforeEach . length > 0 ) {
780- await this . parent [ kRunHook ] ( 'beforeEach' , hookArgs ) ;
779+ await this . parent . runHook ( 'beforeEach' , hookArgs ) ;
781780 }
782781
783- await this [ kRunHook ] ( 'before' , hookArgs ) ;
782+ await this . runHook ( 'before' , hookArgs ) ;
784783
785784 const stopPromise = stopTest ( this . timeout , this . signal ) ;
786785 const subtests = this . skipped || this . error ? [ ] : this . subtests ;
787786 const promise = SafePromiseAll ( subtests , ( subtests ) => subtests . start ( ) ) ;
788787
789788 await SafePromiseRace ( [ promise , stopPromise ] ) ;
790- await this [ kRunHook ] ( 'after' , hookArgs ) ;
789+ await this . runHook ( 'after' , hookArgs ) ;
791790 await afterEach ( ) ;
792791
793792 this . pass ( ) ;
0 commit comments