From 0f6fed4f070391563c40a6c88d25deb734785274 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Mon, 20 Jan 2020 21:46:59 +0100 Subject: [PATCH] test: stricter assert color test Make sure the assertion is actually triggered by using `assert.throws()` instead of `try/catch`. PR-URL: https://github.com/nodejs/node/pull/31429 Reviewed-By: James M Snell Reviewed-By: Rich Trott Reviewed-By: Anna Henningsen --- test/pseudo-tty/test-assert-colors.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/test/pseudo-tty/test-assert-colors.js b/test/pseudo-tty/test-assert-colors.js index a241542c34cebf..9d5a923aa0f8e7 100644 --- a/test/pseudo-tty/test-assert-colors.js +++ b/test/pseudo-tty/test-assert-colors.js @@ -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' + @@ -23,4 +20,5 @@ try { ' 2\n' + ' ]'; assert.strictEqual(err.message, expected); -} + return true; +});