Skip to content

Specify that spec reporter is a class and needs to be instantiate for usage with run #48112

Description

@sushantdhiman

Affected URL(s)

https://nodejs.org/api/test.html#test-reporters

Description of the problem

When importing spec test reporter, you need to instantiate it otherwise you will get no output, for example

import { run } from "node:test";
import { tap, spec } from "node:test/reporters";
import { resolve } from "path";

const files = [resolve("./test/test.js")];

run({
  files,
  concurrency: 1,
  timeout: 10000,
})
 --- .compose(spec)
+++.compose(new spec())
  .pipe(process.stdout);

Documentation should indicate that spec reporter is exported as a class unlike tap and dot reporters.

Activity

  1. added
    docIssues and PRs related to Node.js documentation.
    on May 22, 2023
  2. MoLow commented on May 22, 2023

    @MoLow
    Member

    are you interested in opening a PR for this?

  3. sushantdhiman commented on May 22, 2023

    @sushantdhiman
    Author

    Not sure how to get started with PR @MoLow

    But I think we also need to discuss if api (and behavior) of all test/reporters exports is correct. Ideally all exported reporters should work in same manner? There should be no need to do new spec().

  4. MoLow commented on May 22, 2023

    @MoLow
    Member

    But I think we also need to discuss if api (and behavior) of all test/reporters exports is correct. Ideally all exported reporters should work in same manner? There should be no need to do new spec().

    why?

  5. sushantdhiman commented on May 22, 2023

    @sushantdhiman
    Author

    node:test/reporters has three exports currently, spec, tap and dot (may be more in the future). Two of them can be used directly, but spec needs be instantiate. If you ask me this is an odd api, ideally spec should work directly.

    But it is just a matter of preference. I have reported oddity with the API docs, it is up to the maintainers how they wish to fix this :)

  6. added
    test_runnerIssues and PRs related to the test runner subsystem.
    on May 23, 2023
  7. aduh95 commented on May 23, 2023

    @aduh95
    Contributor

    All lowercase name usually means a function, classes would typically use PascalCase. I agree this is odd, we should fix it either by renaming it and deprecating the old name, or replace it with a function. The latter has the advantage of being doable without any breaking change (hopefully).

  8. added
    good first issueIssues that are suitable for first-time contributors.
    on May 23, 2023
  9. shubham9411 commented on May 23, 2023

    @shubham9411
    Contributor

    Hey @MoLow, I see you added good first issue tag to this issue. Can I take this?

  10. MoLow commented on May 23, 2023

    @MoLow
    Member

    Yeah 👍

  11. shubham9411 commented on May 23, 2023

    @shubham9411
    Contributor

    I am thinking of replacing SpecReporter class with a function, as @aduh95 suggested.

  12. Sumi0 commented on May 27, 2023

    @Sumi0

    Hi @MoLow, I was curious to take up this issue.
    I checked the codebase thoroughly to see any breaking changes.

    They were in two files, according to where we want to make change (signature/ exposure) :

    1. If we make change to reporter/spec.js : (@line-no:143) test_runner/utils.js
    2. If we make change to reporters.js : (@line-no:79) test-runner-run.mjs

    So instead of making amends to the original signature of 'spec' reporter, I have made change where it is getting exposed in reporters.js.

    Kindly check whether this approach is feasible and correct ?

  13. shubham9411 commented on May 27, 2023

    @shubham9411
    Contributor

    Hi @Sumi0, I didn't see your PR that was opened. Please let me know if I need to close my PR, which changes the spec class to a function.

  14. Sumi0 commented on May 27, 2023

    @Sumi0

    That's upon @MoLow and @aduh95 .
    My PoV is to not change 'spec' reporter's signature to a function.

  15. 2 remaining items

  16. aduh95 commented on May 30, 2023

    @aduh95
    Contributor
    1. How do maintainers come to know that, there is an PR awaiting their approval for CI workflow?

    There would be a GitHub notification if they are subscribed to that PR (and they would typically be because the bot pings the team "owning" the modified files).

    2. How do you follow this linting guideline --Wrap all other lines at 72 columns (except for long URLs)-- before making a commit from Github GUI ? What's the process to assert this guideline ?

    You count the chars I guess, and when the line grows larger than 72 chars, you add a line return at the start of the word. If that guideline is not met, the CQ will refuse to land the PR.

  17. Sumi0 commented on May 30, 2023

    @Sumi0

    You count the chars I guess, and when the line grows larger than 72 chars, you add a line return at the start of the word. If that guideline is not met, the CQ will refuse to land the PR.

    So how should one change the commit message afterwards ?
    Since I know, my CI test for my first commit linting failed ..

  18. MoLow commented on May 30, 2023

    @MoLow
    Member

    git commit --amend allows to edit a commits message and content

  19. aduh95 commented on May 31, 2023

    @aduh95
    Contributor

    Or you can use git fetch https://github.com/nodejs/node.git && git rebase FETCH_HEAD -i, and there you can replace pick with reword on the first commit. It's also OK if you don't want to fix it yourself, it can be fixed by someone else, but it's of course more convenient for everyone if you are able to do it yourself.

  20. AryanG210 commented on Jul 20, 2023

    @AryanG210

    is this issue still open?

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

    docIssues and PRs related to Node.js documentation.good first issueIssues that are suitable for first-time contributors.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