@@ -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 {
476475return { ctx, args : [ ctx ] } ;
477476}
478477
479- async [ kRunHook ] ( hook , args ) {
478+ async runHook ( hook , args ) {
480479validateOneOf ( hook , 'hook name' , kHookNames ) ;
481480try {
482481await ArrayPrototypeReduce ( this . hooks [ hook ] , async ( prev , hook ) => {
@@ -507,13 +506,13 @@ class Test extends AsyncResource {
507506const { args, ctx } = this . getRunArgs ( ) ;
508507const afterEach = runOnce ( async ( ) => {
509508if ( 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
514513try {
515514if ( this . parent ?. hooks . beforeEach . length > 0 ) {
516- await this . parent [ kRunHook ] ( 'beforeEach' , { args, ctx } ) ;
515+ await this . parent . runHook ( 'beforeEach' , { args, ctx } ) ;
517516}
518517const stopPromise = stopTest ( this . timeout , this . signal ) ;
519518const runArgs = ArrayPrototypeSlice ( args ) ;
@@ -761,9 +760,10 @@ class Suite extends Test {
761760const hookArgs = this . getRunArgs ( ) ;
762761const afterEach = runOnce ( async ( ) => {
763762if ( this . parent ?. hooks . afterEach . length > 0 ) {
764- await this . parent [ kRunHook ] ( 'afterEach' , hookArgs ) ;
763+ await this . parent . runHook ( 'afterEach' , hookArgs ) ;
765764}
766765} ) ;
766+
767767try {
768768this . parent . activeSubtests ++ ;
769769await this . buildSuite ;
@@ -775,19 +775,18 @@ class Suite extends Test {
775775return ;
776776}
777777
778-
779778if ( 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
785784const stopPromise = stopTest ( this . timeout , this . signal ) ;
786785const subtests = this . skipped || this . error ? [ ] : this . subtests ;
787786const promise = SafePromiseAll ( subtests , ( subtests ) => subtests . start ( ) ) ;
788787
789788await SafePromiseRace ( [ promise , stopPromise ] ) ;
790- await this [ kRunHook ] ( 'after' , hookArgs ) ;
789+ await this . runHook ( 'after' , hookArgs ) ;
791790await afterEach ( ) ;
792791
793792this . pass ( ) ;
0 commit comments