Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/internal/test_runner/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,7 @@ class Test extends AsyncResource {

const { args, ctx } = this.getRunArgs();
const after = async () => {
// If its a root test then check for global after hook else check for parent after hook
const check = this.parent ? this.parent.hooks.after.length > 0 : this.hooks.after.length > 0;
if (check) {
if (this.hooks.after.length > 0) {
await this.runHook('after', { __proto__: null, args, ctx });
}
};
Expand Down
10 changes: 0 additions & 10 deletions test/parallel/test-runner-skip-after-hook.js

This file was deleted.

12 changes: 12 additions & 0 deletions test/parallel/test-runner-subtest-after-hook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';
const common = require('../common');
const { test } = require('node:test');

// Regression test for https://github.com/nodejs/node/issues/51997
test('after hook should be called with no subtests', (t) => {
const timer = setTimeout(common.mustNotCall(), 2 ** 30);

t.after(common.mustCall(() => {
clearTimeout(timer);
}));
});