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' })Signature
Section titled “Signature”function hasImageSnapshot(options?: ImageSnapshotKeyOptions | undefined): Promise<boolean> | falseoptions.snapshotKey selects the snapshot of a theme or a custom key.
Outside a Vitest run
Section titled “Outside a Vitest run”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.