Replies: 4 comments 1 reply
-
This is by design. Ultimately we want to report all failed assertions, not just the first one. It shouldn't typically be an issue but this behavior can be surprising when you first encounter it. AVA 4 updates some assertions to return booleans, for those use cases (e.g. to help with type narrowing when using TypeScript) where it's helpful not to continue. |
Beta Was this translation helpful? Give feedback.
-
I dont think I can use ava if this is by design 😞. If this behavior were opt-in or even opt-out, then I could manage. The way I write all my tests though is assuming the previous line succeeded. Adding if statements all over tests is going to be too arduous and verbose |
Beta Was this translation helpful? Give feedback.
-
Of course, I do the same. It's probably only some specific use cases where executing assertions conditionally is useful. However I find that when you have a series of assertions it doesn't really matter whether the test tries to run a few more. Are you doing something more complicated in the test that it really matters for execution to stop? |
Beta Was this translation helpful? Give feedback.
-
I'll admit this poses a question I haven't given a lot of thought to. I would say conversely though, is there. any use in continuing to execute a test after a failure has occurred? I guess it helps with testing unexpected states. The big reasons I think of are that my library does a lot of io which takes time. It also uses typescript, which adds to the setup time. When I run |
Beta Was this translation helpful? Give feedback.
-
I wrote a test and was confused because despite ava telling me there was a failure at a particular assertion, the test kept execution. I would have expected the test to short circuit at a failed assertion and throw an error. Instead, it seems to just continue and record that a failure happened somewhere. I dont know if this is expected behavior or a bug. If it is expected, please tell me how to disable it.
Sample code:
test output:
you can see the line
arrived here
is printed, though it shouldnt be.ava config:
ava version:
Beta Was this translation helpful? Give feedback.
All reactions