Repository navigation
console.log in node:test ? #44372
Copy link
Copy link
Closed
Labels
feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.test_runnerIssues and PRs related to the test runner subsystem.Issues and PRs related to the test runner subsystem.
Description
Activity
- addedfeature requestIssues requesting new Node.js features.Issues requesting new Node.js features.
on Aug 24, 2022 - addedtest_runnerIssues and PRs related to the test runner subsystem.Issues and PRs related to the test runner subsystem.
on Aug 24, 2022 completed via #43525
What's the resolution?
I am still not able to get output of
console.log:-(https://stackoverflow.com/questions/76391424/how-to-get-output-of-console-log-when-using-nodetest
@lucgagan try with the latest version of Node (v20.2.0). Your issue was fixed recently.
Reacted by Romain, vsDizzy and Ray FossHas it been added to 18.x.x?
Has it been added to 18.x.x?
Workaround:
import {createWriteStream} from 'fs' console.log = async (message: any) => { const tty = createWriteStream('/dev/tty') const msg = typeof message === 'string' ? message : JSON.stringify(message, null, 2) return tty.write(msg + '\n') }Reacted by Javier, Dennis Senn, Paul Taylor and Tarik GulReacted by Greg Eremeev
Metadata
Metadata
Assignees
Labels
feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.test_runnerIssues and PRs related to the test runner subsystem.Issues and PRs related to the test runner subsystem.
What is the problem this feature will solve?
{"type":"module"}What is the feature you are proposing to solve the problem?
The log of the console in the test should print
What alternatives have you considered?
No response