Skip to content

Installation

To install vitest-cucumber:

npm install @amiceli/vitest-cucumber --save-dev

It is that simple, you don’t need to create a configuration file or to update the Vitest config.

Underneath, vitest-cucumber uses Vitest functions like describe, test, etc.

Now you can run Vitest the way you want, see:

vitest --run --coverage

Since 8.0.0, vitest-cucumber requires Vitest to be >=5.0.0.

For older versions, since 3.4.4, vitest-cucumber requires Vitest to be >=2.0.0.

Vitest 5 sets clearMocks to true by default, which clears mocks between each step of a scenario.

If your steps share a mock, set clearMocks to false in your Vitest config :

import { defineConfig } from 'vitest/config'

export default defineConfig({
    test: {
        clearMocks: false,
    },
})