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

Update to 8.1.0 breaks toMatchObject comparison #605

Open
sna6mu opened this issue Oct 28, 2024 · 2 comments
Open

Update to 8.1.0 breaks toMatchObject comparison #605

sna6mu opened this issue Oct 28, 2024 · 2 comments

Comments

@sna6mu
Copy link

sna6mu commented Oct 28, 2024

Using the following test

 it('Can compare objects', () => {
    expect(err({ important: 42, useless: 7 })).toMatchObject(err({ important: 42 }));
    expect(err({ important: 42, useless: 7 })).not.toMatchObject(err({ important: 43 }));
  });

was possible (and often times used for our code), but now breaks with 8.1.0 with

Error: expect(received).toMatchObject(expected)

- Expected  - 1
+ Received  + 1

- Err {
+ Object {
    "error": Object {
      "important": 42,
    },
  }

Any ideas why?

@sna6mu
Copy link
Author

sna6mu commented Oct 28, 2024

Interestingly, the test
expect(err({ important: 42, useless: 7 })).toMatchObject(err({ important: 42, useless: 7 }));
works!
We also got green results when using [email protected] instead of jest.

@busywhistling
Copy link

The issue is still there. A workaround in the meantime would be the following, and so on:

expect(relevantResult.isErr()).toBe(true);
expect(relevantResult._unsafeUnwrapErr()).toMatchObject({important: 42});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants