-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Unable to FORCE_COLOR with test runner #55383
Comments
Hey @deadbeef84, thanks for reporting this. |
I can't reproduce: require('node:test')('...', () => {
console.log(require('node:util').styleText('red', 'red'));
}); w/
It prints 'red' in red |
You're testing |
Actually, I believe the issue is that on Node 22, a non-tty causes the test runner to use the TAP reporter which doesn't use color. If I add |
That red text doesn't come from the test runner, and the test runner doesn't strip the colors. |
I haven't had the chance to take a close look at the issue, but I wonder if node/lib/internal/util/colors.js Lines 26 to 42 in 51d8146
process.stderr.isTTY is false, then even with force enabled, we're still getting "empty" colors.
WDYT? |
Yes. I tried to fix it in the past, but failed (due to test failures). See #54289 |
This issue is a duplicate of #52249 |
Hey @redyetidev, the reported issue is different, even though the fix is related. What do you think about this? |
I agree with @pmarchini. Let's keep this open for now. |
I believe you're right @pmarchini. The current code will only ever colorize output when a TTY is used. We probably don't need that |
@pmarchini was this fixed by #55404? |
Hey @cjihrig, yes, it should be fixed! |
Version
v22.9.0
Platform
Subsystem
test_runner
What steps will reproduce the bug?
When running the test-runner outside of a tty, it's not possible to force colors.
FORCE_COLOR=1 node --test | cat
How often does it reproduce? Is there a required condition?
No condition.
What is the expected behavior? Why is that the expected behavior?
When FORCE_COLOR is set to 1, 2 or 3, I expect ansi color codes to be written to stdout even if it's not in a tty.
What do you see instead?
It doesn't respect the FORCE_COLOR and no ansi color codes are in the output.
Additional information
No response
The text was updated successfully, but these errors were encountered: