visAnnotations
visAnnotations is an object of Storybook project annotations.
Merge it into setProjectAnnotations() in vitest.setup.ts, or spread it into .storybook/preview.ts.
See Configuration for both ways.
import { setProjectAnnotations } from '@storybook/your-framework'import { vis, visAnnotations } from 'storybook-addon-vis/vitest-setup'import * as projectAnnotations from './.storybook/preview.ts'
setProjectAnnotations([projectAnnotations, visAnnotations])vis.setup()What it does
Section titled “What it does”It has one beforeEach hook.
In a Vitest browser run the hook:
- adds the
toMatchImageSnapshotmatcher toexpectonce, - calls
setAutoSnapshotOptionswithenable, from the story tags (seeisSnapshotEnabled),- the story’s
parameters.snapshot(seedefineAutoSnapshotParam), - the
tagsof the story, - and
meta.visof the running Vitest test.
Outside a Vitest browser run, such as in the Storybook UI, the hook does nothing.
Import paths
Section titled “Import paths”storybook-addon-vis/vitest-setup and storybook-addon-vis.
The vitest-setup entry also exports vis and setAutoSnapshotOptions.