Revert "test_runner: do not invoke after hook when test is empty"

This reverts commit a53fd95d36.

This caused a regression because the original issue this commit
was attempting to fix is not a bug. The after() hook should
always run.

Fixes: https://github.com/nodejs/node/issues/51997
PR-URL: https://github.com/nodejs/node/pull/51998
Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
cjihrig authored and Michaël Zasso committed 2024-03-07 10:27:35 +01:00
1 parent 7ff3551bad
commit 85aa6ca850
2 files changed
+1 -13

No files matched your search

+1 -3
View File
@@ -595,9 +595,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 });
}
};
@@ -1,10 +0,0 @@
'use strict';
// Refs: https://github.com/nodejs/node/issues/51371
const common = require('../common');
const { test } = require('node:test');
test('test', async (t) => {
t.after(common.mustNotCall(() => {
t.fail('should not run');
}));
});