@@ -75,7 +75,6 @@ const testNamePatterns = testNamePatternFlag?.length > 0 ? |
75 | 75 | (re) => convertStringToRegExp(re, '--test-name-pattern') |
76 | 76 | ) : null; |
77 | 77 | const kShouldAbort = Symbol('kShouldAbort'); |
78 | | -const kRunHook = Symbol('kRunHook'); |
79 | 78 | const kHookNames = ObjectSeal(['before', 'after', 'beforeEach', 'afterEach']); |
80 | 79 | const kUnwrapErrors = new SafeSet() |
81 | 80 | .add(kTestCodeFailure).add(kHookFailure) |
@@ -476,7 +475,7 @@ class Test extends AsyncResource { |
476 | 475 | return { ctx, args: [ctx] }; |
477 | 476 | } |
478 | 477 |
|
479 | | - async [kRunHook](hook, args) { |
| 478 | + async runHook(hook, args) { |
480 | 479 | validateOneOf(hook, 'hook name', kHookNames); |
481 | 480 | try { |
482 | 481 | await ArrayPrototypeReduce(this.hooks[hook], async (prev, hook) => { |
@@ -507,13 +506,13 @@ class Test extends AsyncResource { |
507 | 506 | const { args, ctx } = this.getRunArgs(); |
508 | 507 | const afterEach = runOnce(async () => { |
509 | 508 | if (this.parent?.hooks.afterEach.length > 0) { |
510 | | - await this.parent[kRunHook]('afterEach', { args, ctx }); |
| 509 | + await this.parent.runHook('afterEach', { args, ctx }); |
511 | 510 | } |
512 | 511 | }); |
513 | 512 |
|
514 | 513 | try { |
515 | 514 | if (this.parent?.hooks.beforeEach.length > 0) { |
516 | | - await this.parent[kRunHook]('beforeEach', { args, ctx }); |
| 515 | + await this.parent.runHook('beforeEach', { args, ctx }); |
517 | 516 | } |
518 | 517 | const stopPromise = stopTest(this.timeout, this.signal); |
519 | 518 | const runArgs = ArrayPrototypeSlice(args); |
@@ -761,9 +760,10 @@ class Suite extends Test { |
761 | 760 | const hookArgs = this.getRunArgs(); |
762 | 761 | const afterEach = runOnce(async () => { |
763 | 762 | if (this.parent?.hooks.afterEach.length > 0) { |
764 | | - await this.parent[kRunHook]('afterEach', hookArgs); |
| 763 | + await this.parent.runHook('afterEach', hookArgs); |
765 | 764 | } |
766 | 765 | }); |
| 766 | + |
767 | 767 | try { |
768 | 768 | this.parent.activeSubtests++; |
769 | 769 | await this.buildSuite; |
@@ -775,19 +775,18 @@ class Suite extends Test { |
775 | 775 | return; |
776 | 776 | } |
777 | 777 |
|
778 | | - |
779 | 778 | if (this.parent?.hooks.beforeEach.length > 0) { |
780 | | - await this.parent[kRunHook]('beforeEach', hookArgs); |
| 779 | + await this.parent.runHook('beforeEach', hookArgs); |
781 | 780 | } |
782 | 781 |
|
783 | | - await this[kRunHook]('before', hookArgs); |
| 782 | + await this.runHook('before', hookArgs); |
784 | 783 |
|
785 | 784 | const stopPromise = stopTest(this.timeout, this.signal); |
786 | 785 | const subtests = this.skipped || this.error ? [] : this.subtests; |
787 | 786 | const promise = SafePromiseAll(subtests, (subtests) => subtests.start()); |
788 | 787 |
|
789 | 788 | await SafePromiseRace([promise, stopPromise]); |
790 | | - await this[kRunHook]('after', hookArgs); |
| 789 | + await this.runHook('after', hookArgs); |
791 | 790 | await afterEach(); |
792 | 791 |
|
793 | 792 | this.pass(); |
|