Open danny-does-stuff opened 2 days ago
I checked Jest has the same behavior https://stackblitz.com/edit/github-vktwdn?file=basic.test.js, but I don't know for what reason this would make sense. It's probably a bug and should be fixed.
It looks like asymmetric matcher's equality doesn't consider iterableEquality
, so arrayContaining
doesn't work either https://stackblitz.com/edit/vitest-dev-vitest-4n18bx?file=test%2Fbasic.test.ts
import { expect, test } from 'vitest';
test('repro 1', () => {
expect([new Set()]).toEqual(expect.arrayContaining([new Set([1])]));
});
Describe the bug
When comparing Sets within
expect.objectContaining
, any Set will make the test pass. In other words, the lineexpect({ set: new Set() }).toEqual(expect.objectContaining({ set: new Set([1]) }));
does not cause the test to fail.Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-dpdxnv?file=test%2Fbasic.test.ts
System Info
Used Package Manager
yarn
Validations