-
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
Allow throws / throwsAsync to work with any value, not just errors #2517
Comments
I think we should add a short note to the docs that if the user is in control of the error, they should prefer to make it a proper |
Hello @novemberborn & @sindresorhus, I would like to tackle this issue if possible. Thank you, |
@randomicon00 that's great go for it 😄 |
@novemberborn Will do thanks :) |
This comment has been minimized.
This comment has been minimized.
@novemberborn I'd like to take a crack at this. |
It assigned to me, I still didn't complete it but you can try I guess. I am still working on it. |
@randomicon00 , it's cool if you are working on it. I though that it was inactive, so asked. |
This comment was marked as off-topic.
This comment was marked as off-topic.
@novemberborn I'd still like to take a crack at this. |
By all means @adiSuper94! I'm low on time but I do want this in for AVA 6. Hopefully you get to it before I do 😀 |
I have added a PR that tries to fix this.
I am a bit confused about this. The signature of the If I am missing anything could you explain how this can be done ? |
Fixes #2517. Co-authored-by: Mark Wubben <mark@novemberborn.net>
t.throws()
andt.throwsAsync()
require the resulting exception to be a proper error:ava/lib/assert.js
Lines 147 to 154 in 952a017
I propose we add an
any: boolean
option to theexpectations
object used for these assertions. Iftrue
it won't cause a failed assertion when the exception is not an error.We need to update the validation logic here to allow this property:
ava/lib/assert.js
Line 74 in 952a017
Don't forget to update the type definition:
ava/index.d.ts
Line 11 in 952a017
If
any
istrue
, we should try and change the typing of the return value to beunknown
:ava/index.d.ts
Line 252 in 952a017
ava/index.d.ts
Line 263 in 952a017
And update our own tests:
ava/test-tap/assert.js
Line 786 in 952a017
ava/test-tap/assert.js
Line 976 in 952a017
See also the discussion in #1841.
The text was updated successfully, but these errors were encountered: