Skip to content
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: global before doesn't run if there are no global test #48844

Closed
alcuadrado opened this issue Jul 19, 2023 · 2 comments · Fixed by #48877
Closed

test runner: global before doesn't run if there are no global test #48844

alcuadrado opened this issue Jul 19, 2023 · 2 comments · Fixed by #48877
Labels
test_runner Issues and PRs related to the test runner subsystem.

Comments

@alcuadrado
Copy link

Version

v20.4.0

Platform

Darwin lucille.lan 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:23 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6020 arm64

Subsystem

test runner

What steps will reproduce the bug?

If you run this test with node --test, "before" is not printed.

import { describe, it, before, after } from "node:test";

before(async () => {
  console.log("before");
});

after(async () => {
  console.log("after");
});

describe("describe", async () => {
  it("it inside describe", async () => {});
});

If you define a test outside the describe, "before" is printed

import { describe, it, before, after } from "node:test";

before(async () => {
  console.log("before");
});

after(async () => {
  console.log("after");
});

describe("describe", async () => {
  it("it inside describe", async () => {});
});

it("it outside describe", async () => {});

How often does it reproduce? Is there a required condition?

It's deterministic.

What is the expected behavior? Why is that the expected behavior?

The before hook should always run.

What do you see instead?

It only runs if I have a global test.

Additional information

after doesn't seem to be affected by this issue. It always runs. This makes me believe that the intended behavior of before matches my expectations.

@VoltrexKeyva VoltrexKeyva added the test_runner Issues and PRs related to the test runner subsystem. label Jul 20, 2023
@rluvaton
Copy link
Member

rluvaton commented Jul 21, 2023

I'm looking at it

@rluvaton
Copy link
Member

rluvaton commented Jul 21, 2023

I'll try to look at it again tomorrow night as well...

creating a PR now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants