From 90c77bcc1861cd01b1939db9d08aebe1092039ea Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sat, 12 May 2018 22:39:09 -0400 Subject: [PATCH] test: disable colors in test-assert.js When test/parallel/test-assert.js is run with a TTY as stdout, color codes in assertion messages cause the test to fail. This commit disables colors when stdout is a TTY. Fixes: https://github.com/nodejs/node/issues/18967 PR-URL: https://github.com/nodejs/node/pull/20695 Reviewed-By: Rich Trott Reviewed-By: Trivikram Kamat Reviewed-By: Daniel Bevenius Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- test/parallel/test-assert.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index dba40c0a0e3c42..59e67810c2c41f 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -34,6 +34,12 @@ const { writeFileSync, unlinkSync } = require('fs'); const { inspect } = require('util'); const a = assert; +// Disable colored output to prevent color codes from breaking assertion +// message comparisons. This should only be an issue when process.stdout +// is a TTY. +if (process.stdout.isTTY) + process.env.NODE_DISABLE_COLORS = '1'; + const start = 'Input A expected to strictly deep-equal input B:'; const actExp = '+ expected - actual';