我知道如何在afterEach()
mocha 的方法中检查测试是否失败:这里解释了:从 Mocha 中的 afterEach 挂钩中检测测试失败
但是那些使用suite
and test
(tdd) 而不是describe
and的人呢it
?
如何检查当前测试是否在此处失败?state
由于未定义,相同的代码将不起作用:
teardown(async () => {
// check if failed:
if (this.currentTest.state === 'failed') {
console.log("fail");
}
});