-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add ErrorContains #1022
Add ErrorContains #1022
Conversation
I'd love to get community feedback on this. I'm not sure the value this extra function adds is greater than the confusion/complexity it creates by having yet another function in the In fact, how is this different from the |
|
I see. Would it not make sense to rename this function to |
Semantically I'm asserting that the Error
I'd written
|
Fair point, that makes sense :) |
This was merged 6 months ago but still unavailable in |
1.7.1 is realeased and seems to include this feature. Thank you everyone. |
Summary
It's common practice to wrap errors, so that you do not have a transitive dependency on the error format of a third party library, but also so that you are able to exactly match you are testing a specific error case correctly.
This change adds an
ErrorContains()
method to check that both an error is reurned, and it contains a provided string.Changes
Added
ErrorContains()
andErrorContainsf()
.Motivation
When I wrap errors returned from third party modules:
This then forces me to write:
This change removes the
require
andError()
unpacking:Related issues