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.
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', () => {})
})
})
Do not take the word for it, try it out yourself in the following playground.
If you are interested, you can install it here.