For jasmine test, will afterEach() get executed if an `it` block fails?

#1

For jasmine test, will afterEach() get executed if an it block fails?

Let’s say that for every it block, there are some objects created. And they are supposed to be removed in afterEach(). I just want to know, when an it block fails, whatever was created will be removed.

0 Likes

#2

Yes. afterEach() is meant for teardown: https://jasmine.github.io/api/edge/global.html#afterEach
Teardown is for cleaning up state after a test, even if the test fails.

For more on Jasmine test execution order:

1 Like