From 7597d45beeba0faa8058c369514274a7d166e6a2 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sun, 13 May 2018 09:27:01 -0400 Subject: [PATCH] test: disable colors in test-assert-deep.js When test/parallel/test-assert-deep.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. 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-deep.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/parallel/test-assert-deep.js b/test/parallel/test-assert-deep.js index 4fa091ef2af..538f4bef49d 100644 --- a/test/parallel/test-assert-deep.js +++ b/test/parallel/test-assert-deep.js @@ -7,6 +7,12 @@ const { AssertionError } = assert; const defaultMsgStart = 'Input A expected to strictly deep-equal input B:\n' + '+ expected - actual'; +// 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'; + // Template tag function turning an error message into a RegExp // for assert.throws() function re(literals, ...values) {