PyCharm 2017.2 Help

Testing JavaScript with Cucumber.js

This feature is supported in the Professional edition only.

PyCharm supports integration with the Cucumber.js test framework. PyCharm recognizes features written in the Gherkin language.

Before you start

  1. Make sure the Node.js runtime environment is installed on your computer.
  2. Install and enable the NodeJS, Cucumber.js, and Gherkin repository plugins on the Plugins page as described in Installing, Updating and Uninstalling Repository Plugins and Enabling and Disabling Plugins.

Installing Cucumber.js

Open the built-in PyCharm Terminal (press Alt+F12 or choose View | Tool Windows | Terminal on the main menu) and type one of the following commands at the command prompt:

  • npm install cucumber for local installation in your project.
  • npm install -g cucumber for global installation.
  • npm install --save-dev cucumber to install Cucumber.js as a development dependency.
See also Cucumber.js demo on the Cucumber.js official website.

Running tests

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

To create a Cucumber.js run configuration

  1. Open the Run/Debug Configuration dialog box (Run | Edit Configurations on the main menu).
  2. Click /help/img/idea/2017.2/new.png on the toolbar and select Cucumber.js from the list. The Run/Debug Configuration: Cucumber.js dialog box opens.
  3. 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.
  4. In the Executable path text box, specify the location of the cucumber-js.cmd, cucumber-js.bat, or other depending on your operating system. The location depends on the installation mode.
  5. Optionally, 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 /help/img/idea/2017.2/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.

Navigation

With PyCharm, 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: 26 October 2017

See Also