A popular headless browser is PhantomJS (http://phantomjs.org/). Since it is pretty popular and easy to set up, I want to discuss it here, but I should mention upfront that it does not work well with Protractor. The Protractor team actually recommends that you do not use PhantomJS with Protractor. I concur, I never got it to work together either. However, it works fine for Karma, so let's set that up.
Installation of PhantomJS is easy, it is just a regular npm installation. Of course, you will also need to install the appropriate Karma launcher:
npm install phantomjs --save-dev npm install karma-phantomjs-launcher --save-dev
You can now use PhantomJS as a browser in your Karma configuration:
If you now start ...