Scenario Outline

A Scenario Outline should have a Examples, otherwise vitest-cucumbe will throw an error before run your unit tests.

A Scenario Outline example :

# example.feature
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

// example.spec.ts
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-requestapproves
first runfeat: add awesome featureApproves it
second runtests: add awesome feature unit testsApproves it
last runbig commitRequests changes

Currently variables is any type and each value is string.

If in your Examples you have values like 1, true, null etc. There are string also.

Validation

Before run tests vitest-cucumber check if :

  • Scenario Outline have Examples
  • Examples have at least one line for values
  • each Examples variable name is used at least one time in scenario step

Synonym

Same thing if you use Scenario Template and/or Scenarios.