master runner in testcafe for several other runners?

℡╲_俬逩灬. 提交于 2019-12-24 07:39:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!