-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
t.throws(promise, stringOrRegexp) should only test against errors #468
Comments
👏👏👏 |
👍 👍 👍 |
I was looking into this and had a couple of questions. It looks like @jamestalmage would like AVA to have an opinion about Promises that fail to reject with Errors.
|
@corinna000 the way I read it is that |
Looking at the assert code just now it seems we convert non- IMO we should pass the rejection reason to |
If you are rejecting a Promise, you should be doing so with an Error object.
If you are testing that a promise will be rejected, we currently allow this:
That makes sense.
However. If the promise is rejected with a string:
We magically handle detecting it's not an error and test the expectation directly against the string instead of
error.message
.I think this is silly. We are accommodating bad practice (rejecting with non-errors), and creating an ambiguous assertion conditions:
I propose we drop the magic string behavior.
If they specify the second arg, we use it as an expectation against
rejectionReason.message
only.The text was updated successfully, but these errors were encountered: