You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
assert: partialDeepStrictEqual rejects Sets that deepStrictEqual accepts #67317
How often does it reproduce? Is there a required condition?
Always. An element of actual must partially match an element of expected that is not its exact counterpart. The same happens with Sets of objects and with object-keyed Maps:
What is the expected behavior? Why is that the expected behavior?
true
true
ok
The docs say partialDeepStrictEqual "always passes the same test cases as assert.deepStrictEqual()" and that Set items are compared unordered.
What do you see instead?
true
false
node:internal/assert/utils:146
throw error;
^
AssertionError [ERR_ASSERTION]: Values have same structure but are not reference-equal:
Set(2) {
[
1
],
[
1,
2
]
}
Additional information
compareSmallSets, partialObjectSetEquiv and partialObjectMapEquiv in lib/internal/util/comparisons.js pair each element with the first unclaimed partial match, so [1, 2] takes [1] and [1] is left with nothing to match. Matching exact pairs first (or backtracking) would fix it.
Found with a differential-testing tool; the report was drafted with AI assistance and reviewed and edited by me.
Activity
Stella050408 commentedon Nov 8, 2026
I'd like to work on this