Commit 524eb248e55 for nodejs
commit 524eb248e55a7e2c65da6efaf9be1aa16f519045
Author: Filip Skokan <panva.ip@gmail.com>
Date: Sat Sep 26 15:37:50 2026 +0200
test: isolate styleText tests from the environment
The TTY cases inherit TERM, CI and the color override variables. These
can disable colors in a case expecting styling, or force colors in a
case expecting plain text. The tests skip these cases without a TTY,
which hides the dependency in many standalone runs.
Set a color-capable TERM and only the environment variables specified
by each case. Remove the RISC-V flaky expectations.
Refs: https://github.com/nodejs/build/issues/4099#issuecomment-5070947806
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Claude, Codex
PR-URL: https://github.com/nodejs/node/pull/66320
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status
index 3c26a14cd47..15fc53543b0 100644
--- a/test/parallel/parallel.status
+++ b/test/parallel/parallel.status
@@ -130,8 +130,3 @@ test-http-correct-hostname: SKIP
[$arch==riscv64]
# Snapshot test works in some environments but not others for now on RISC-V
test-snapshot-reproducible: PASS, FLAKY
-# styletext ones are failing in jenkins but pass standalone so something
-# odd is happening to the ttys when run via java. tty issue
-# https://github.com/nodejs/build/issues/4099#issuecomment-5070947806
-test-util-styletext: PASS, FLAKY
-test-util-styletext-hex: PASS, FLAKY
diff --git a/test/parallel/test-util-styletext-hex.js b/test/parallel/test-util-styletext-hex.js
index f12c35a780d..9677217bd33 100644
--- a/test/parallel/test-util-styletext-hex.js
+++ b/test/parallel/test-util-styletext-hex.js
@@ -213,8 +213,10 @@ describe('util.styleText hex color support', () => {
for (const testCase of testCases) {
it(`should respect ${testCase.description}`, () => {
writeStream.isTTY = testCase.isTTY;
+ // Do not inherit color-related variables (TERM, CI, NO_COLOR, ...)
+ // from the environment the test happens to run in.
process.env = {
- ...originalEnv,
+ TERM: 'xterm-256color',
...testCase.env,
};
const output = util.styleText('#ffcc00', 'test', { stream: writeStream });
diff --git a/test/parallel/test-util-styletext.js b/test/parallel/test-util-styletext.js
index 3db01bec1c3..ba81aae06d8 100644
--- a/test/parallel/test-util-styletext.js
+++ b/test/parallel/test-util-styletext.js
@@ -203,9 +203,11 @@ if (fd !== -1) {
{ isTTY: true, env: { FORCE_COLOR: '1', NO_COLOR: '1', NODE_DISABLE_COLORS: '1' }, expected: styled },
].forEach((testCase) => {
writeStream.isTTY = testCase.isTTY;
+ // Do not inherit color-related variables (TERM, CI, NO_COLOR, ...) from
+ // the environment the test happens to run in.
process.env = {
- ...process.env,
- ...testCase.env
+ TERM: 'xterm-256color',
+ ...testCase.env,
};
{
const output = util.styleText('red', 'test', { stream: writeStream });