-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
console.log() does not work in the test runner #43034
Comments
When I try to run that code, I get $ node <<EOF
const assert=require('node:assert');
const test=require('node:test');
test('synchronous passing test', (t) => {
console.log('abc');
assert.strictEqual(1, 1);
});
EOF
abc
(node:80807) ExperimentalWarning: The test runner is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
TAP version 13
ok 1 - synchronous passing test
---
duration_ms: 0.005491586
...
1..1
# tests 1
# pass 1
# fail 0
# skipped 0
# todo 0
# duration_ms 0.048477983 As you can see, |
Weird. No output on my machine. import test from 'node:test';
import assert from 'node:assert';
test('synchronous passing test', (t) => {
console.log('abc');
assert.strictEqual(1, 1);
});
|
So you are using the |
OK. That's a good workaround. But I insist that |
|
Can't agree more. It would be better to have |
If you are willing to contribute for that, that'd be awesome (opening a feature request issue would be ❤️ , opening a PR would be ❤️🔥 ). |
I'm not sure whether I could do this. But I'll try it. |
Version
v18.1.0
Platform
Win11
Subsystem
No response
What steps will reproduce the bug?
Use test runner in node v18 to run the test.
Run the code above and notice that string
abc
is not printed in the console.How often does it reproduce? Is there a required condition?
everytime
What is the expected behavior?
We could use
console.log()
in test runner.What do you see instead?
console.log()
does not work in test runner.Additional information
We need output some debug information during the test. We were like a blind when nothing could be printed to the console.
The text was updated successfully, but these errors were encountered: