问题
I have several runners which are using promise.race to complete the testcase at a particular time Say I have runner1.js, runner2.js runner3.js, how do I create a master runner so that I can run all these runners together?
const createTestCafe = require('testcafe');
let testcafe = null;
// createTestCafe('localhost', 1337, 1338)
createTestCafe()
.then(tc => {
testcafe = tc;
//create test runner for configuring and launching test tasks
const runner = testcafe.createRunner();
return runner
//run test from specified folders/files
.src(['*the path to all runner.js*'])
//configure the test runner to run tests in the specified browsers
.browsers('chrome')
.reporter('html-testrail')
.run({skipJsErrors:true})
})
.catch(failedCount => {
console.log('Tests failed: ' + failedCount);
testcafe.close();
})
it's not working this way, any suggestions?
回答1:
TestCafe allows running multiple test runners at the same time. Check the following code:
const createTestCafe = require('testcafe');
(async () => {
const testCafe = await createTestCafe();
const runner1 = testCafe
.createRunner()
.src('test1.js')
.reporter([{ name: 'spec', output: 'report1.txt' }])
.browsers('chrome');
const runner2 = testCafe
.createRunner()
.src('test2.js')
.reporter([{ name: 'spec', output: 'report2.txt' }])
.browsers('firefox');
await Promise.all([runner1, runner2].map(runner => runner.run()));
await testCafe.close();
})();
来源:https://stackoverflow.com/questions/58068687/master-runner-in-testcafe-for-several-other-runners