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
[Bug]: objectContaining, arrayContaining, and arrayOf don't compare the contents of Sets, Maps, and other iterables #16508
Every test passes. For a Set, a Map, and a custom iterable, the tests check that two instances with different contents don't match: once with toEqual, and once with each of expect.objectContaining, expect.arrayContaining, expect.arrayOf, and expect.objectContaining inside toHaveBeenCalledWith.
Actual behavior
For each type, the toEqual test passes and the other four fail. Inside the containing matchers, a Set, Map, or other iterable that isn't an Array or a typed array matches any other of its kind, no matter what it contains. URLSearchParams and generator objects behave the same way, and so does expect.not.objectContaining, in reverse. An Array, a typed array, or a plain object is compared correctly.
Additional context
#13968 reported this for Map values, and a 2023 comment on #11250 reported it for objectContaining too. #11250 itself was about toMatchObject, which now compares Maps and Sets correctly. The stale bot closed both issues without triage, and the behavior is unchanged on main.
Activity
Link the Jest bug report from the reproduction README (#7)
fix(expect): include iterableEquality in ArrayContaining, ArrayOf, an…
fix(expect): include iterableEquality in ArrayContaining, ArrayOf, an…
fix(expect): pass iterableEquality to asymmetric matcher equality checks