WebStorm 9.0.0 Web Help

JavScript unit tests are run in a browser against a test server which actually handles the testing process.

This server allows you to capture a browser to run tests in, loads the test targets to the captured browser, controls the testing process, and exchanges data between the browser and WebStorm, so you can view test results without leaving the IDE.

The test server does not necessarily have to be on your machine, it can be launched right from WebStorm through the Karma test runner. Cucumber.js runs tests that are called features and are written in the Gherkin language. Each feature is described in a separate file with the extension feature.

On this page:

Prerequisites
  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 Cucumber.js test runner is installed as described in Preparing to Use Cucumber.Js Test Runner.
  4. Make sure the Node.js plugin is enabled. The plugin is bundled with WebStorm and activated by default. If it is not, enable it as described in Enabling and Disabling Plugins.
  5. Make sure the Cucumber.js and Gherkin plugins are enabled. The plugins are bundled with WebStorm and activated by default. If not, enable them as described in Enabling and Disabling Plugins.
Creating a Cucumber.js run configuration
  1. Open the Run/Debug Configuration dialog box by doing one of the following:
    • On the main menu, choose Run | Edit Configurations.
    • Press RunConfigurationRunConfigurationRunConfigurationRunConfigurationRunConfigurationRunConfigurationRunConfigurationRunConfigurationRunConfigurationRunConfigurationRunConfiguration and choose Edit Configuration on the context menu.
    • 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 Cucumber.js configuration type. The Run/Debug Configuration: Cucumber.Js dialog box opens.
  3. In the Feature file or directory text box, specify the tests to run. Cucumber.js runs tests that are called features and are written in the Gherkin language. Each feature is described in a separate file with the extension feature.
    • To have one feature executed, specify the path to the corresponding .feature file.
    • To have a bunch of features executed, specify the folder where the .feature files to run are stored.
  4. In the Executable path text box, specify the location of the cucumber executable file, .cmd, .bat, or other depending on the operating system used. The location depends on the installation mode, see Installing the Cucumber.js test runner.
  5. Optionally, specify the command line arguments to be passed to the Cucumber.js executable file, such as -r (--require LIBRARY|DIR), -t (--tags TAG_EXPRESSION), or --coffee. For details, see Cucumber's native built-in help available through the following command:
    cucumber-js --help
                    
  6. Apply the changes and close the dialog box.
Launching unit tests
  1. To launch the tests according to a run configuration, select the Cucumber.js run/debug configuration from the list on the main toolbar.

    ws_select_run_configuration.png

    Then click the Run button run.png  to the right of the list.
  2. The test server starts automatically without any steps from your side. View and analyze messages from the test server in the Run tool window.
  3. Monitor test execution in the Test Runner tab of the Run tool window as described in Monitoring and Managing Tests.

See Also

Procedures:

Reference:

External Links:

Web Resources: