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

Make toBe matcher error message more helpful for objects and arrays #4228

Closed
thymikee opened this issue Aug 9, 2017 · 4 comments
Closed

Comments

@thymikee
Copy link
Collaborator

thymikee commented Aug 9, 2017

Do you want to request a feature or report a bug?
Enhancement

What is the current behavior?
Using expect(object).toBe(otherObject) fails with default message.

What is the expected behavior?
Since this is a common mistake, we could detect if the received entity is an object or an array and display helpful message like:

Looks like you wanted to test for object/array equity with strict `toBe` matcher. 
You probably need to use `toEqual` instead.

We can figure out better wording, this is just an idea :)

@rogeliog
Copy link
Contributor

Would we always show that message for arrays/objects or would we also do a toEquals behind the scenes and then show the message?

@thymikee
Copy link
Collaborator Author

We may do this, but only to show, that this expectation would work with toEqual. It would still throw of course.

@rogeliog
Copy link
Contributor

Correct! I'm happy to help with it

@github-actions
Copy link

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants