Skip to content

Commit b3b384e

Browse files
cjihrigMoLow
authored andcommitted
fix: don't use a symbol for runHook()
This is not exposed to userland, so there is no need to put it behind a symbol. PR-URL: nodejs/node#45792 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Matteo Collina <[email protected]> (cherry picked from commit 8302b0add01758713246117d3d0533cd212f160d)
1 parent b942f93 commit b3b384e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/internal/test_runner/test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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
22

33
'use strict'
44

@@ -80,7 +80,6 @@ const testNamePatterns = testNamePatternFlag?.length > 0
8080
)
8181
: null
8282
const kShouldAbort = Symbol('kShouldAbort')
83-
const kRunHook = Symbol('kRunHook')
8483
const kHookNames = ObjectSeal(['before', 'after', 'beforeEach', 'afterEach'])
8584
const kUnwrapErrors = new SafeSet()
8685
.add(kTestCodeFailure).add(kHookFailure)
@@ -464,7 +463,7 @@ class Test extends AsyncResource {
464463
return { ctx, args: [ctx] }
465464
}
466465

467-
async [kRunHook] (hook, args) {
466+
async runHook (hook, args) {
468467
validateOneOf(hook, 'hook name', kHookNames)
469468
try {
470469
await ArrayPrototypeReduce(this.hooks[hook], async (prev, hook) => {
@@ -495,13 +494,13 @@ class Test extends AsyncResource {
495494
const { args, ctx } = this.getRunArgs()
496495
const afterEach = runOnce(async () => {
497496
if (this.parent?.hooks.afterEach.length > 0) {
498-
await this.parent[kRunHook]('afterEach', { args, ctx })
497+
await this.parent.runHook('afterEach', { args, ctx })
499498
}
500499
})
501500

502501
try {
503502
if (this.parent?.hooks.beforeEach.length > 0) {
504-
await this.parent[kRunHook]('beforeEach', { args, ctx })
503+
await this.parent.runHook('beforeEach', { args, ctx })
505504
}
506505
const stopPromise = stopTest(this.timeout, this.signal)
507506
const runArgs = ArrayPrototypeSlice(args)
@@ -751,9 +750,10 @@ class Suite extends Test {
751750
const hookArgs = this.getRunArgs()
752751
const afterEach = runOnce(async () => {
753752
if (this.parent?.hooks.afterEach.length > 0) {
754-
await this.parent[kRunHook]('afterEach', hookArgs)
753+
await this.parent.runHook('afterEach', hookArgs)
755754
}
756755
})
756+
757757
try {
758758
this.parent.activeSubtests++
759759
await this.buildSuite
@@ -766,17 +766,17 @@ class Suite extends Test {
766766
}
767767

768768
if (this.parent?.hooks.beforeEach.length > 0) {
769-
await this.parent[kRunHook]('beforeEach', hookArgs)
769+
await this.parent.runHook('beforeEach', hookArgs)
770770
}
771771

772-
await this[kRunHook]('before', hookArgs)
772+
await this.runHook('before', hookArgs)
773773

774774
const stopPromise = stopTest(this.timeout, this.signal)
775775
const subtests = this.skipped || this.error ? [] : this.subtests
776776
const promise = SafePromiseAll(subtests, (subtests) => subtests.start())
777777

778778
await SafePromiseRace([promise, stopPromise])
779-
await this[kRunHook]('after', hookArgs)
779+
await this.runHook('after', hookArgs)
780780
await afterEach()
781781

782782
this.pass()

0 commit comments

Comments
 (0)