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 run function crashing #47231

Closed
jeanbmar opened this issue Mar 23, 2023 · 7 comments · Fixed by #47238
Closed

Test runner run function crashing #47231

jeanbmar opened this issue Mar 23, 2023 · 7 comments · Fixed by #47238
Labels
good first issue Issues that are suitable for first-time contributors. test_runner Issues and PRs related to the test runner subsystem.

Comments

@jeanbmar
Copy link

jeanbmar commented Mar 23, 2023

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

@jeanbmar jeanbmar changed the title Test runner run method crashing on Windows Test runner run function crashing on Windows Mar 23, 2023
@jeanbmar
Copy link
Author

@cjihrig @nodejs/test_runner

@jeanbmar
Copy link
Author

Crashes on Linux too

@MoLow
Copy link
Member

MoLow commented Mar 23, 2023

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

@MoLow MoLow closed this as completed Mar 23, 2023
@MoLow MoLow added the test_runner Issues and PRs related to the test runner subsystem. label Mar 23, 2023
@jeanbmar
Copy link
Author

jeanbmar commented Mar 23, 2023

@MoLow then why official docs shows this

run({ files: [path.resolve('./tests/test.js')] })
  .pipe(process.stdout);

@jeanbmar
Copy link
Author

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

@jeanbmar
Copy link
Author

#44241

@MoLow MoLow reopened this Mar 23, 2023
@MoLow
Copy link
Member

MoLow commented Mar 23, 2023

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

@MoLow MoLow added the good first issue Issues that are suitable for first-time contributors. label Mar 23, 2023
@jeanbmar jeanbmar changed the title Test runner run function crashing on Windows Test runner run function crashing Mar 23, 2023
nodejs-github-bot pushed a commit that referenced this issue Mar 28, 2023
PR-URL: #47238
Fixes: #47231
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
RafaelGSS pushed a commit that referenced this issue Apr 5, 2023
PR-URL: #47238
Fixes: #47231
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
RafaelGSS pushed a commit that referenced this issue Apr 6, 2023
PR-URL: #47238
Fixes: #47231
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
RafaelGSS pushed a commit that referenced this issue Apr 7, 2023
PR-URL: #47238
Fixes: #47231
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
danielleadams pushed a commit that referenced this issue Jul 6, 2023
PR-URL: #47238
Fixes: #47231
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
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
Labels
good first issue Issues that are suitable for first-time contributors. test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants