Skip to content

Commit

Permalink
test: disable colors in test-assert-deep.js
Browse files Browse the repository at this point in the history
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 <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>
  • Loading branch information
cjihrig committed May 15, 2018
1 parent b570485 commit 7597d45
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/parallel/test-assert-deep.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7597d45

Please sign in to comment.