Skip to content

Commit 58f17c0

Browse files
BridgeARcodebytere
authored andcommitted
test: stricter assert color test
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]>
1 parent 2db7593 commit 58f17c0

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

test/pseudo-tty/test-assert-colors.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22
require('../common');
33
const assert = require('assert').strict;
44

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

0 commit comments

Comments
 (0)