Skip to content

Commit d1bd779

Browse files
cjihrigtargos
authored andcommitted
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: #45792 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 8a03684 commit d1bd779

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

lib/internal/test_runner/test.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ const testNamePatterns = testNamePatternFlag?.length > 0 ?
7575
(re) => convertStringToRegExp(re, '--test-name-pattern')
7676
) : null;
7777
const kShouldAbort = Symbol('kShouldAbort');
78-
const kRunHook = Symbol('kRunHook');
7978
const kHookNames = ObjectSeal(['before', 'after', 'beforeEach', 'afterEach']);
8079
const 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

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy