-
-
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
nested objectContaining does not show diff #10276
Comments
I believe this is only the case when you pass an asymmetric matcher function into toEqual. Looking at the source jest-matcher-utils contains a function |
Experiencing the same issue currently. @sk- did you manage to resolve it? |
@SamLee is there another way to write it? If I use |
This is an ugly workaroud for jestjs/jest#10276.
In my case when I use expect(mySpy).toHaveBeenCalledWith(expect.objectContaining({...}) I don't get a line by line diff. I only get a massive string output of the entire object. When I do expect(mySpy).toHaveBeenCalledWith({... , someField: expect.objectContaining({...}}) I get a more useful line by line diff. I don't always want to do the latter though. I might need to partial match just a specific property. |
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
Using
expect.objectContaining
in nested in anotherobjectContaining
will not trigger a diff.To Reproduce
Expected behavior
I would expect to see a diff showing why the objects are different. Note that this already happens when we use just one level of
objectContaining
inside an array (see tests:objectContaining within array
and'objectContaining in array
)Link to repl or repo (highly encouraged)
https://repl.it/repls/CooperativeRipeBruteforceprogramming#nested.test.js
envinfo
The text was updated successfully, but these errors were encountered: