Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expect(testee).toMatchObject(reference) != expect(reference).toMatchObject(testee) #3

Closed
GeorgGerber opened this issue Oct 22, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@GeorgGerber
Copy link

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

@ValeriaVG ValeriaVG added the bug Something isn't working label Oct 28, 2021
@ValeriaVG
Copy link
Owner

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants