Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
assert: add
matchObjectStrict
andmatchObject
#53415assert: add
matchObjectStrict
andmatchObject
#53415Changes from all commits
4164f10
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these seem flipped - the strict variant should not allow type coercion, and the loose variant should permit it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not convinced that this is sufficiently different from
deepEqual
anddeepStrictEqual
to warrant a new API. At the absolute least the documentation does not provide enough information for someone to be able to decide which to useThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jasnell If the
expected
object has fewer properties than theactual
object,deepEqual
will throw an error based on your example. On the other hand,matchObject
will compare the existing properties and values in theexpected
object, allowing for a partial comparison.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I get that, I just do not think there's enough justification for a new api. A new option to the existing method could do the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was some conversation in the original issue about whether it should be:
here @synapse decided to go with option 1, lacking a clear consensus on which option made the most sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I would love to see
node:assert
have amatch
function equivalent to https://github.com/tapjs/tapjs/blob/8f2baa7eb5e1f4cd0fcf8b60da4fb4e41ea680f1/docs/src/content/docs/api/asserts/index.md?plain=1#L318-L338But the proposal here seems like a less consistent
deepStrictEqual
.