Is it possible to run Karma with no browsers at all?

randwa1k picture randwa1k · Feb 20, 2014 · Viewed 15.1k times · Source

I started an Angular.js app with Yeoman's yo angular that includes Karma testing. Then, the grunt test reasonably failed because Karma can't find any browsers. (The browsers has not been set in the app's node_modules/karma config file.)

I'm doing my development via SSH into a remote machine, which I think (let me know if I'm wrong) is pointless to have Chrome, /usr/bin/chromium-browser, installed.

So is it possible to run Karma without any browsers?

Answer

Clay picture Clay · May 12, 2019

I am going to add my two cents to this.

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.

We used this configuration for our CI/CD deployments. Our Docker image for running the tests had Chrome installed and we ran them with Chrome headless mode. Worked like a charm.

To use this, simply modify your browsers property in your karma.conf.js

browsers: ['ChromeHeadless']

Hope this might help someone out there who may be looking for something similar...