jeudi 21 janvier 2021

Mocha shuts down whole test suite on beforeEach error

I'm using TypeScript with Mocha and Selenium. My problem is that if an Error gets thrown in beforeEach the whole test suite gets shut down. I'll try to illustrate it, this is how it would run on successful tests:

TestSuite A
     beforeEach hook for Test A
     Test A
     beforeEach hook for Test B
     Test B
     ...

This is how it currently runs if an Error occurres in "beforeEach hook for Test A":

TestSuite A
     beforeEach hook for Test A -> Error gets thrown
     TestSuite A gets exited

This is a problem for me because I'm using a Selenium wait in my beforeEach hooks. I'm waiting for a text to be changed on my webpage to "connected". This indicates that my clients have established a successful connection which is what I want. I'm basically setting up my environment in my beforeEach hooks.

This is how I'd like for it to run, this seems the most natural to me but Mocha for some reason does not work this way (while basically every other framework does work this way, like RSpec, JUnit, XUnit etc.)

TestSuite A
     beforeEach hook for Test A -> Error gets thrown
     beforeEach hook for Test B
     Test B
     ...

I'm using Node version v14.15.4 and Mocha 8.2.1. Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire