vitest-cucumber
Presentation Installation Configuration Setup Gherkin Scenario Scenario Outline Background Rule Hooks Gherkin tags Async/sequential steps Step expression DocStrings DataTables Spoken languages

Presentation

About vitest-cucumber

vitest-cucumber is an opiniated tool to write acceptance tests following the Gherkin syntax, designed to be used specifically with Vitest.

This package was originally inspirated by jest-cucumber.

Example

A Gherkin Feature is written in a .feature file. Example:

# example.feature
Feature: use vitest-cucumber with vitest
    Scenario: Run unit tests
        Given I have installed vitest-cucumber
        And   I have a feature like "example.feature"
        When  I run vitest-cucumber
        Then  My feature file is parsed
        And   I can test my scenarios

You can then use it with vitest-cucumber:

// example-feature.spec.ts
import { loadFeature, describeFeature } from '@amiceli/vitest-cucumber'

const feature = await loadFeature('./example.feature')

describeFeature(feature, ({ Scenario }) => {
    Scenario('Run unit tests', ({ Given, When, Then, And }) => {
        Given('I have installed vitest-cucumber', () => {})
        And('I have a feature like "example.feature"', () => {})
        When('I run vitest-cucumber', () => {})
        Then('My feature file is parsed', () => {})
        And('I can test my scenarios', () => {})
    })
})

Playground

Do not take the word for it, try it out yourself in the following playground.

Next steps

If you are interested, you can install it here.