A Flatiron student asked me for help the other day on how to change her Karma testing browser in Angular from Chrome to Firefox.
She specifically focused on switching from Chrome to Firefox, but these instructions can be modified to add browser types instead, or replaced with different browsers. Just do a Google search for ‘karma
Here are the steps:
-
Go to
package.json
and change thekarma-chrome-launcher
package tokarma-firefox-launcher
- As of the writing of this blog post, the current version is^1.1.0
. -
Re-run
npm install
to unintall the previous launcher and install the new one. -
In
karma.conf.js
in the:plugins
key, replacerequire("karma-chrome-launcher")
withrequire("karma-firefox-launcher")
in the plugins array. -
Still in
karma.conf.js
, go to the:browsers
key, and replaceChrome
withFirefox
in the browsers array.
Then, run karma start
and your tests should work in the proper browser!