Closed GeorgGerber closed 3 years ago
This works as intended, toMatchObject
is a loose comparison:
const more = { a: 1, b: 2, c: 3 };
const less = { a: 1, b: 2 };
expect(more).toMatchObject(more);
expect(less).toMatchObject(less);
expect(more).toMatchObject(less);
expect(less).not.toMatchObject(more);
scenario: expect(testee).toMatchObject(reference);
testee = {a:1,b:2,c:3} reference = {a:1,b:2} will not succeed
testee = {a:1,b:2} reference = {a:1,b:2,c:3} will succeed
Is this behaviour a bug or a feature? In my use case, I want to get "not successful" in both cases