Repository navigation
deepStrictEqual and notDeepStrictEqual do not compare Error causes nor AggregateError errors arrays #51793
Description
Activity
As mentioned in deepstrictequalactual, for
Errortype, it comparesnames,messagesand enumerable "own" properties.cause,message, andname, are both non-enumerable properties. However, as mentioned in ECMA2024,causetriggers some special operations during the creation of anErrorinstance, so I believecauseserves as another distinguishing attribute among differentError, much likemessageandname. I'm unsure if others agree with this perspective, and I'm willing to submit a PR if feasible.Reacted by Ruben BridgewaterI use AggregateError and Error's cause to create a tree to provide an explicit trail of what was wrong and where.
Being able to recursively compare the Error's cause/Aggregate's errors in the tests is more thorough that no info on the reason is missing.
I agree with @zhenweijin that we should just add a special handling for it. It should be pretty straight forward to add that check.
- addedgood first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.assertIssues and PRs related to the assert subsystem.Issues and PRs related to the assert subsystem.feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.
on Feb 19, 2024 - addedutilIssues and PRs related to the built-in util module.Issues and PRs related to the built-in util module.
on Feb 19, 2024 I'm interested in looking at this issue if it become available 🙇 (I see it's still in Triage)
Hi, can you assign me to this issue?
- removedgood first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.
on Feb 21, 2024 There's an open PR, so it's almost done.
Reacted by Abid and Zamralik- added a commit that references this issue
on May 12, 2024 - added a commit that references this issue
on May 13, 2024 - added a commit that references this issue
on Jun 20, 2024
Version
v20.9.0
Platform
Linux DESKTOP-8H17SD6 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
These 4 calls should not throw.
Inversely, replacing notDeepStrictEqual by deepStrictEqual should throw for all.
How often does it reproduce? Is there a required condition?
Every time
What is the expected behavior? Why is that the expected behavior?
notDeepStrictEqual should throw when the Error's cause / AggregateError's errors match perfectly recursively.
deepStrictEqual should throw when the Error's cause / AggregateError's errors do not match perfectly recursively.
What do you see instead?
notDeepStrictEqual throw when the Error's cause / AggregateError's errors match perfectly recursively.
deepStrictEqual do not throw when the Error's cause / AggregateError's errors do not match perfectly recursively.
Additional information
No response