Skip to content

test module corrupts console.log output #47955

Closed
@strager

Description

@strager

Version

v20.1.0

Platform

Linux strapurp 5.15.0-56-generic #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

test/test-bug.mjs:

import test from "node:test";                                                   
                                                                                
test("bug repro", () => {                                                       
  console.log(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]));                        
}); 

Run: node --test test/test-bug.mjs

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

100% repro rate (not flaky).

Seems to happen when [ is logged.

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

ℹ Uint8Array(8) [
ℹ   1, 2, 3, 4,
ℹ   5, 6, 7, 8
ℹ ]
✔ bug repro (1.678472ms)
ℹ tests 1
ℹ suites 0
ℹ pass 1
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 35.77873

console.log in --test mode should show output similar to console.log in normal Node.js:

$ node -e 'console.log(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]));'
Uint8Array(8) [
  1, 2, 3, 4,
  5, 6, 7, 8
]

What do you see instead?

Logged elements of the Uint8Array are missing:

ℹ Uint8Array(8) [
ℹ 1
ℹ 5
ℹ ]
✔ bug repro (1.678472ms)
ℹ tests 1
ℹ suites 0
ℹ pass 1
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 35.77873

Additional information

I encountered this bug with Uint8Array.

I also encountered this bug with code like the following:

console.log(`  [${i}] ...`);

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.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