PyCharm 2017.2 Help

Testing JavaScript

This feature is supported in the Professional edition only.

With PyCharm, you can run and debug JavaScript unit tests using Mocha, Karma, Jest, Protractor, and Cucumber.js.

You can see the test results in a treeview and easily navigate to the test source from there. Test status is shown next to the test in the editor with an option to quickly run or debug it:

ws_run_test_from_editor.png

For Karma and Mocha you can also see a code coverage report right in PyCharm.

Navigation

You can quickly jump from the source code to the related test file with the Go to test action (Ctrl+Shift+T or Navigate | Test). For example, from auth.js you can jump to auth.test.js.

Running and debugging tests

Before you start with testing JavaScript, make sure the chosen test runner is installed and set up in your project as described on the corresponding page.

To quickly run or debug a single test with Mocha, Karma, or Jest
Click run.png or rerun.png in the left gutter and choose Run <test_name> or Debug <test_name> from the pop-up list.

To run or debug tests using a run/debug configuration

  1. In the Run/Debug Configuration dialog box (Run | Edit Configurations), click /help/img/idea/2017.2/new.png, select the appropriate configuration type, and fill in the required fields.
  2. Save the configuration and click /help/img/idea/2017.2/run.png, /help/img/idea/2017.2/runWithCoverage.png, or /help/img/idea/2017.2/debug.png on the toolbar.
For a more detailed overview, see:

Last modified: 26 October 2017

See Also