4 min
front-end · tools · testing

How to Configure IntelliJ IDEA For Angular JS Testing

April 3, 2014 · 4 min
Contents
  1. 1. Install Karma
  2. 2. Install Karma plugin
  3. 3. Configure Karma Run Configuration
  4. 4. Configure Jasmine
  5. 5. Enable Jasmine library for your project
  6. References

If you’re using IntelliJ IDEA and writing Angular tests using Karma/Jasmine, IDEA can make this a very pleasant experience:

IntelliJ 13 running Karma Jasmine tests

Note the fact that IDEA is aware of Jasmine syntax and uses the built-in test runner to run Karma tests. Here’s a quick summary of how to do it.

1. Install Karma

At the command line, type the following (assumes you’ve already installed node/npm):

npm install -g karma

2. Install Karma plugin

Go to Settings > Plugins > Browse Repositories > search for “karma”:

IntelliJ 13 install Karma plugin

Note that this requires IDEA 13.

3. Configure Karma Run Configuration

Go to Run > Edit Configurations, add new configuration of type Karma:

IntelliJ Configure run configufation

4. Configure Jasmine

Go to Settings > JavaScript > Libraries, add a new Global Library. Then, navigate to wherever npm installs its modules (probably /usr/local/lib/) and select the jasmine.js file from node_modules/karma-jasmine/lib/jasmine.js:

IntelliJ 13 Global Library Jasmine configuration

5. Enable Jasmine library for your project

Click on the “Hector” icon (a little guy in a bowler hat at the bottom right of the screen) and click “Configure Inspections”:

IntelliJ Configure inspections

Select jasmine library click OK:

Intellij 13 enable library for project

References