-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
toContain gives unhelpful error message when value being checked is an object #6808
Comments
if this wording is okay I will make a PR for this. |
Oh, I didn't see you're using v21. In v23 we've added this message: However, you can see it's a bit off. @Gregjarvez feel free to add 2 extra newlines here: https://github.com/facebook/jest/blob/277c547edd13ef2b69049ec1b4e768a2333471e1/packages/expect/src/matchers.js#L316 |
sure !! |
Oh my mistake, was working on an existing project and didn't realize we weren't up to date. Thanks. :-) |
can I work on this issue, if someone is not ? |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🐛 Bug Report
expect(arr).toContain(val)
gives an unhelpful error message when matching object values.To Reproduce
Steps to reproduce the behavior:
const arr = [{ a: 1 }, { b: 2}];
expect(arr).toContain({ a: 1 })
Error message is displayed:
but mentions nothing about how identity is being used for equality checks, leaving you scratching your head since it plainly displays "the same" object literal in both places.
Expected behavior
It would ideally add a note about how it's checking object identity and not key/value equality.
Link to repl or repo (highly encouraged)
https://repl.it/repls/UsableLovingPhases
Run
npx envinfo --preset jest
The text was updated successfully, but these errors were encountered: