I usually use browsers=['PhantomJS'] for running my specs with karma because it's faster than chrome and I find a bit annoying when chrome opens the browser in front of the window on every boot.
But when I have a bug and I need to debug, I change karma.conf.js browsers to ['Chrome'].
I would like to set this property when I start karma, something like: 'karma start --browsers=[Chrome]'.
Is this posible?
Setting singleRun: false assumes that you are explicitly start the karma-client manually. 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.
Correct - Karma requires a browser to run. BUT - you can run Chrome in Headless mode, which means although you do need the browser installed, it will not open it's UI, and you can therefore run the tests purely through an SSH session for example.
In order to serve you well, Karma needs to know about your project in order to test it and this is done via a configuration file. The easiest way to generate an initial configuration file is by using the karma init command. This page lists all of the available configuration options.
Preprocessors in Karma allow you to do some work with your files before they get served to the browser. These are configured in the preprocessors block of the configuration file: preprocessors: { '**/*. coffee': ['coffee'], '**/*.
you just have to use the --browsers parameter and it'll overide your config file browsers part.
$ karma start config/testacular.conf.js --browsers Chrome
where Chrome is the name of the browser or a path to a binary.
For example, I have only a small Qt browser configured. if I use the line above, it runs Chrome instead.
INFO [karma]: Karma server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 24.0 (Linux)]: Connected on socket id DxbVJNX0jIoe1CbaWf9V
Chrome 24.0 (Linux): Executed 74 of 74 SUCCESS (0.443 secs / 0.232 secs)
...
or, for example, I have firefox beta, aurora and release in my home. I run beta with:
$ karma start config/testacular.conf.js --browsers ~/firefox/firefox
$ karma start --help
Karma - Spectacular Test Runner for JavaScript.
START - Start the server / do a single run.
Usage:
karma start [<configFile>] [<options>]
Options:
--port <integer> Port where the web server is running.
--runner-port <integer> Port where the server is listening for runner.
--auto-watch Auto watch source files and run on change.
--no-auto-watch Do not watch source files.
--log-level <disable | error | warn | info | debug> Level of logging.
--colors Use colors when reporting and printing logs.
--no-colors Do not use colors when reporting or printing logs.
--reporters List of reporters (available: dots, progress, junit).
--browsers List of browsers to start (eg. --browsers Chrome,ChromeCanary,Firefox).
--capture-timeout <integer> Kill browser if does not capture in given time [ms].
--single-run Run the test when browsers captured and exit.
--no-single-run Disable single-run.
--report-slower-than <integer> Report tests that are slower than given time [ms].
--help Print usage and options.
--version Print current version.
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