1
- // https://github.com/nodejs/node/blob/f8ce9117b19702487eb600493d941f7876e00e01 /lib/internal/test_runner/test.js
1
+ // https://github.com/nodejs/node/blob/8302b0add01758713246117d3d0533cd212f160d /lib/internal/test_runner/test.js
2
2
3
3
'use strict'
4
4
@@ -80,7 +80,6 @@ const testNamePatterns = testNamePatternFlag?.length > 0
80
80
)
81
81
: null
82
82
const kShouldAbort = Symbol ( 'kShouldAbort' )
83
- const kRunHook = Symbol ( 'kRunHook' )
84
83
const kHookNames = ObjectSeal ( [ 'before' , 'after' , 'beforeEach' , 'afterEach' ] )
85
84
const kUnwrapErrors = new SafeSet ( )
86
85
. add ( kTestCodeFailure ) . add ( kHookFailure )
@@ -464,7 +463,7 @@ class Test extends AsyncResource {
464
463
return { ctx, args : [ ctx ] }
465
464
}
466
465
467
- async [ kRunHook ] ( hook , args ) {
466
+ async runHook ( hook , args ) {
468
467
validateOneOf ( hook , 'hook name' , kHookNames )
469
468
try {
470
469
await ArrayPrototypeReduce ( this . hooks [ hook ] , async ( prev , hook ) => {
@@ -495,13 +494,13 @@ class Test extends AsyncResource {
495
494
const { args, ctx } = this . getRunArgs ( )
496
495
const afterEach = runOnce ( async ( ) => {
497
496
if ( this . parent ?. hooks . afterEach . length > 0 ) {
498
- await this . parent [ kRunHook ] ( 'afterEach' , { args, ctx } )
497
+ await this . parent . runHook ( 'afterEach' , { args, ctx } )
499
498
}
500
499
} )
501
500
502
501
try {
503
502
if ( this . parent ?. hooks . beforeEach . length > 0 ) {
504
- await this . parent [ kRunHook ] ( 'beforeEach' , { args, ctx } )
503
+ await this . parent . runHook ( 'beforeEach' , { args, ctx } )
505
504
}
506
505
const stopPromise = stopTest ( this . timeout , this . signal )
507
506
const runArgs = ArrayPrototypeSlice ( args )
@@ -751,9 +750,10 @@ class Suite extends Test {
751
750
const hookArgs = this . getRunArgs ( )
752
751
const afterEach = runOnce ( async ( ) => {
753
752
if ( this . parent ?. hooks . afterEach . length > 0 ) {
754
- await this . parent [ kRunHook ] ( 'afterEach' , hookArgs )
753
+ await this . parent . runHook ( 'afterEach' , hookArgs )
755
754
}
756
755
} )
756
+
757
757
try {
758
758
this . parent . activeSubtests ++
759
759
await this . buildSuite
@@ -766,17 +766,17 @@ class Suite extends Test {
766
766
}
767
767
768
768
if ( this . parent ?. hooks . beforeEach . length > 0 ) {
769
- await this . parent [ kRunHook ] ( 'beforeEach' , hookArgs )
769
+ await this . parent . runHook ( 'beforeEach' , hookArgs )
770
770
}
771
771
772
- await this [ kRunHook ] ( 'before' , hookArgs )
772
+ await this . runHook ( 'before' , hookArgs )
773
773
774
774
const stopPromise = stopTest ( this . timeout , this . signal )
775
775
const subtests = this . skipped || this . error ? [ ] : this . subtests
776
776
const promise = SafePromiseAll ( subtests , ( subtests ) => subtests . start ( ) )
777
777
778
778
await SafePromiseRace ( [ promise , stopPromise ] )
779
- await this [ kRunHook ] ( 'after' , hookArgs )
779
+ await this . runHook ( 'after' , hookArgs )
780
780
await afterEach ( )
781
781
782
782
this . pass ( )
0 commit comments