Scenario Outline
A Scenario Outline should always have an Examples block, otherwise vitest-cucumber
will throw an error before running unit tests.
A Scenario Outline example:
Feature: Use ScenarioOutline with vitest-cucumber Scenario Outline: A tale of two developers Given two developers, John and Jane And on a common codebase When John makes a pull request <pull-request> And Jane reviews it Then Jane <approves> it
Examples: | pull-request | approves | | feat: add awesome feature | Approves it | | tests: add awesome feature unit tests | Approves it | | big commit | Requests changes |Run Scenario Outline tests
Section titled “Run Scenario Outline tests”describeFeature(featureCampagneFilter, ({ ScenarioOutline }) => { ScenarioOutline(`A tale of two developers`, ({ Given, When, Then, And }, variables) => { Given(`two developers, John and Jane`, () => { // variables['pull-request'] }) And(`on a common codebase`, () => { // variables['approves'] }) When(`John makes a pull request <pull-request>`, () => { }) And(`Jane reviews it`, () => { }) Then(`Jane <approves> it`, () => { }) })})When you run your tests, ScenarioOutline is runned X times.
In this example, we have 3 value lines in Examples.
So it will be runned 3 times and variables contains each values:
| pull-request | approves | |
|---|---|---|
| first run | feat: add awesome feature | Approves it |
| second run | tests: add awesome feature unit tests | Approves it |
| last run | big commit | Requests changes |
Currently variables is of type any and each value is of type string.
If in your Examples you have values like 1, true, null, etc.
They will always be interpreted as string.
Validation
Section titled “Validation”Before running tests, vitest-cucumber checks if:
Scenario Outlinehave anExamplesblockExampleshave at least one line for values- each
Examplesvariable name is used at least one time in a scenario step
Synonym
Section titled “Synonym”Same thing if you use Scenario Template and/or Scenarios.