| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -587,7 +587,9 @@ class Test extends AsyncResource { | |||
| 587 | 587 | ||
| 588 | 588 | const { args, ctx } = this.getRunArgs(); | |
| 589 | 589 | const after = async () => { | |
| 590 | - if (this.hooks.after.length > 0) { | ||
| 590 | + // If its a root test then check for global after hook else check for parent after hook | ||
| 591 | + const check = this.parent ? this.parent.hooks.after.length > 0 : this.hooks.after.length > 0; | ||
| 592 | + if (check) { | ||
| 591 | 593 | await this.runHook('after', { __proto__: null, args, ctx }); | |
| 592 | 594 | } | |
| 593 | 595 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,10 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + // Refs: https://github.com/nodejs/node/issues/51371 | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const { test } = require('node:test'); | ||
| 5 | + | ||
| 6 | + test('test', async (t) => { | ||
| 7 | + t.after(common.mustNotCall(() => { | ||
| 8 | + t.fail('should not run'); | ||
| 9 | + })); | ||
| 10 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments