Appendix A. Setting up Karma
Karma is a JavaScript test runner created by the AngularJS team. It’s important to note that it’s not a testing framework. It allows you to specify information about your testing environment, such as which browser(s) to use, which files to include, and so on. You then specify which testing framework you want to use (Jasmine, in our case) and write your tests using that particular framework.
First things first. If you haven’t yet installed Node.js, stop! Here are a couple resources to get the ball rolling:
- https://nodejs.org/download/
- You’re in luck: Node.js comes with npm!
If you do have Node.js and npm, welcome! First, install karma-cli globally so you have access to it in any directory:
Next, make sure you’re in the angello directory, and then install karma and save it as a dev dependency:
Now, install your necessary plugins. These include the plugins for your testing framework of choice as well as any browsers that you need to integrate with. In this book, we use Jasmine as our testing framework and Chrome for our browser.
Now that you have all the dependencies installed, it takes only a single command in the terminal to initialize the Karma configuration: