WebStorm 10.0.0 Help

Running Unit Tests on KarmaRunning Nodeunit Tests

Running Mocha Unit Tests

On this page:


  1. Download and install Node.js. The framework is required for two reasons:
    • The transpiledLanguage toolType is started through Node.js.
    • NPM, which is a part of the framework, is also the easiest way to download the transpiledLanguage toolType.
  2. If you are going to use the command line mode, make sure the following paths are added to the PATH variable:
    1. The path to the parent folder of the Node.js executable file.
    2. The path to the npm folder.

    This enables you to launch the transpiledLanguage toolType and npm from any folder.

  3. Make sure the Mocha test framework is installed as described in Preparing to Use Mocha Test Framework.
  4. Make sure the Node.js plugin is enabled. The plugin is bundled with WebStorm and activated by default. If the plugin is not activated, enable it on the Plugins page of the Settings dialog box as described in Enabling and Disabling Plugins.

Creating a Mocha run configuration

  1. Open the Run/Debug Configuration dialog box by doing one of the following:
    • On the main menu, choose Run | Edit Configurations.
    • Open the test file in the editor, and then choose Create <file name> on the context menu.
    • Select the test file in the Project tool window, and then choose Create <file name> on the context menu of the selection.
  2. Click the Add button add on the toolbar and select the Mocha configuration type.
  3. In the dialog box that opens, specify the location of the Node.js and Node package, the working directory and the test directory, and choose the interface used in the test to run.
  4. Apply the changes and close the dialog box.

See Also

Last modified: 25 July 2015