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

You may also like:

Did you love / hate / were unmoved by this post?
Then show your support / disgust / indifference by following me on Twitter!

This post got one comment so far. Care to add yours?

  1. […] Artigo traduzido pela Redação iMasters com autorização do autor. Publicado originalmente em http://tatiyants.com/how-to-configure-intellij-idea-for-angular-js-testing/ […]