-
Notifications
You must be signed in to change notification settings - Fork 29
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
Alias 'to throw' as 'to throw ... satisfying' #535
Comments
Aliases for "to throw" are already supported - see the documentation for the assertion here. The word "satisfying" is not something defined for "to throw", but if we added it that wouldn't really be an alias but an entirely different assertion. However, you can already achieve exactly the semantics you want by using expect.it, for example:
|
The |
My apologies, I think I misread the value type to mean it wouldn't compare the error using satisfy semantics - the assertion does something a little special for strings I believe (comparing the message against it) hence the expect.it suggestion. |
The issue title was also a bit confusing, I've updated it to make it a bit clearer. While I have your attention, what does Lines 1030 to 1044 in 9b30831
|
I've been thinking about this some more - I can definitely see the value in this alias but I'd like to raise one concern. Using satisfying here would introduce something that behaves a little differently than for example "to have an item satisfying" primarily because of the matching of the error message to a string of its supplied. That would make this use of "satisfying" a little different to all the others. My concern is also that since (unfortunately) strings can be thrown at the language level this would create an annoying ambibugity. I might be over losing this though so keen to hear thoughts. @joelmukuthu thanks for expanding on the description a bit :) |
@alexjeffburke I agree, but I've also always thought of |
I agree about
expect(myFunction, 'to throw an', httpErrors.Conflict); |
Agreed about that spelling for which I think means we've reached some broad agreement - I can have a look next time I'm near core. |
You're right, that's a bit of a wart in itself, but I think we can fix that so it reduces directly to |
@joelmukuthu, personally I'd welcome a PR for this now that the other oddity got resolved. |
No description provided.
The text was updated successfully, but these errors were encountered: