Skip to content

Gherkin

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

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

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.

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 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

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 --feature <path-to-feature> --spec <path-to-spec> --lang <en:optional>

Example:

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

By default feature file is parsed with en language.

You can override this with --lang option :

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