0

We have around 400+ TestCafe js files and we are running these tests nightly through our CI/CD pipeline. Our problem right now is that, it consumes a lot of hours before it completes the test. What we are planning to do is to split up those tests maybe at least 4. Now my question is: How can we run the TestCafe in 4 instances with each instance runs the split tests?

For example: Instance 1 - runs Tests #1 - #100 Instance 2 - runs Tests #101 - #200 Instance 3 - runs Tests #201 - #300 Instance 4 - runs Tests #301 - #400

Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47

2 Answers2

1

You can use fixture or test metadata and hen execute a different command in each instance.

For example you use fixture metadata:

fixture `My fixture`
    .meta('instance', '1')

// and somewhere else:
fixture `My fixture`
    .meta('instance', '2')

then to run only tests within fixtures with a specific metadata:

$ testcafe chrome my-tests --fixture-meta instance=1

Or you can just group those fixture files in different directories and then run tests from only a specific directory:

$ testcafe chrome ./Tests/instance-one/*.js
pavelsaman
  • 7,399
  • 1
  • 14
  • 32
  • Thank you @pavelsaman I believe this will only run for one instance, right? How about running all 4 instances? Like 4 different runs or 4 different windows all at once so that we could reduce the no. of hours the test spent. – Rommel-Neptune Jun 17 '21 at 17:21
0

I think I've found a solution to my own problem. I've installed this package called npm-run-all

I added the split tests in the package.json

"test:split1": "testcafe chromium src-compact/SplitTest1.js --skip-js-errors",
"test:split2": "testcafe chromium src-compact/SplitTest2.js --skip-js-errors",
"test:parallel": "npm-run-all -p test:split1 test:split2"

And then execute it by running this command:

npm run test:parallel