【发布时间】:2021-04-15 13:29:11
【问题描述】:
我使用 WebdriverIO 通过 mocha 框架进行 E2E 测试
当我运行测试时,我希望在第一个错误之后,跳过此测试中的所有后续检查,然后 Mocha 转到下一个测试文件
作为一个例子,我展示了下面的代码,需要从每个测试文件中取出并全局应用。
我需要将 beforeEach 和 afterEach 从规范移动到全局配置 WDIO [mocha, hook, wdio]
我需要将代码从规范移动到全局配置 WDIO
主要目标是在测试失败后跳过测试
import { expect } from 'chai';
describe('Verify next it is skipped', function () {
let skipNextIt = false;
beforeEach(function () {
if (skipNextIt) {
this.skip();
}
});
afterEach(function() {
if(this.currentTest.state === 'failed') {
skipNextIt = true;
}
});
it('is should pass', function () {
expect(true).to.equal(true);
});
it('is should fail', function () {
expect(true).to.equal(false);
});
it('is should skipp 1', function () {
expect(true).to.equal(true);
});
it('is should skipp 2', function () {
expect(true).to.equal(true);
});
});
【问题讨论】:
-
什么是 wdio?到目前为止你尝试了什么?你有错误吗?请解释更多
标签: typescript mocha.js hook wdio-v6