Since 3.5.0
provides step expressions inspired by cucumber-expression.
vitest-cucumber provides :
{string}
to match string between quotes or double quotes{number}
to match number with or without $
{float}
to match number with dot like 3.2{list}
to match texte with comma like “Vue, Typescript, Astro”Feature file example :
Feature: Background run before scenario tests
Scenario: scenario with expression
Given I use "Vue" 3.2
Then I can't use Vue 2
And I use typescript for $2
And I can't use React, Angular, Solid
In unit tests, values are passed after test context ctx
:
describeFeature(feature, (f) => {
f.Scenario(`scenario with expression`, (s) => {
s.Given(`I use {string} {float}`, (ctx: TaskContext, framework: string, version: number) => {
expect(framework).toEqual(`Vue`)
expect(version).toEqual(3.2)
})
s.Then(`I can't use Vue {number}`, (ctx: TaskContext, version: number) => {
expect(version).toEqual(2)
})
s.And(`I use typescript for {number}`, (ctx: TaskContext, num: number) => {
expect(num).toEqual(2)
})
s.And(`I can't use {list}`, (ctx : TaskContext, list : string[]) => {
expect(list.length).toEqual(3)
expect(list).toContain(`Angular`)
expect(list).toContain(`React`)
expect(list).toContain(`Solid`)
})
})
})