test: refactor test using assert instead of try/catch
PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
54ae530951
commit
9cda6f28c8
@ -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' +
|
||||
'- }'
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user