Skip to content

Installation (Vitest)

Terminal window
pnpm add -D vitest executable-stories-vitest executable-stories-formatters

Or with npm:

Terminal window
npm install -D vitest executable-stories-vitest executable-stories-formatters

In vitest.config.ts, import the reporter from the /reporter subpath so the config does not load the main package (which imports Vitest and can cause “Vitest failed to access its internal state” when loaded inside the config file):

import { StoryReporter } from 'executable-stories-vitest/reporter';
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
reporters: ['default', new StoryReporter()],
},
});

With no options, the reporter uses the formatters package defaults (e.g. Cucumber JSON in reports/). To write Markdown to docs/user-stories.md, pass options to StoryReporter (see Vitest reporter options — e.g. formats: ['markdown'], outputDir: 'docs', outputName: 'user-stories'). Run your tests:

Terminal window
pnpm vitest run

The Markdown file is generated after the test run.

First Story (Vitest) — write your first scenario and see the generated output.

Vitest reporter options — all configuration options.