Skip to content

Commit

Permalink
docs: missing steps
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalets committed Oct 19, 2024
1 parent a6dc85c commit cbad130
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [Cucumber-style (legacy)](writing-steps/cucumber-style-legacy.md)
- [Decorators](writing-steps/decorators.md)
- [Hooks](writing-steps/hooks.md)
- [Snippets](writing-steps/snippets.md)

* [**Reporters**](reporters/index.md)
- [Cucumber reporters](reporters/cucumber.md)
Expand Down
11 changes: 11 additions & 0 deletions docs/configuration/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,17 @@ const testDir = defineBddConfig({
});
```

## missingSteps
<div style="color: gray; font-size: 0.8em">since <b>v8</b></div>

- Type: `'fail-on-gen' | 'fail-on-run' | 'skip-scenario'`
- Default: `'fail-on-gen'`

The behavior when missing steps are found:
- `fail-on-gen` *(default)* - test files generation will fail and display code [snippets](writing-steps/snippets.md) for missing steps
- `fail-on-run` - test files will be generated, but tests run will fail
- `skip-scenario` - test files will be generated, but scenarios with missing steps will be marked as `fixme`

## verbose

- Type: `boolean`
Expand Down
42 changes: 42 additions & 0 deletions docs/writing-steps/snippets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Snippets

Snippets allow to quickly create definitions for missing steps.

Example:

Imagine you've added a new feature file:
```gherkin
Feature: Playwright site
Scenario: Check title
Given I open url "https://playwright.dev"
When I click link "Get started"
Then I see in title "Playwright"
```
And executed it without defining it's steps implementation:
```
npx bddgen && npx playwright test
```
The output shows an error and provides code snippets, that you can copy-paste to your codebase:
```
Missing step definitions: 3
Given('I open url {string}', async ({}, arg) => {
// Step: Given I open url "https://playwright.dev"
// From: features/homepage.feature:4:5
});
When('I click link {string}', async ({}, arg) => {
// Step: When I click link "Get started"
// From: features/homepage.feature:5:5
});
Then('I see in title {string}', async ({}, arg) => {
// Step: Then I see in title "Playwright"
// From: features/homepage.feature:6:5
});
Use snippets above to create missing steps.
```

> In some projects, features are written beforehand and step definitions come later. For such cases, you may need to allow generation of test files with missing steps and have them reported as failing (or fixme) scenarios. Check out [`missingSteps`](configuration/options.md#missingsteps) option to configure that behavior.

0 comments on commit cbad130

Please sign in to comment.