我正在使用TestCafe来运行我的集成测试。我知道它有test.skip
函数,这对于我在本地测试时想要跳过一组我不需要/想要运行的测试很有用但是我想知道是否有办法运行所有测试除了--test-meta environmentSpecific=true
等?
我们有许多不同的环境,我正在寻找一种通过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();
});