Skip to content

describe should not be counted as a single test #46762

Description

@MoLow

when running a simple suite of tests, each suite is counted as a single test instead of counting the individual tests

for example, running

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

describe('suite', () => {
  it('test1', () => {
    // ...
  });
  it('test2', () => {
    // ...
  });
});

results in

TAP version 13
# Subtest: suite
    # Subtest: test1
    ok 1 - test1
      ---
      duration_ms: 0.146666
      ...
    # Subtest: test2
    ok 2 - test2
      ---
      duration_ms: 0.060584
      ...
    1..2
ok 1 - suite
  ---
  duration_ms: 2.048875
  ...
1..1
# tests 1
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms 93.241042

I propose the summary should count 2 passed tests instead of 1

Activity

  1. added
    test_runnerIssues and PRs related to the test runner subsystem.
    on Feb 22, 2023
  2. MoLow commented on Feb 22, 2023

    @MoLow
    MemberAuthor

    I am not sure how should subtests be counted when running using t.test

  3. SRHerzog commented on Feb 23, 2023

    @SRHerzog
    Contributor

    I'm taking a look at this now.

  4. parmishh commented on Mar 2, 2023

    @parmishh

    When running this test suite using a testing framework it would typically be counted as a single test suite, regardless of how many individual tests are contained within it.
    However, most testing frameworks will report the number of individual tests that were run and their individual results as part of the test output.
    If you want to explicitly count the number of individual tests within a test suite, you can use the --verbose or -v option when running your tests. This will provide more detailed output, including the number of individual tests that were run and their results. @MoLow

  5. added a commit that references this issue on Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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