Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to run parallel tests using karma

At the moment we have close to 1000 unit tests written in jasmine/typescript. When I run them all they take as much as 5 mins on chrome. We do have some unit tests which deals with DOM as well. e.g. verify if a button exists with specified text. We have a number of files where these tests are distributed. We have noticed that when we run individual files and sum up total time taken, it is far less than that of when we run all tests in one go. That's why we are thinking if there is a way to run tests in parallel? The plan is to divide tests and run them in parallel.

like image 776
TypeScripter Avatar asked Mar 23 '17 00:03

TypeScripter


People also ask

Does karma run tests in parallel?

We can utilize karma-parallel plugin to execute test cases parallely. This npm package splits your unit tests into multiple suites that run in parallel with each other, on different threads of your processor.

What is karma parallel?

A Karma JS plugin to support sharding tests to run in parallel across multiple browsers.

Do Jasmine tests run in parallel?

Jasmine doesn't actually support parallel execution. It runs one spec (or before/after) function at a time.

Does go test run tests in parallel?

The 'go test' command may run tests for different packages in parallel as well, according to the setting of the -p flag (see 'go help build').


1 Answers

You can use karma-parallel to split up your tests across multiple browser instances. It runs specs in different browser instances and is very simple and easy to install:

npm i karma-parallel

and then add the 'parallel' to the frameworks list in karma.conf.js

module.exports = function(config) {
  config.set({
    frameworks: ['parallel', 'jasmine']
  });
};

karma-parallel

Disclosure: I am the author

like image 54
Joel Jeske Avatar answered Oct 04 '22 11:10

Joel Jeske