You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why is that? We need that because this is the only way to capture the entire error object. And assert on objects within.
Current functionality of Jest for capturing error only allows to see the message of the exception not the entire error object.
The text was updated successfully, but these errors were encountered:
This is laid out in the docs for no-conditional-expect: It's because Jest only considers a test to have failed if it throws an error.
For example with your code, if await axios(url) is successful, the test will be marked as passing despite having not called expect.
The quickest way to fix the underlying error would be to add a throw in the try:
However that is still considered a conditional by our rule, which wants you to get the expect out of the catch all together - I outlined a good way of doing this with a wrapper here, which I've distilled into a PR adding this to the docs for no-conditional-expect :)
Hi everyone,
When I was implementing testing with Jest for Axios, I've noticed that this is regarded as anti pattern:
Why is that? We need that because this is the only way to capture the entire
error
object. And assert on objects within.Current functionality of Jest for capturing error only allows to see the message of the exception not the entire error object.
The text was updated successfully, but these errors were encountered: