diff options
author | cjihrig <cjihrig@gmail.com> | 2022-12-06 13:21:02 -0500 |
---|---|---|
committer | Danielle Adams <adamzdanielle@gmail.com> | 2023-01-04 20:31:55 -0500 |
commit | d1452bc52e35ff7e78d6c9afa1139402164f4f40 (patch) | |
tree | 5a25bc391f7e35398d9b842a471ed2c88877f2ff | |
parent | fec71b8503e7b4135b5d460169a4f80a2208ecbf (diff) | |
download | node-new-d1452bc52e35ff7e78d6c9afa1139402164f4f40.tar.gz |
test_runner: 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: https://github.com/nodejs/node/pull/45792
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
-rw-r--r-- | lib/internal/test_runner/test.js | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/internal/test_runner/test.js b/lib/internal/test_runner/test.js index c56c03c072..96c86ab3ed 100644 --- a/lib/internal/test_runner/test.js +++ b/lib/internal/test_runner/test.js @@ -75,7 +75,6 @@ const testNamePatterns = testNamePatternFlag?.length > 0 ? (re) => convertStringToRegExp(re, '--test-name-pattern') ) : null; const kShouldAbort = Symbol('kShouldAbort'); -const kRunHook = Symbol('kRunHook'); const kHookNames = ObjectSeal(['before', 'after', 'beforeEach', 'afterEach']); const kUnwrapErrors = new SafeSet() .add(kTestCodeFailure).add(kHookFailure) @@ -476,7 +475,7 @@ class Test extends AsyncResource { return { ctx, args: [ctx] }; } - async [kRunHook](hook, args) { + async runHook(hook, args) { validateOneOf(hook, 'hook name', kHookNames); try { await ArrayPrototypeReduce(this.hooks[hook], async (prev, hook) => { @@ -507,13 +506,13 @@ class Test extends AsyncResource { const { args, ctx } = this.getRunArgs(); const afterEach = runOnce(async () => { if (this.parent?.hooks.afterEach.length > 0) { - await this.parent[kRunHook]('afterEach', { args, ctx }); + await this.parent.runHook('afterEach', { args, ctx }); } }); try { if (this.parent?.hooks.beforeEach.length > 0) { - await this.parent[kRunHook]('beforeEach', { args, ctx }); + await this.parent.runHook('beforeEach', { args, ctx }); } const stopPromise = stopTest(this.timeout, this.signal); const runArgs = ArrayPrototypeSlice(args); @@ -761,9 +760,10 @@ class Suite extends Test { const hookArgs = this.getRunArgs(); const afterEach = runOnce(async () => { if (this.parent?.hooks.afterEach.length > 0) { - await this.parent[kRunHook]('afterEach', hookArgs); + await this.parent.runHook('afterEach', hookArgs); } }); + try { this.parent.activeSubtests++; await this.buildSuite; @@ -775,19 +775,18 @@ class Suite extends Test { return; } - if (this.parent?.hooks.beforeEach.length > 0) { - await this.parent[kRunHook]('beforeEach', hookArgs); + await this.parent.runHook('beforeEach', hookArgs); } - await this[kRunHook]('before', hookArgs); + await this.runHook('before', hookArgs); const stopPromise = stopTest(this.timeout, this.signal); const subtests = this.skipped || this.error ? [] : this.subtests; const promise = SafePromiseAll(subtests, (subtests) => subtests.start()); await SafePromiseRace([promise, stopPromise]); - await this[kRunHook]('after', hookArgs); + await this.runHook('after', hookArgs); await afterEach(); this.pass(); |