Skip to content

test within describe runs twice #46887

Closed
Closed
@MoLow

Description

@MoLow

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    test_runnerIssues and PRs related to the test runner subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions