Skip to content

Commit

Permalink
test: stricter assert color test
Browse files Browse the repository at this point in the history
Make sure the assertion is actually triggered by using
`assert.throws()` instead of `try/catch`.

PR-URL: #31429
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
  • Loading branch information
BridgeAR authored and codebytere committed Feb 17, 2020
1 parent 2db7593 commit 58f17c0
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions test/pseudo-tty/test-assert-colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@
require('../common');
const assert = require('assert').strict;

try {
// Activate colors even if the tty does not support colors.
process.env.COLORTERM = '1';
// Make sure TERM is not set to e.g., 'dumb' and NODE_DISABLE_COLORS is not
// active.
process.env.TERM = 'FOOBAR';
assert.throws(() => {
process.env.FORCE_COLOR = '1';
delete process.env.NODE_DISABLE_COLORS;
delete process.env.NO_COLOR;
assert.deepStrictEqual([1, 2, 2, 2, 2], [2, 2, 2, 2, 2]);
} catch (err) {
}, (err) => {
const expected = 'Expected values to be strictly deep-equal:\n' +
'\u001b[32m+ actual\u001b[39m \u001b[31m- expected\u001b[39m' +
' \u001b[34m...\u001b[39m Lines skipped\n\n' +
Expand All @@ -23,4 +20,5 @@ try {
' 2\n' +
' ]';
assert.strictEqual(err.message, expected);
}
return true;
});

0 comments on commit 58f17c0

Please sign in to comment.