Now you can choose either to use JSTestDriver to run your test in WebStorm (learn about the JSTestDriver plugin), or to try Karma.
Here is some basic info about Karma integration in WebStorm:
- It uses a local server to run the tests in the selected browsers installed on your computer;
- It can run tests written with the use of Jasmine, QUnit, or Mocha, or write a simple adapter to use any other framework you like;
- It works with the istanbul code coverage engine.
To start using Karma, make sure that Node.js is installed on your computer. You can install Karma globally or locally in your project directory with WebStorm’ built-in npm (click Node.js Setting in the toolbar to search and install karma module). The recommended approach is to install Karma locally in the project’s directory.
Configure Karma for your project by adding or generating a Karma configuration file. In this configuration file you should specify the testing framework you are going to use, and select browsers for testing.
Next, you create a Karma Run Configuration that will allow you to simply run your tests anytime in WebStorm in one click.
Test results are presented in a nice visual format in the Run panel for Karma. You can navigate from the test result to its code, check statistics for the tests execution, and make HTML reports from it.
WebStorm provides support for the istanbul code coverage engine that is used by Karma. Install node module karma-coverage and add coverage settings in Karma configuration file, and then simply click the Run with coverage button to get the report of the coverage of your code with tests.
Develop with pleasure!