-
-
Notifications
You must be signed in to change notification settings - Fork 224
Add failing element to satisfyAll
and satisfyAny
error messages
#482
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## main #482 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 71 71
Lines 582 584 +2
Branches 148 150 +2
=========================================
+ Hits 582 584 +2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@@ -1,23 +1,28 @@ | |||
export function toSatisfyAny(actual, expected) { | |||
const { printReceived, printExpected, matcherHint } = this.utils; | |||
|
|||
const pass = actual.some(expected); | |||
const failingElement = pass ? actual.find(expected) : actual.find(a => !expected(a)); |
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.
Why return the first non-matching element? In the case of toSatisfyAny
, all elements would fail the predicate during failure scenarios.
@@ -1,23 +1,28 @@ | |||
export function toSatisfyAll(actual, expected) { | |||
const { printReceived, printExpected, matcherHint } = this.utils; | |||
|
|||
const pass = actual.every(expected); | |||
const failingElement = pass ? actual.find(expected) : actual.find(a => !expected(a)); |
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.
There could be multiple failing elements, right? I'm wondering if it'd be better to print them all instead of just the first one.
What
Add failing element to
satisfyAll
andsatisfyAny
error messagesWhy
This will give a clearer error message of why the assertion failed
Notes
Housekeeping