我正在使用TestCafe来运行集成测试。我知道它具有test.skip
函数,该函数非常适合当我在本地进行测试并且想要跳过不需要/不想运行的一组测试时...但是我想知道是否有一个除{em> --test-meta environmentSpecific=true
等以外的所有测试的方式?
我们有许多不同的环境,我正在寻找一种简单的方法来通过CLI跳过测试,具体取决于我们针对构建的目标环境。
答案 0 :(得分:4)
是的,您可以使用编程方式来运行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();
});