Skip to content

Commit 90c77bc

Browse files
cjihrigMylesBorins
authored andcommitted
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: #18967 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 fd14ec1 commit 90c77bc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

test/parallel/test-assert.js

+6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ const { writeFileSync, unlinkSync } = require('fs');
3434
const { inspect } = require('util');
3535
const a = assert;
3636

37+
// Disable colored output to prevent color codes from breaking assertion
38+
// message comparisons. This should only be an issue when process.stdout
39+
// is a TTY.
40+
if (process.stdout.isTTY)
41+
process.env.NODE_DISABLE_COLORS = '1';
42+
3743
const start = 'Input A expected to strictly deep-equal input B:';
3844
const actExp = '+ expected - actual';
3945

0 commit comments

Comments
 (0)