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 within describe runs twice #46887

Closed
MoLow opened this issue Feb 28, 2023 · 2 comments
Closed

test within describe runs twice #46887

MoLow opened this issue Feb 28, 2023 · 2 comments
Labels
test_runner Issues and PRs related to the test runner subsystem.

Comments

@MoLow
Copy link
Member

MoLow commented Feb 28, 2023

Version

v19.7.0

Platform

Darwin Moshes-MBP.localdomain 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:01 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T6000 arm64

Subsystem

test_runner

What steps will reproduce the bug?

run a test file:

const { test, describe, beforeEach } = require('node:test');

describe('tests', () => {
  beforeEach((t) => {
    console.log("beforeEach")
  });
  test('1', () => {
    console.log("test1")
  });
});

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

always

What is the expected behavior?

each test should run once.

What do you see instead?

test is reported once but it is actually ran twice

beforeEach
test1
beforeEach
test1
TAP version 13
# Subtest: tests
    # Subtest: 1
    ok 1 - 1
      ---
      duration_ms: 2.669708
      ...
    1..1
ok 1 - tests
  ---
  duration_ms: 2.015625
  ...
1..1
# tests 1
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms 6.29675

Additional information

No response

@MoLow MoLow added the test_runner Issues and PRs related to the test runner subsystem. label Feb 28, 2023
@jakecastelli
Copy link
Member

In node v18.x it will report 2 tests passed instead of 1. I think this has been fixed but I didn't find any issue / PR linked to it 🤔

@MoLow
Copy link
Member Author

MoLow commented Mar 3, 2023

completed via #46888

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.

2 participants