-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
assert: handle cause when cutting off stack frames
- Loading branch information
1 parent
4c72dda
commit 2eb8889
Showing
3 changed files
with
38 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use strict'; | ||
require('../common'); | ||
const assert = require('assert'); | ||
const { test } = require('node:test'); | ||
|
||
const defaultStartMessage = 'Expected values to be strictly deep-equal:\n' + | ||
'+ actual - expected\n' + | ||
'\n'; | ||
|
||
test('Handle error causes', () => { | ||
assert.throws(() => { | ||
assert.deepStrictEqual(new Error('a', { cause: new Error('x') }), new Error('a', { cause: new Error('y') })); | ||
}, { message: defaultStartMessage + ' [Error: a] {\n' + | ||
'+ [cause]: [Error: x]\n' + | ||
'- [cause]: [Error: y]\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' + | ||
'- }' }); | ||
|
||
assert.notDeepStrictEqual(new Error('a', { cause: new Error('x') }), new Error('a', { cause: new Error('y') })); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters