From now on, users of JsTestDriver can measure code coverage visually, right in the editor.
To illustrate this, we have created a sample project for you. Please download percentage-sample.zip , extract it and open the project in your IDE.
When you open percentage-test.js for the first time, you will see error highlighting on the
TestCase method call expression. Position the caret on the error-highlighted code, press Alt+Enter/Option+Enter and choose “Add JsTestDriver assertion framework support” from the list of available intention actions.
Before you can run any of your tests, you need to start the test server and capture at least one slave browser. The server does not have to reside on the machine where the test runner is located; similarly, the browsers themselves may be located on different machines.
Starting JsTestDriver server locally
To launch the JsTestDriver server, look for the tool window at the bottom of the screen.
Click the green arrow to the left of the address bar to start a local server. The status bar turns yellow to let you know the server is running, but has no slave browsers.
Click the browser icon you want to capture. Alternatively, you can copy the capture URL and paste it in a browser. The status bar turns green, and the corresponding browser icon lights up. Now you’re ready to run tests.
Running tests with code coverage
To run tests, right-click percentage.jstd and choose Run ‘percentage.jstd’ with Coverage. Tests will be run against the local JsTestDriver server and you will get a tree diagram.
It also shows which lines were exercised by your unittests, and which weren’t, in two places. First, in your source files, it adds a green bar (exercised) or red bar (omitted) to the left of the source lines:
You can also see test coverage statistics by file and by directory in your Project View:
Excluding files from code coverage
We’d appeciate to hear responses from you in our issue tracker ;).
Note: Users of PhpStorm, as well as other JetBrains IDE – IntelliJ IDEA, PyCharm, RubyMine, and AppCode – should install it from the plugin repository by following these instructions.
Test with pleasure!
Subscribe to Blog updates
Thanks, we've got you!
Nx Console Idea: A Must-Have JetBrains IDE Plugin for Nx Developers
This is a guest blog post by Issam Guissouma, developer of the Nx Console Idea plugin.
FOMO Digest #3: Top 7 Features for React Development in JetBrains IDEs
The third edition of our FOMO digest with tips on using React in JetBrains IDEs.