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 - using node test.mjs and node --test test.mjs print different outputs #45470

Closed
ErickWendel opened this issue Nov 15, 2022 · 5 comments
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. test_runner Issues and PRs related to the test runner subsystem.

Comments

@ErickWendel
Copy link
Member

Version

v20.0.0-pre

Platform

darwin

Subsystem

No response

What steps will reproduce the bug?

No response

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

npm i -g tap-spec@5.0.0
// index.test.mjs
import { describe, it } from 'node:test'
import { deepEqual } from 'node:assert'
function sum(num1, num2) {
  return num1 + num2
}

describe('Math test suite', () => {
  it('it should sum two integers', () => {
    const expected = 10
    const current = sum(8, 2)
    deepEqual(current, expected)
  })
})
./node --test  watch-mode-tests/index.test.mjs | tap-spec

  Subtest: /Users/erickwendel/Downloads/projetos/node/watch-mode-tests/index.test.mjs

    ✔ /Users/erickwendel/Downloads/projetos/node/watch-mode-tests/index.test.mjs

and

./node watch-mode-tests/index.test.mjs | tap-spec 

  Subtest: Math test suite

        # Subtest: it should sum two integers
        ok 1 - it should sum two integers
          ---
          duration_ms: 0.660125
          ...
    ✔ Math test suite

or in a folder

./node --test watch-mode-tests | tap-spec

  Subtest: /Users/erickwendel/Downloads/projetos/node/watch-mode-tests/index.test.mjs

    ✔ /Users/erickwendel/Downloads/projetos/node/watch-mode-tests/index.test.mjs

What is the expected behavior?

Both should output

  Subtest: Math test suite

        # Subtest: it should sum two integers
        ok 1 - it should sum two integers
          ---
          duration_ms: 0.660125
          ...
     Math test suite

What do you see instead?

when using --test

  Subtest: /Users/erickwendel/Downloads/projetos/node/watch-mode-tests/index.test.mjs

     /Users/erickwendel/Downloads/projetos/node/watch-mode-tests/index.test.mjs

Additional information

@nodejs/test_runner @nodejs/tooling

@MoLow
Copy link
Member

MoLow commented Nov 15, 2022

@ErickWendel this seems to be a duplicate of #43344
can you confirm?

@MoLow MoLow added the test_runner Issues and PRs related to the test runner subsystem. label Nov 15, 2022
@ErickWendel
Copy link
Member Author

ErickWendel commented Nov 15, 2022

@ErickWendel this seems to be a duplicate of #43344 can you confirm?

I think they're similar but different. In that issue, it's the actual parser that would be modified (and might affect it here also) but here I mentioned that adding the flag --test outputs only the file path that is being executed and without it the complete test results.

I think --test would print the complete result

@MoLow
Copy link
Member

MoLow commented Nov 15, 2022

@ErickWendel yes that is the same issue

@ErickWendel
Copy link
Member Author

@ErickWendel yes that is the same issue

I didn't get why. Reading that issue means that the output for the test count is incorrect and here are different outputs for running with our without the --test flag.

@cjihrig
Copy link
Contributor

cjihrig commented Nov 15, 2022

@MoLow is right. The output is different because the CLI runner reports each file as a TAP test point. Currently, the output from each child process is only shared when there is a failure in that file. The TAP parser PR addresses this.

I think we can close this as a dupe.

@aduh95 aduh95 added the duplicate Issues and PRs that are duplicates of other issues or PRs. label Nov 17, 2022
@aduh95 aduh95 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

No branches or pull requests

4 participants