I get that .toEqual() checks equality of all fields for plain objects:
expect(
{"key1":"pin
As already mentioned expect.arrayContaining checks if the actual array contains the expected array as a subset.
To check for equivalence one may
expected array contains the actual array:// This is TypeScript, but remove the types and you get JavaScript
const expectArrayEquivalence = (actual: T[], expected: T[]) => {
expect(actual).toEqual(expect.arrayContaining(expected));
expect(expected).toEqual(expect.arrayContaining(actual));
};
This still has the problem that when the test fails in the first assertion one is only made aware of the elements missing from actual and no the extra ones that are not in expected.