【发布时间】:2019-07-31 09:56:53
【问题描述】:
是否可以在隔离模式下运行一些测试而在没有该模式的情况下运行其他测试? 例如,我们有一些轻量级测试,我们不需要为它们尝试 3 次,但对于其他测试可能是必要的
【问题讨论】:
标签: testing automated-tests e2e-testing web-testing testcafe
是否可以在隔离模式下运行一些测试而在没有该模式的情况下运行其他测试? 例如,我们有一些轻量级测试,我们不需要为它们尝试 3 次,但对于其他测试可能是必要的
【问题讨论】:
标签: testing automated-tests e2e-testing web-testing testcafe
您可以使用不同的filters 串联运行两个 testcafe 运行器。其中之一可能是隔离模式。
例如:
const createTestCafe = require('testcafe');
let testcafe = null;
const runTests = (testFiles, quarantineMode, testPrefix) => {
const runner = testcafe.createRunner();
return runner
.src(testFiles)
.filter((testName) => testName.startsWith(testPrefix))
.browsers(['chrome'])
.run({ quarantineMode });
};
createTestCafe('localhost', 1337, 1338)
.then(tc => {
testcafe = tc;
return runTests(['test.js'], false, 'Simple')
.then(() => runTests(['test.js'], true, 'Complex'));
})
.then(() => testcafe.close());
测试:
test('Simple Test', async t => {
//...
});
test('Complex Test', async t => {
//...
});
【讨论】: