PhpStorm 2018.2 Help

Cucumber.js

Cucumber.js is a test framework for behavior driven JavaScript development. Cucumber.js tests are written in the human-readable Gherkin language and are stored in feature files that have the feature extension. PhpStorm integrates with Cucumber.js and recognizes features written in Gherkin so you can run Cucumber,js test right from the IDE.

Before you start

  1. Install Node.js.
  2. Install and enable the Cucumber.js and Gherkin repository plugins on the Plugins page as described in Managing Plugins.

Installing Cucumber.js

Running tests

Cucumber.js tests are launched only through a run/debug configuration.

To create a Cucumber.js run configuration

  1. Select a test file in the Project tool window and choose Create <file name> on the context menu. The Run/Debug Configuration: Cucumber.js dialog box opens.
  2. In the Feature file or directory text box, specify the tests to run. Type the path to a specific .feature file or to a folder, if you want to run a bunch of features.
  3. Specify the Node.js interpreter to use. This can be a local Node.js interpreter or a Node.js on WSL, see Configuring a local Node.js interpreter and Using Node.js on Windows Subsystem for Linux for details.
  4. In the Cucumber package field, specify the path to the folder where the cucumber package is stored or the location of the cucumber-js.cmd, cucumber-js.bat, or other executable depending on your operating system.
  5. Optionally:
    • In the Name Filter text box, type the name of a specific scenario to run instead of all the scenarios from the feature file or directory.
    • Specify the command line arguments to be passed to the executable file, such as -r (--require LIBRARY|DIR), -t (--tags TAG_EXPRESSION), or --coffee. For details, see native built-in help available through the cucumber-js --help command.

To run tests via a run configuration

  1. Select the Cucumber.js run/debug configuration from the list on the main toolbar and click icons toolwindows toolWindowRun svg to the right of the list.
    ws_select_run_configuration.png
  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.

With PhpStorm, you can jump between a file and the related test file. Navigation from a test result in the Test Runner Tab to the test is also supported.

To jump between a file and the related test file

  • Open the file in the editor and choose Go To | Test or Go To | Test Subject on the context menu, or just press Ctrl+Shift+T.

To jump from a test result to the test

  • Select the test name in the Test Runner tab and choose Jump to Source on the context menu.
    ws_test_jump_to_test
    The test file opens in the editor with the cursor placed at the test definition.
Last modified: 19 July 2018

See Also