Skip to content

assert colors don’t match test colors #52249

Closed
@remcohaszing

Description

@remcohaszing

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    assertIssues and PRs related to the assert subsystem.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