-
-
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
Improve description line when assertion fails: part 1 #5437
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5437 +/- ##
==========================================
- Coverage 62.18% 62.17% -0.01%
==========================================
Files 205 205
Lines 6928 6927 -1
Branches 3 4 +1
==========================================
- Hits 4308 4307 -1
Misses 2619 2619
Partials 1 1
Continue to review full report at Codecov.
|
@@ -504,7 +504,7 @@ Received: | |||
`; | |||
|
|||
exports[`.toBeCloseTo() throws: [1.23, 1.2249999] 1`] = ` | |||
"<dim>expect(</><red>received</><dim>).toBeCloseTo(</><green>expected, precision</><dim>)</> | |||
"<dim>expect(</><red>received</><dim>).toBeCloseTo(</><green>expected</><dim>)</> |
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.
One of toBeCloseTo
snapshots should have a precision
param set.
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.
Yes, see 3 tests for accepts an optional precision argument
like needles in the haystack just above this last set of 3 for throws
however I will make a note to self that there do not seem to be any tests that assertion throws error if either arg is not number.
isDirectExpectCall?: boolean, | ||
secondArgument?: ?string, | ||
}, |
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.
Can we set this to have a default value of = {}
to avoid further options &&
checks?
I actually like it this way! |
Good stuff indeed! |
Love it, great attention to detail here @pedrottimark! |
By the way, part 2 will include one CHANGELOG item for both, if you will excuse me on this one ;) |
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
First in series of pull requests for clearer shorter report when assertion fails.
To warm up, let’s sweat some small stuff :) //cc @thymikee @rickhanlonii
Apply two principles from The Non-Designer’s Design Book by Robin Williams:
toHaveProperty
assertion.toBeCloseTo
which concatenated names instead of providing secondary as option.// Object.is equality
to be parallel with// strict equality
and// deep equality
in next PR] at end of line instead labels in labelExpected value to be (using Object.is)
of values, which a future pull request will omit when there is a diff.Test plan
toHaveProperty
assertion.