Skip to content

Commit dccbc3a

Browse files
cjihrigMylesBorins
authored andcommitted
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 90c77bc commit dccbc3a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

test/parallel/test-assert-deep.js

Lines changed: 6 additions & 0 deletions
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)