This folder is, by convention, the place for all step definitions.
Let's say you want to create a step-definition file for the sentence When I do something specific
.
-
Create a new empty file in the
steps
folder and name iti-do-something-specific.ts
. -
Consider using the kebab-case naming convention in order to quickly find the implementation associated to the step through the Command Palette:
-
Copy, in this new file, the content of the basic template step definition file or the content of the not implemented step definition file;
-
Adapt the jsDoc comments:
/**
* @step
* @when("I do something specific")
*/
- If the statement should be available as a
Given
and aWhen
step, the JSDoc comments should be:
/**
* @step
* @given,@when("I do something specific")
*/
- If the same step-definition must be re-used for different statements, the JSDoc comments should be (see this step implementation for more details):
/**
* @step
* @given,@when("I do something specific")
* @when("I set the user name as 'john doe'")
* @when("I set the user name as 'Perry Scope'")
* @when("I set the user name as 'Art Decco'")
*/
- for a
Then
step:
/**
* @step
* @then("I do something specific")
*/
- for a
But
step:
/**
* @step
* @but("I do something specific")
*/
- Save the new step-definition file and run the following command in a terminal window:
npm run build-step-mappings
- Now go back to the feature file. The sentence should be available in the intellisense:
You MUST run this command each time you add/modify/move/delete a step-definition file.:
npm run build-step-mappings