npm install cucumberfor local installation in your project.
npm install -g cucumberfor global installation.
npm install --save-dev cucumberto install Cucumber.js as a development dependency.
Creating test definitions
Position the caret at the step without a definition, press Alt+Enter, and select Create step definition or Create all step definitions.
Alternatively, hover the mouse over the step and use the links in the popup.
In the dialog that opens, specify the name for the new file and the language to write the definitions in.
If such file already exists, PyCharm displays a popup where you have to select a file to add the definition to or choose to create a new file.
Create a Cucumber.js run configuration
Specify the working directory of the application. By default, the Working directory field shows the project root folder. To change this predefined setting, specify the path to the desired folder or choose a previously used folder from the list.
In the Name Filter field, 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
--tags TAG_EXPRESSION, or
--coffee. For details, see native built-in help available through the
Run tests via a run configuration
The test server starts automatically without any steps from your side. View and analyze messages from the test server in the Run tool window.
Monitor test execution in the Test Runner tab of the Run tool window.
Run and debug tests from a test file
To run or debug a single test, open the test file in the editor, position the caret at the scenario to run or debug, and then selector from the context menu.
To run or debug all tests from a single test file, open the test file in the editor or select it in the Project tool window and choose or from the context menu.
In either case, PyCharm creates a run/debug configuration which you can save and use later.
Running and debugging tests written in TypeScript
Create a Cucumber.js run/debug configuration as described above.
In the Before launch area, click , select Compile TypeScript from the list, and then specify the tsconfig.json file to use. PyCharm will run the TypeScript compiler with this tsconfig.json before running Cucumber.js.
To debug tests written in TypeScript, open your tsconfig.json and set
"sourceMap": trueto enable source maps.
With PyCharm, you can jump between a file and the related test file or from a test result in the Test Runner Tab to the test.
Open the file in the editor and selector from the context menu, or just press Ctrl+Shift+T.
To jump from a step in a .feature file to the step definition, press and hold Ctrl, hover over the step, and click the step when it turns into a link.
To jump from a test result to the test, select the test name in the Test Runner tab and choose Jump to Source from the context menu. The test file opens in the editor with the cursor placed at the test definition.
Configuring syntax highlighting
You can configure Cucumber.js-aware syntax highlighting according to your preferences and habits.
Select the color scheme, accept the highlighting settings inherited from defaults or customize them as described in Configuring Colors and Fonts.