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

[WIP] Make toBe matcher error message more helpful for objects and arrays #4277

Merged
merged 2 commits into from
Aug 17, 2017

Conversation

rogeliog
Copy link
Contributor

@rogeliog rogeliog commented Aug 16, 2017

Summary

See #4228

Test plan
screen shot 2017-08-17 at 1 04 47 pm

@rogeliog
Copy link
Contributor Author

I wonder if that would be some performance hit for large objects

return (
matcherHint('.toBe') +
'\n\n' +
'Looks like you wanted to test for object/array equity with strict `toBe` matcher. You probably need to use `toEqual` instead.'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

equity? Shouldn't it be "equality"?

I think it's still useful to keep some of the information from before, at least "Expected value to be (using ===) but they are different objects/arrays. […]”. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

screen shot 2017-08-17 at 9 51 10 am

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we just add the new message below and leave the rest as it was? Just a new line as extra information

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think that is preferable. Can you keep it on the same line as the "no visual difference" sentence?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@rogeliog rogeliog changed the title Make toBe matcher error message more helpful for objects and arrays [WIP] Make toBe matcher error message more helpful for objects and arrays Aug 17, 2017
@cpojer
Copy link
Member

cpojer commented Aug 17, 2017

Love it!

tushardhole pushed a commit to tushardhole/jest that referenced this pull request Aug 21, 2017
…rays (jestjs#4277)

* Make toBe matcher error message more helpful for objects and arrays

* Just add a message at the bottom instead of replacing it
@billiegoose
Copy link

This is so bloody fantastic that I searched for the error string "You probably need to use" in the git repo,, found the line, used git blame to find who introduced it, found this PR, all to tell you @rogeliog if we ever meet I shall buy you all the beers! 🍻 I love error messages like this. It's like peer programming with an AI.

@rogeliog
Copy link
Contributor Author

rogeliog commented Feb 8, 2018

Hehehe I’m glad that it was useful, happy to help! 🙃😀

@github-actions
Copy link

This pull request 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 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants