Skip to content

Gherkin

Gherkin validation

vitest-cucumber uses its own feature file parser and validate it before running unit tests.

And check ths tests for all scenario, steps, etc.

Before unit tests run

When you call loadFeature, vitest-cucumber parses and validates your feature file. It implements gherkin keywords:

  • Scenario
  • Scenario Outline
  • Feature
  • Examples
  • Rule
  • Steps : Given, When, Then, And, But

Since 3.3.2 version you can use Example, Scenarios and Scenario Template synonyms.

Validation

When vitest-cucumber parses your feature file, it checks that:

  • You have an Examples in your Scenario Outline
  • You use Examples variables in your Scenario Outline steps

After unit tests run

Validation

After all unit tests vitest-cucumber, it checks:

  • non tested Scenario and/or Scenario Outline
  • non tested Scenario and/or Scenario Outline steps
  • non tested Feature
  • non tested Rule

Generate spec file from feature file

If you want to save time, vitest-cucumber is able to generate a spec file automatically via the CLI.

You can use it like this:

Terminal window
npx @amiceli/vitest-cucumber <path-to-feature> <path-to-spec>

Example:

Terminal window
npx @amiceli/vitest-cucumber features/example.feature src/__tests__/example.spec.ts