Skip to content

Commit

Permalink
test: refactor test using assert instead of try/catch
Browse files Browse the repository at this point in the history
PR-URL: #28346
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
  • Loading branch information
juansb827 authored and targos committed Aug 2, 2019
1 parent 32cf344 commit a0f89a2
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions test/pseudo-tty/test-assert-no-color.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ const assert = require('assert').strict;

process.env.NODE_DISABLE_COLORS = true;

try {
assert.deepStrictEqual({}, { foo: 'bar' });
} catch (error) {
const expected =
'Expected values to be strictly deep-equal:\n' +
'+ actual - expected\n' +
'\n' +
'+ {}\n' +
'- {\n' +
'- foo: \'bar\'\n' +
'- }';
assert.strictEqual(error.message, expected);
}
assert.throws(
() => {
assert.deepStrictEqual({}, { foo: 'bar' });
},
{
message: 'Expected values to be strictly deep-equal:\n' +
'+ actual - expected\n' +
'\n' +
'+ {}\n' +
'- {\n' +
'- foo: \'bar\'\n' +
'- }'
});

0 comments on commit a0f89a2

Please sign in to comment.