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
feat: improve deep equality check failing message for toBe #1383
feat: improve deep equality check failing message for toBe #1383
Conversation
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
Thanks for working on the issue that I opened, however I still prefer how Jest shows the error, the text is more aligned especially around the expectations of expected/received. Also I see you added square brackets around the "serializes to the same string" but I find that a little bit confusing, I didn't know (until I looked at your code change) that the bracket was something that you added, I wasn't sure if the text inside it was dynamic or not (it's not) and that made it confusing, it's also not an array so why use brackets and not double quotes? Nonetheless, it's a great improvement compare to current code, so I'd be curious to see what the core team will reply. Thanks again for working on the issue I like how Jest shows it, everything is aligned and more readable expect(received).toBe(expected) // Object.is equality
If it should pass with deep equality, replace "toBe" with "toStrictEqual"
Expected: [{"age": 30, "id": 123, "name": "John"}]
Received: serializes to the same string
at Object.<anonymous> (/src/index.spec.ts:34:50) |
Yeah this is much closer to Jest message, love it |
What does this PR do?
A PR for issue #1290.
We would like to have a message to remind users they should use deep equality checks, when object comparison fails with
toBe
. The error message would look like this now:The implementation is similar to how jest does it.
How the change is tested?
Unit tests