storybook-vitest
Installation
SKILL.md
Storybook Vitest + Svelte CSF
Stories are .stories.svelte with defineMeta and <Story> from @storybook/addon-svelte-csf. Official reference: Vitest addon, use it for plugin, browser mode, CLI, tags, debugging, CI; ignore non-Svelte story file examples there. Manual setup · Example configuration files · Options
How it works
- Plugin
storybookTestturns stories into Vitest tests via portable stories (Vitest). No Storybook server required for the test run. - Each
<Story>: smoke render; aplayfunction runs as the interaction test (interaction testing, asserting with expect). - Console errors fail the test. MSW in
.storybook/previewapplies when configured (v2+ if you use MSW). - Test coverage: see Storybook’s coverage doc;
vitest --coverage --project …only covers projects you pass (many pipelines omitstorybookon purpose). - With the addon, snapshot tests are not supported (unlike the test runner; comparison).
.stories.svelte + play
Use storybook/test (expect, within, userEvent, waitFor) in play. Scope queries with canvasElement to within(canvasElement).