summaryrefslogtreecommitdiff
path: root/test/parallel/test-assert.js
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2018-05-12 22:39:09 -0400
committercjihrig <cjihrig@gmail.com>2018-05-14 23:39:04 -0400
commitb5704859d043baeeda916ee4e435c06f5e2569e6 (patch)
treeae134164fffd23e909a1f7230799472f021f3883 /test/parallel/test-assert.js
parent4b00c4fafaa2ae8c41c1f78823c0feb810ae4723 (diff)
downloadandroid-node-v8-b5704859d043baeeda916ee4e435c06f5e2569e6.tar.gz
android-node-v8-b5704859d043baeeda916ee4e435c06f5e2569e6.tar.bz2
android-node-v8-b5704859d043baeeda916ee4e435c06f5e2569e6.zip
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 <rtrott@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-assert.js')
-rw-r--r--test/parallel/test-assert.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js
index d3e37afa51..bf9d6c6eb4 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';