Skip to content

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.

vitest.setup.ts
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()

It has one beforeEach hook. In a Vitest browser run the hook:

  1. adds the toMatchImageSnapshot matcher to expect once,
  2. calls setAutoSnapshotOptions with

Outside a Vitest browser run, such as in the Storybook UI, the hook does nothing.

storybook-addon-vis/vitest-setup and storybook-addon-vis. The vitest-setup entry also exports vis and setAutoSnapshotOptions.