Repository navigation
npm test fails when colours are enabled #1228
Copy link
Copy link
Open
Description
Running npm test (with Node.js 26.12.1) in a terminal on Linux x64 is failing due to ANSI escapes in the output (i.e. colours are enabled).
✖ failing tests:
test at test/unit/ci_preflight_cli.test.js:190:3
✖ prints only the number of unfinished and queued PR jobs (316.653064ms)
AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
actual expected
'\x1B[33m3\x1B[39m\n'
at TestContext.<anonymous> (file:///home/local/rlau/sandbox/github/node-core-utils/test/unit/ci_preflight_cli.test.js:205:12)
at Test.runInAsyncScope (node:async_hooks:226:14)
at Test.run (node:internal/test_runner/test:1402:25)
at Test.start (node:internal/test_runner/test:1262:17)
at node:internal/test_runner/test:1903:71
at node:internal/per_context/primordials:505:82
at new Promise (<anonymous>)
at new SafePromise (node:internal/per_context/primordials:479:3)
at node:internal/per_context/primordials:505:9
at Array.map (<anonymous>) {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: '\x1B[33m3\x1B[39m\n',
expected: '3\n',
operator: 'strictEqual',
diff: 'simple'
}
test at test/unit/ci_preflight_cli.test.js:209:3
✖ includes running PR builds when the waiting queue is empty (309.199536ms)
AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
actual expected
'\x1B[33m20\x1B[39m\n'
at TestContext.<anonymous> (file:///home/local/rlau/sandbox/github/node-core-utils/test/unit/ci_preflight_cli.test.js:217:12)
at Test.runInAsyncScope (node:async_hooks:226:14)
at Test.run (node:internal/test_runner/test:1402:25)
at Suite.processPendingSubtests (node:internal/test_runner/test:974:18)
at Test.postRun (node:internal/test_runner/test:1542:19)
at Test.run (node:internal/test_runner/test:1467:12)
at async Promise.all (index 0)
at async Suite.run (node:internal/test_runner/test:1905:7)
at async Test.processPendingSubtests (node:internal/test_runner/test:974:7) {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: '\x1B[33m20\x1B[39m\n',
expected: '20\n',
operator: 'strictEqual',
diff: 'simple'
}
test at test/unit/ci_preflight_cli.test.js:222:3
✖ combines queued and working PR builds without double counting transitions (315.872432ms)
AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
actual expected
'\x1B[33m4\x1B[39m\n'
at TestContext.<anonymous> (file:///home/local/rlau/sandbox/github/node-core-utils/test/unit/ci_preflight_cli.test.js:242:12)
at Test.runInAsyncScope (node:async_hooks:226:14)
at Test.run (node:internal/test_runner/test:1402:25)
at Suite.processPendingSubtests (node:internal/test_runner/test:974:18)
at Test.postRun (node:internal/test_runner/test:1542:19)
at Test.run (node:internal/test_runner/test:1467:12)
at async Suite.processPendingSubtests (node:internal/test_runner/test:974:7) {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: '\x1B[33m4\x1B[39m\n',
expected: '4\n',
operator: 'strictEqual',
diff: 'simple'
}
test at test/unit/ci_preflight_cli.test.js:247:5
✖ prints zero for a valid queue with no PR jobs: [] (315.205079ms)
AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
actual expected
'\x1B[33m0\x1B[39m\n'
at TestContext.<anonymous> (file:///home/local/rlau/sandbox/github/node-core-utils/test/unit/ci_preflight_cli.test.js:250:14)
at Test.runInAsyncScope (node:async_hooks:226:14)
at Test.run (node:internal/test_runner/test:1402:25)
at Suite.processPendingSubtests (node:internal/test_runner/test:974:18)
at Test.postRun (node:internal/test_runner/test:1542:19)
at Test.run (node:internal/test_runner/test:1467:12)
at async Suite.processPendingSubtests (node:internal/test_runner/test:974:7) {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: '\x1B[33m0\x1B[39m\n',
expected: '0\n',
operator: 'strictEqual',
diff: 'simple'
}
test at test/unit/ci_preflight_cli.test.js:247:5
✖ prints zero for a valid queue with no PR jobs: [{"task":{"url":"https://ci.nodejs.org/job/node-test-commit/"}}] (309.745672ms)
AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
actual expected
'\x1B[33m0\x1B[39m\n'
at TestContext.<anonymous> (file:///home/local/rlau/sandbox/github/node-core-utils/test/unit/ci_preflight_cli.test.js:250:14)
at Test.runInAsyncScope (node:async_hooks:226:14)
at Test.run (node:internal/test_runner/test:1402:25)
at Suite.processPendingSubtests (node:internal/test_runner/test:974:18)
at Test.postRun (node:internal/test_runner/test:1542:19)
at Test.run (node:internal/test_runner/test:1467:12)
at async Suite.processPendingSubtests (node:internal/test_runner/test:974:7) {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: '\x1B[33m0\x1B[39m\n',
expected: '0\n',
operator: 'strictEqual',
diff: 'simple'
}
Tests pass if run with colours disabled, e.g.
NODE_DISABLE_COLORS=1 npm test
Metadata
Metadata
Assignees
Labels
No labels
Activity
Sagar07Kr commentedon Oct 29, 2026
I looked into this. The failing test is
test/unit/ci_preflight_cli.test.js, and the cause is inbin/ncu-ci.jsline 626:console.log(await getPRWorkload(request)). That value is a number, and console.log formats numbers with util.inspect, which colours them yellow when colours are forced. So stdout becomes\x1b[33m3\x1b[39m\ninstead of3\n.Printing it as a string instead should fix it without changing the normal output.
Could you please assign this issue to me?
richardlau commentedon Oct 29, 2026
We don't assign issues, but please open a pull request if you have something to contribute.