-
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
Assertion 'to throw' does not work #411
Comments
The correct usage of .then(() => expect(() => projects.create(createEvent2), 'to throw')) We should try to make that clearer in the docs. Tangentially related: #395 |
Hi thanks for the issue. Could it be that the create method throws an exception instead of returning a rejected promise? If so the expect statement have no way of catching that as the method arguments will be evaluated before the method invocation. "to throw" works by invoking it's first parameter and expecting that it will throw an exception. Try to see if the examples in the documentation will clear things up http://unexpected.js.org/assertions/function/to-throw/ |
Oh, thank you, the suggestion by @papandreou works. And yes, the |
👍
…On Wed, 26 Jul 2017 at 14.25, Jakub Matějka ***@***.***> wrote:
Oh, thank you, the suggestion by @papandreou
<https://github.com/papandreou> works.
And yes, the create method consists of calling an external method (which
throws the exception) and then returns a chain of promises. So I guess I
should rather put the sync method to a promise chain too.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#411 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAFishc_ctlUNljOmo4i_W31Kamv48fzks5sRyIjgaJpZM4OiV_h>
.
|
Would be great if the docs could be improved to make the distinction that @papandreou describes clear... |
Assertions 'to throw', 'to error' and 'to throw a' does not work and the test fails on the thrown error instead. Maybe the problem could be that I throw subclass of the Error class? (But 'to throw a' does not work either so I don't know.)
The text was updated successfully, but these errors were encountered: