Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limiting parallel browser instance in Karma

I want to run some tests with Karma using multiple browsers. However, the tests are integration tests that interact with the database (get and update data). Since the same tests are run in multiple browsers, they all interact with the same test data.

Therefore, if the tests are run concurrently in multiple browsers, one test may impact other tests running in other browsers.

How can I limit the number of concurrent browsers, while still testing with multiple browsers? (for example, setting a limit to 1 would result in running tests for each browser in sequence instead of in parallel)

like image 640
ckarras Avatar asked Nov 06 '14 21:11

ckarras


People also ask

Does karma run tests in parallel?

Karma parallel tests execution In short it spins up multiple instances of a browser from a single karma server.

What does it mean to set the single run attribute to true located in the karma Conf js file?

This means that you start karma (technically the karma-server ), then go to another terminal and type karma run . Setting singleRun: true in your karma configuration will call karma run for you. Here's the doc: karma-runner.github.io/0.13/plus/requirejs.html.

What is the command used for karma configuration used for using CLI?

The configuration file can be generated using karma init : $ karma init my. conf.

What is karma config file?

The Karma configuration file can be written in JavaScript, CoffeeScript, or TypeScript and is loaded as a regular Node. js module. Unless provided as argument, the Karma CLI will look for a configuration file at. ./karma.conf.js.


1 Answers

This has been fixed in https://github.com/karma-runner/karma/pull/1646 and merged into 0.13.2:

concurrency

Type: Number

Default: Infinity

Description: How many browser Karma launches in parallel.

Especially on sevices like SauceLabs and Browserstack it makes sense to only launch a limited amount of browsers at once, and only start more when those have finished. Using this configuration you can sepcify how many browsers should be running at once at any given point in time.

https://karma-runner.github.io/2.0/config/configuration-file.html

like image 179
Andy Avatar answered Oct 18 '22 14:10

Andy