Skip to content

Commit

Permalink
test: test when cause not an instance of Error
Browse files Browse the repository at this point in the history
  • Loading branch information
geeksilva97 committed Oct 19, 2024
1 parent d91d935 commit 7ef786b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions test/parallel/test-assert-deep-with-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,24 @@ test('Handle error causes', () => {
}, { message: defaultStartMessage + ' [Error: a] {\n' +
'+ [cause]: [Error: x]\n' +
'- [cause]: [Error: y]\n' +
' }' });
' }\n' });

assert.throws(() => {
assert.deepStrictEqual(new Error('a'), new Error('a', { cause: new Error('y') }));
}, { message: defaultStartMessage + '+ [Error: a]\n' +
'- [Error: a] {\n' +
'- [cause]: [Error: y]\n' +
'- }' });
'- }\n' });

assert.throws(() => {
assert.deepStrictEqual(new Error('a'), new Error('a', { cause: { prop: 'value' } }));
}, { message: defaultStartMessage + '+ [Error: a]\n' +
'- [Error: a] {\n' +
'- [cause]: {\n' +
'- prop: \'value\'\n' +
'- }\n' +
'- }\n' });

assert.notDeepStrictEqual(new Error('a', { cause: new Error('x') }), new Error('a', { cause: new Error('y') }));
assert.notDeepStrictEqual(new Error('a', { cause: { prop: 'value' } }), new Error('a', { cause: { prop: 'a different value' } }));

Check failure on line 35 in test/parallel/test-assert-deep-with-error.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

This line has a length of 132. Maximum allowed is 120
});

0 comments on commit 7ef786b

Please sign in to comment.