镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Test runner run function crashing #47231

Description

@jeanbmar

Version

v18.15.0

Platform

Microsoft Windows NT 10.0.19045.0 x64

Subsystem

No response

What steps will reproduce the bug?

import { run } from 'node:test';

run({ files: [] }).pipe(process.stdout);

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

Always. Crashes as well when files is not empty.

What is the expected behavior? Why is that the expected behavior?

It shouldn't crash.

What do you see instead?

node:internal/test_runner/harness:45                                                                                                                
      throw err;                                                                                                                                    
      ^                

TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of Object
    at new NodeError (node:internal/errors:399:5)
    at _write (node:internal/streams/writable:315:13)
    at Writable.write (node:internal/streams/writable:337:10)
    at TestsStream.ondata (node:internal/streams/readable:766:22)
    at TestsStream.emit (node:events:513:28)
    at Readable.read (node:internal/streams/readable:539:10)
    at flow (node:internal/streams/readable:1023:34)
    at resume_ (node:internal/streams/readable:1004:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Additional information

No response

Activity

  1. changed the title [-]Test runner run method crashing on Windows[/-] [+]Test runner run function crashing on Windows[/+] on Mar 23, 2023
  2. jeanbmar commented on Mar 23, 2023

    @jeanbmar
    Author

    @cjihrig @nodejs/test_runner

  3. jeanbmar commented on Mar 23, 2023

    @jeanbmar
    Author

    Crashes on Linux too

  4. MoLow commented on Mar 23, 2023

    @MoLow
    Member

    run returns a testsStream wich is a Readable in object mode,
    meaning you cannot pipe it directly to stdout without transforming it.
    this error is expected

  5. added
    test_runnerIssues and PRs related to the test runner subsystem.
    on Mar 23, 2023
  6. jeanbmar commented on Mar 23, 2023

    @jeanbmar
    Author

    @MoLow then why official docs shows this

    run({ files: [path.resolve('./tests/test.js')] })
      .pipe(process.stdout);
  7. jeanbmar commented on Mar 23, 2023

    @jeanbmar
    Author

    And how are we supposed to parse the run output to generate something similar to --test?

  8. jeanbmar commented on Mar 23, 2023

    @jeanbmar
    Author
  9. reopened this on Mar 23, 2023
  10. MoLow commented on Mar 23, 2023

    @MoLow
    Member

    I am reopening this for us to perform 2 action items:

    • fix the example in the docs
    • allow using reporters within the run API, either by exposing the reporters or by adding an option to run
  11. added
    good first issueIssues that are suitable for first-time contributors.
    on Mar 23, 2023
  12. changed the title [-]Test runner run function crashing on Windows[/-] [+]Test runner run function crashing[/+] on Mar 23, 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

    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