Since 3.5.0
vitest-cucumber provides step expressions inspired by cucumber-expression.
Example:
In unit tests, values are passed after test context ctx
:
Built-in step expressions
{string}
Match string between quotes or double quotes
{number}
Match number with or without ,
{float}
deprecated
Removed since v4.0.0
.
Can be replaced with {number}
.
{list}
Match text and split it to array
with a separator.
Custom separator v4.0.0
You can use a custom separator like ;
: {list:";"}
.
{date}
v4.0.0
Match text according supported formats and return a Date
.
Supported formats :
MM/DD/YYYY
YYYY-MM-DD
YYYY-MM-DD
MM/DD/YYYY HH:MM:SS
{char}
v4.0.0
Match any character in step title.
{int}
v4.0.0
Match text and return number
only for integer. Use {number}
for float.
{word}
v4.0.0
Match word in step title.
{any}
v4.0.0
Match anything section in step title.
{email}
v4.0.0
Match any email.
{boolean}
v4.0.0
Match text and check if it equals true
{url}
v4.0.0
Match url and return a string
. Protocol like https:// is required.
{currency}
v4.0.0
Match currency with built-in symbols
and parsecurrency.
Custom step expressions v4.0.0
vitest-cucumber provides defineParameterExpression
to define your own expression.
Example :