Search code examples
javascriptautomated-testse2e-testingweb-testingtestcafe

How to run a some testsuites with concurrency and rest without concurrency using TestCafe?


I have 6 test suites out of which I would like to run 5 of them with 3 concurrent browsers and the remaining 1 without concurrency. Also, I would like to get 1 HTML file result of all the 6 test suites.

I have looked into the test runner but unable to figure out how do I run the 1 test suite without concurrency.

Here is the code from TestRunner:


let testcafe = null;

createTestCafe('localhost', 1337, 1338)
  .then((tc) => {
    testcafe = tc;
    const runner = testcafe.createRunner();

    return runner
      .src('uitests/tests/test1.js', 'uitests/tests/test2.js', 'uitests/tests/test3.js', 'uitests/tests/tes4t.js', 'uitests/tests/test5.js')
      .browsers('chrome:headless')
      .screenshots('screenshots', true)
      .reporter('html', 'resultsrunner.html')
      .concurrency(3)
      .run({
        skipJsErrors: true,
      })
  })
  .then(() => {
    testcafe.close();
  });

What should I do to make my test6.js run without concurrency and append the results of all the 6 test suites in an HTML file?

      .src('uitests/tests/test6.js')
      .browsers('chrome:headless')
      .screenshots('screenshots', true)
      .reporter('html', 'resultsrunner.html')
      .run({
        skipJsErrors: true,
      })```

Solution

  • Testcafe does not support combining of tests with and without concurrency in one run. A slightly better approach than the one suggested by TallKU is to implement a custom testcafe reporter and to use the same reporter's instance for two testcafe runs.