Skip to content

Test concurrency causes the Test Runner to report a wrong isTTY value #56192

@nicholaswmin

Description

@nicholaswmin

another one for the test runner:

Description

Using child_process for test parallisation also sets process.stdout.isTTY to undefined.

The following returns undefined when it's run with node --test:

# node --test example.test.js
console.log(process.stdout.isTTY)
# undefined

when it's run with plain node, it's true:

# node example.test.js
console.log(process.stdout.isTTY)
# true

I had a very faint memory of a similar issue described by someone else,
very similar to this and IIRC about the child_process.

So, I run the same with --experimental-test-isolation=none and there it is: it returns true which confirms my suspicions.

# node --test --experimental-test-isolation=none example.test.js
console.log(process.stdout.isTTY)
# true

Although you can work around it, it's very problematic for the following reasons:

  • It's inconsistent with POLA
  • It' inconsistent with it's own API because it reports one way with one flag, and another without.
  • It leaks implementation details

How the tests are run is an implementation detail that shouldn't be leaking like that.
I'm sure there are some valid reasons for it but this feels plain wrong.

Thoughts?

Note: I only suspect these 2 issues are related.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionIssues that look for answers.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions