-
-
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
Fix pretty print for closeTo matcher #12626
Conversation
Good catch. It could be good to add a test case without precision arg: Another though. If I get it right, |
Good note. Thank you. I've added more tests (infinity, scientific notation and without precision). Regarding print format, I don't think it's a good idea to use the format you've suggested.
However, I'm not sure about my version either. I'd be glad to see any other proposals. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason why we cannot implement toAsymmetricMatcher
on https://github.com/facebook/jest/blob/b82fd89d16fdbe74d9bc80dd86ae4912966adc1d/packages/expect/src/asymmetricMatchers.ts#L293? Instead of adding to pretty-format
. Same for the existent types.
Also, we should throw a more useful error if toAsymmetricMatcher
is not present - it's optional: https://github.com/facebook/jest/blob/b82fd89d16fdbe74d9bc80dd86ae4912966adc1d/packages/expect/src/asymmetricMatchers.ts#L84
I don't have strong opinions about the exact message when serialized btw, I think the current one seems fine?
ping @L4vlet 🙂 |
Hey, thank you for the ping. Got a bit busy. I am not sure about the reasons why |
If I got it right, originally (PR) it was implemented that way. However, later author decided to create a plugin for the
In our case, it's not that necessary as printing is relatively simple. We can put it inside
I suggest we write a test which will check all matchers to see if jest can correctly print them. Not sure about the special error handling, though. It is not a kind of error client can fix by themselves so there won't be much use from a pretty message. |
Error handling would be |
…to closeTo-print-fix
@SimenB, good time of the day. Could you take a look again, please? I've moved the formatting from As for the test I was going to write, I couldn't find a proper way to extract all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
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. |
Summary
This PR fixes print for the closeTo matcher. Currently, it breaks with the
val.toAsymmetricMatcher is not a function
error.Test plan
yarn test
. Everything passed except for two tests related to Mercurial. They were as well failing on my machine before I made any changesobjectContaining
as an example