GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test_runner: don't use a symbol for runHook() · nodejs/node@370ad45

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/test_runner
    • test.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/test_runner/test.js‎

Copy file name to clipboardExpand all lines: lib/internal/test_runner/test.js
+8-9Lines 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 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.