-
Notifications
You must be signed in to change notification settings - Fork 633
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(expect): always show custom message #6217
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6217 +/- ##
==========================================
- Coverage 96.49% 96.32% -0.17%
==========================================
Files 536 543 +7
Lines 41179 41598 +419
Branches 6175 6314 +139
==========================================
+ Hits 39735 40071 +336
- Misses 1401 1485 +84
+ Partials 43 42 -1 ☔ View full report in Codecov by Sentry. |
expect/_matchers.ts
Outdated
context.customMessage ?? | ||
`Expected the value not to be close to ${expected} (using ${numDigits} digits), but it is`, |
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.
I think this part should be something like:
const defaultMessage = `Expected the value not to be close to ${expected} (using ${numDigits} digits), but it is`
throw new AssertionError(
context.customMessage ? `${context.customMessage}: ${defaultMessage}` : defaultMessage
);
Vitest, for example, shows the custom message like the above.
In Vitest:
expect(42, "custom message").toEqual(43);
This assertion error shows the message like:
AssertionError: custom message: expected 42 to deeply equal 43
- Expected
+ Received
- 43
+ 42
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.
Updated
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.
Oh, I missed this message. Sorry for the delay!
I vendored |
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.
LGTM. Thanks!
This pr is to solve #6206