Skip to content

Add partialDeepStrictEqual support - #7

Open
yassernasc wants to merge 10 commits into
mainfrom
partialDeepStrictEqual
Open

Add partialDeepStrictEqual support#7
yassernasc wants to merge 10 commits into
mainfrom
partialDeepStrictEqual

Conversation

@yassernasc

Copy link
Copy Markdown
Contributor

No description provided.

@yassernasc
yassernasc requested a review from a team August 18, 2026 22:50
Comment thread index.js Outdated
else result = deepStrictEqualObject(a, b, memo)
if (partial === true && type.isArray()) {
result = partialDeepStrictEqualArray(a, b, partial, memo)
} else if (type.isError()) result = deepStrictEqualError(a, b, partial, memo)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is an error we fallback to deep strict?

I think that on node that would pass:

assert.partialDeepStrictEqual(new Error('x', { cause: 1 }), new Error('x'))

But I think that if we fallback to strict it would fail on this branch, maybe worth trying.

Note: Also, I know that taking node as an exemple is not Always the good approach haha.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, working on it.

Comment thread test.js
/should fail/
)
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add test for Errors too.

@yassernasc

Copy link
Copy Markdown
Contributor Author

Adding more unit tests, I am converting the PR to draft for now.

@yassernasc
yassernasc marked this pull request as draft August 20, 2026 14:01
@yassernasc
yassernasc requested a review from tony-go August 21, 2026 00:20
@yassernasc
yassernasc marked this pull request as ready for review August 21, 2026 00:20
Comment thread index.js Outdated

for (const key of bKeys) {
// Do not test indexes when partial
if (partial === true && typeof key === 'string' && !isNaN(key)) continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this isNan() thing: do we want to skip when we have stuff like:

assert.partialDeepStrictEqual({ 0: 'a', 1: 'b' }, { 1: 'c' })

That should pass or fail?

Comment thread index.js Outdated
const itemA = a[j]

if (deepStrictEqualValue(itemA, itemB, memo)) {
if (deepStrictEqualValue(itemA, itemB, false, memo)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect this:

Suggested change
if (deepStrictEqualValue(itemA, itemB, false, memo)) {
if (deepStrictEqualValue(itemA, itemB, partial, memo)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For instance, lets try:

 assert.partialDeepStrictEqual(                                                                                  
      new Set([{ a: 1, extra: 2 }]),                                                                                
      new Set([{ a: 1 }])                                                                                           
    )      

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment and the above were real issues, I made a few tweaks

@yassernasc
yassernasc requested a review from tony-go August 21, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants