vendredi 1 novembre 2019

How to check in the teardown method of mocha (tdd) if the current test failed?

I know how to check if a test failed in the afterEach() method of mocha: That's explained here: detecting test failures from within afterEach hooks in Mocha

But what about the people using suite and test (tdd) instead of describe and it??

How can I check if the current test failed here? The same code won't work because state would be undefined:

  teardown(async () => {
    // check if failed:
    if (this.currentTest.state === 'failed') {
      console.log("fail");
    }
  });

Aucun commentaire:

Enregistrer un commentaire