Skip to content
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

assert colors don’t match test colors #52249

Closed
remcohaszing opened this issue Mar 28, 2024 · 8 comments
Closed

assert colors don’t match test colors #52249

remcohaszing opened this issue Mar 28, 2024 · 8 comments
Labels
assert Issues and PRs related to the assert subsystem. test_runner Issues and PRs related to the test runner subsystem.

Comments

@remcohaszing
Copy link

Version

v20.12.0

Platform

Linux vali 6.8.0-76060800daily20240311-generic #202403110203171019808822.04~1a3dbc7 SMP PREEMPT_DYNAMIC Mon M x86_64 x86_64 x86_64 GNU/Linux

Subsystem

assert

What steps will reproduce the bug?

Create an empty directory with the following file named test.mjs:

import assert from 'node:assert/strict'
import { test } from 'node:test'

test('fruit', () => {
  assert.equal('apple', 'pear')
})

Now run the following:

node test.mjs
node --test

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

In my experience always.

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

I expected the assertion error to always be colorful, at least if the rest of the test output is.

What do you see instead?

The assertion error is colorful when running a test script directly, but not when it’s run via node --test.

The output of node test.mjs and node --test next to each other.

Additional information

Potentially related environment variables from my desktop session:

COLORTERM=truecolor
DESKTOP_SESSION=pop
GDMSESSION=pop
SHELL=/bin/zsh
SHLVL=1
TERM=xterm-256color

From a Docker container:

SHLVL=1
TERM=xterm
@cjihrig
Copy link
Contributor

cjihrig commented Mar 28, 2024

This could be a duplicate of #50397, but I have not confirmed it.

@VoltrexKeyva VoltrexKeyva added assert Issues and PRs related to the assert subsystem. test_runner Issues and PRs related to the test runner subsystem. labels Mar 30, 2024
@avivkeller
Copy link
Member

This could be a duplicate of #50397, but I have not confirmed it.

It's not. This has to do with the way internal/util/colors handles non-TTY terminals. I've opened a PR to adjust that behavior (#54289)

@cjihrig
Copy link
Contributor

cjihrig commented Jan 15, 2025

@pmarchini was this issue fixed by your work in #55404?

@pmarchini
Copy link
Member

@cjihrig it should be addressed.
I'll take a look to ensure I'm not mistaken, and if not, I'll close the issue!

@pmarchini
Copy link
Member

Image

The issue is fixed, closing it now!

@remcohaszing
Copy link
Author

On what Node.js version is that? The issue still exists in Node.js 22.13.0

Node.js test output

@cjihrig
Copy link
Contributor

cjihrig commented Jan 16, 2025

Looking at #55404, it looks like that change was released in v23.1.0 and has not been backported to the v22 release line.

@remcohaszing
Copy link
Author

IMO a backport would be nice, but definitely not critical. I look forward to seeing this change in a near future. Thanks for fixing this! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assert Issues and PRs related to the assert subsystem. test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants