Skip to content

hasImageSnapshot

hasImageSnapshot() returns a promise of true when the snapshot image exists. Use it in a story loaders function, as shown in Manual snapshots.

import { hasImageSnapshot } from 'storybook-addon-vis'
const exists = await hasImageSnapshot({ snapshotKey: 'dark' })
function hasImageSnapshot(options?: ImageSnapshotKeyOptions | undefined): Promise<boolean> | false

options.snapshotKey selects the snapshot of a theme or a custom key.

It looks up the current Vitest test. Without one, such as in a plain Storybook preview, it returns false because the preview cannot read snapshot files.

The matching plugin function is page.hasImageSnapshot.