-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test_runner: t.after is never called #51997
Comments
cross referencing to nodejs/undici#2931 |
In #51371 the example is import { test } from 'node:test';
import { open } from 'node:fs/promises';
test('test', async (t) => {
let filehandle;
t.before(async () => {
console.log('before');
filehandle = await open('./index.mjs', 'r');
});
t.after(async () => {
console.log('after');
await filehandle.close();
});
// await t.test(() => {});
}); This can be simplified to import { test } from 'node:test';
test('test', async (t) => {
t.before(async () => {
console.log('before');
});
t.after(async () => {
console.log('after');
});
// await t.test(() => {});
}); So running this on node 21.6.2 results in printing only after but not before. In 21.7.0 it does not print anything. |
This reverts commit a53fd95. 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: nodejs#51997
I have opened #51998 with the revert + a regression test. |
I am currently building node from main branch and want to understand what we should expect. But I wonder what the correct behavior is. Should it really not trigger before and after if there is not test, or should it anyway run before and after if there is no test?! |
The documented behavior for
The documented behavior for
|
Actually I have the feeling that before should also run always like after. But I thinks that your revert PR should land asap. |
Feel free to change whatever you want 😄 |
I would rather prefer continue working on undici ;). |
Refs: #51997 PR-URL: #51998 Fixes: #51997 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 reverts commit a53fd95. 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: #51997 PR-URL: #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>
Refs: #51997 PR-URL: #51998 Fixes: #51997 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>
Refs: #51997 PR-URL: #51998 Fixes: #51997 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>
Refs: #51997 PR-URL: #51998 Fixes: #51997 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 reverts commit a53fd95. 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: nodejs#51997 PR-URL: nodejs#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>
Refs: nodejs#51997 PR-URL: nodejs#51998 Fixes: nodejs#51997 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 reverts commit a53fd95. 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: nodejs#51997 PR-URL: nodejs#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>
Refs: nodejs#51997 PR-URL: nodejs#51998 Fixes: nodejs#51997 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>
Version
v21.7.0
Platform
n/a
Subsystem
test_runner
What steps will reproduce the bug?
node --test test.mjs
How often does it reproduce? Is there a required condition?
always
What is the expected behavior? Why is that the expected behavior?
No response
What do you see instead?
the test hangs, "Called!" is never printed to the console
Additional information
It could be caused by #51389?
The text was updated successfully, but these errors were encountered: