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)
Karma parallel tests execution In short it spins up multiple instances of a browser from a single karma server.
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.
The configuration file can be generated using karma init : $ karma init my. conf.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With