describe('some tests', function () {
/*
* Run some tests...
*/
})
after(function () {
failures = ? // <--- what goes here?
console.log(failures + " tests failed!")
})
如果测试失败,我会用它来保持 chromedriver 的浏览器打开,并返回到 report success or failure to sauce labs .
Mocha 的运行者和记者 have the info I'm looking for作为 stats
但我不确定如何从测试文件中获取它们。
最佳答案
我找到了这个问题的答案 here
afterEach(function() {
if (this.currentTest.state == 'failed') {
// ...
}
});
关于javascript - 我如何检查 after block 中是否有任何 mocha 测试失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22031765/