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

describe should not be counted as a single test #46762

Closed
MoLow opened this issue Feb 22, 2023 · 3 comments · Fixed by #47094
Closed

describe should not be counted as a single test #46762

MoLow opened this issue Feb 22, 2023 · 3 comments · Fixed by #47094

Comments

@MoLow
Copy link
Member

MoLow commented Feb 22, 2023

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

@MoLow
Copy link
Member Author

MoLow commented Feb 22, 2023

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

@SRHerzog
Copy link
Contributor

I'm taking a look at this now.

@parmishh
Copy link

parmishh commented Mar 2, 2023

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

SRHerzog added a commit to SRHerzog/node that referenced this issue Mar 6, 2023
With this change, test reports will count `test`, `it`, and `t.test`
rather than `describe`.

Fixes: nodejs#46762
nodejs-github-bot pushed a commit that referenced this issue Mar 21, 2023
PR-URL: #47094
Fixes: #46762
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
RafaelGSS pushed a commit that referenced this issue Apr 5, 2023
PR-URL: #47094
Fixes: #46762
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
RafaelGSS pushed a commit that referenced this issue Apr 7, 2023
PR-URL: #47094
Fixes: #46762
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
danielleadams pushed a commit that referenced this issue Jul 6, 2023
PR-URL: #47094
Fixes: #46762
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants