Setup
About plugin
Since 4.1.1
vitest-cucumber provides a vitest plugin to create / update .spec.ts
file
watching .feature
file.
This plugin is optional, it doesn’t change how vitest-cucumber. It’s a new feature ;).
NB : currently this plugin doesn’t work with vitest browser mode.
Use plugin
Add plugin in your vitest.config.js
:
Now when you run vitest, vitest-cucumber will watch your .feature
file in src/features
.
By example, if your create src/features/user-auth.feature
, vitest-cucumber will create
src/__tests__/user-auth.spec.ts
file like npx @amiceli/vitest-cucumber
does.
Update spec file
When your .feature
file change, vitest-cucumber updates spec file.
By example your .feature
file
You spec file:
If you add a new step like When I click on "login" button
, vitest-cucumber
add new step in your spec file :
Features
vitest-cucumber-plugin
what your changes in .feature
file:
- add / remove
Scenario
,ScenarioOutline
,Background
fromRule
andFeature
- add / remove step(s) from
Scenario
,ScenarioOutline
andBackground
- update arrow functions arguments, by example :
- removes
And
from{ Given, When, And}
if you remove last ScenarioAnd
step - add
Backgorund
in{ Scenario }
if you add aBackground
in yourRule
/Feature
- removes
vitest-cucumber-plugin
will match steo even if you use step expression.
By example When('I click on {string} button', () => {})
match with When I click on "login" button
.
To check and update code vitest-cucumber-plugin
uses ts-moprh ❤️.
Configuration
vitest-cucumber-plugin
provides some options:
formatCommand
(optional): will run a command to format spec file after update- by example :
npx biome check --write
- plugin will pass spec file pass to your command
- by example :
onDeleteAction
(optional) : define how to handle remove code from.feature file
delete
(default value): plugin will remove code in your spec filecomment
plugin will comment code in your spec file
Example: