Skip to content

Commit 7597d45

Browse files
committed
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: #20695 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent b570485 commit 7597d45

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

test/parallel/test-assert-deep.js

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ const { AssertionError } = assert;
77
const defaultMsgStart = 'Input A expected to strictly deep-equal input B:\n' +
88
'+ expected - actual';
99

10+
// Disable colored output to prevent color codes from breaking assertion
11+
// message comparisons. This should only be an issue when process.stdout
12+
// is a TTY.
13+
if (process.stdout.isTTY)
14+
process.env.NODE_DISABLE_COLORS = '1';
15+
1016
// Template tag function turning an error message into a RegExp
1117
// for assert.throws()
1218
function re(literals, ...values) {

0 commit comments

Comments
 (0)