When I enter 'karma start' in the WebStorms' terminal, it opens Chrome and I can start testing, when I make some changes, it reruns the tests. But what is the difference when I type Karma start or when I click un Run Karma? Is Run Karma only for test reporters?
There are 2 console commands:
karma start
karma run
Karma start creates a karma server with the given config file and opens a browser window which connects to that server and waits for tests. You should use karma start after every change of your karma.conf.js
file. The PhpStorm plugin does this automatically, by run it checks whether the config file is changed, and if so, it executes karma start
before karma run
.
Karma run sends your tests to the browser and runs them there. Your should use this after every change of your code or unit tests. Ofc the PhpStorm plugin does this automatically by every run.
The standard way is to run karma start
and karma run
as described by @inf3rno.
When running karma on CI/CD it's good to start karma, run the tests and exit. It's possible to reach using the singleRun: true
option in the karma.conf.js
. Check it out in the docs http://karma-runner.github.io/1.0/config/configuration-file.html.
© 2022 - 2024 — McMap. All rights reserved.
--single-run
directly from the CLI. – Neighboring