尽管内部声明失败,仍继续执行AfterEach挂钩中的步骤

时间:2018-10-06 18:19:59

标签: mocha

作为Mocha的普通用户,我在AfterEach回调中有一些清洁方法。

但是我那里还有一些测试,可以断言我的it()套件中每个describe()测试的输出

示例:

afterEach(async function () {
        1. expect(mytestMethod(), `this is test`).to.equal(true); //test
        2. console.log(this.currentTest.title, this.currentTest.state);
        3. await clearTargeting(); //Clean-up-after method
        }
    });

如果第1步失败,则不会执行第3步,但是我仍然需要执行此步骤以清除测试空间以进行下一个测试。

我尝试使用它,但是没有帮助。

if (this.currentTest.state === 'failed') {
            await clearTargeting();
        } else if (this.currentTest.state === 'passed') {
            await clearTargeting();
        }

有人做了类似的事情吗?将感谢您的帮助。

更新:已经通过在BeforeEach中移动方法来解决它:-) 但是无论如何,有趣的是,如我最初所问的那样。

0 个答案:

没有答案