How to check in afterEach if an it block passed or failed

38 views
Skip to first unread message

daniel...@human.x.ai

unread,
Jul 7, 2017, 6:53:38 PM7/7/17
to Jasmine
Hi there.

I am using protractor/jasmine 2.0. I have setup jasmine-spec-reporter. I want to be able to add something like this to my spec tests:

afterEach(() => {
    if (specFailure > 0) {
      // do something
   }
});

Basically I wan to check after each it block runs if it passed or not and if not do something in that case. Is this possible? If so how?

Thanks in advance.

Gregg Van Hove

unread,
Jul 7, 2017, 7:46:37 PM7/7/17
to jasmi...@googlegroups.com
A reporter is the only for sure way to handle spec failures. It is possible for an `afterEach` to cause an otherwise passing spec to fail (i.e. by failing an `expect` or throwing an error). At least partially because of this, an `afterEach` is unable to get the current status of the spec as it is running.

Hope this helps. Thanks for using Jasmine!

-Gregg

--
You received this message because you are subscribed to the Google Groups "Jasmine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jasmine-js+unsubscribe@googlegroups.com.
To post to this group, send email to jasmi...@googlegroups.com.
Visit this group at https://groups.google.com/group/jasmine-js.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages