我正在使用 TestCafe 来运行我的集成测试。我知道它有test.skip
函数,当我在本地测试并想要跳过一组我不需要/不想运行的测试时,这非常有用......但我想知道是否有办法运行所有测试,除了 --test-meta environmentSpecific=true
etc?
我们有许多不同的环境,我正在寻找一种简单的方法来通过 CLI 跳过测试,具体取决于我们构建的目标环境。
是的,您可以使用编程方式运行 TestCafe 来完成此操作。
看一个例子:
const createTestCafe = require('testcafe');
let testcafe = null;
createTestCafe('localhost', 1337, 1338)
.then(tc => {
testcafe = tc;
const runner = testcafe.createRunner();
return runner
.src('/tests')
.filter((testName, fixtureName, fixturePath, testMeta, fixtureMeta) => {
return !testMeta.environmentSpecific;
})
.browsers(['chrome', 'safari'])
.run();
})
.then(failedCount => {
console.log('Tests failed: ' + failedCount);
testcafe.close();
});
也可以看看:指定测试元数据 https://devexpress.github.io/testcafe/documentation/guides/basic-guides/organize-tests.html#specify-test-metadata
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)