# Visual regression testing for Storybook

> Add visual regression testing to Storybook with @snapvisor/storybook: one screenshot per story via the Vitest addon or Test Runner, then review on PRs.

Source: https://snapvisor.io/storybook

Guide

@snapvisor/storybook runs your stories in a real browser and captures one screenshot per story, so the story list stays in Storybook and nothing is duplicated in a visual-testing config. Snapvisor compares each screenshot with the approved baseline and posts the result on your pull request.

## Install the package

shell

```
npm install --save-dev @snapvisor/storybook
```

Create a project in the Snapvisor app and copy its project token (`ARGOS_TOKEN`) from the project settings. Store it as a CI secret, never in the repository.

## Capture with the Storybook Vitest addon

This is the recommended route. Register the plugin in your Vitest config:

vitest.config.ts

```
// vitest.config.ts
import { defineConfig } from "vitest/config";
import { argosVitestPlugin } from "@snapvisor/storybook/vitest-plugin";

export default defineConfig({
  plugins: [
    argosVitestPlugin({
      // Upload the screenshots only on CI.
      uploadToArgos: process.env.CI === "true",
    }),
  ],
});
```

A screenshot is captured for every story automatically. To capture extra screenshots at different steps of an interaction, call `argosScreenshot` from `@snapvisor/storybook/vitest` inside a story's `play` function.

If a component needs a screenshot in a second state, give that state its own story, or take an extra `argosScreenshot` in the story's `play` function.

## Or capture with the Storybook Test Runner

If you run your stories with the Storybook Test Runner instead, call `argosScreenshot` from `@snapvisor/storybook/test-runner` after each visit:

.storybook/test-runner.ts

```
// .storybook/test-runner.ts
import { argosScreenshot } from "@snapvisor/storybook/test-runner";

export default {
  async postVisit(page, context) {
    await argosScreenshot(page, context);
  },
};
```

Every story the test runner visits produces a screenshot.

## Run it in CI

Nothing wraps your test command. Run your Vitest or Test Runner step as you normally do, with `ARGOS_TOKEN` set as a CI secret in the job that runs it. On GitHub Actions you can skip the token with tokenless authentication.

A green CI job after the upload means the screenshots arrived, not that they are unchanged. The gate is the status check Snapvisor posts to the pull request, so require it in your branch protection rules.

A project can produce several builds on the same commit, such as separate Storybook and end-to-end runs. A summary check rolls them into one pass or fail status you can require before merge.

Read more: [CI integration](https://snapvisor.io/docs/ci-integration), [GitHub tokenless authentication](https://snapvisor.io/docs/learn/integrations/github-tokenless-authentication), [Summary checks](https://snapvisor.io/docs/summary-checks), [GitHub](https://snapvisor.io/docs/github), [GitLab](https://snapvisor.io/docs/gitlab).

## Review story screenshots on a pull request

For a design system, a change to a shared component shows up as a diff on every story it touches. Each pull request gets a commit status that stays pending with "N changes awaiting review" until a reviewer approves or rejects the story diffs, and the approval turns it green. The [GitHub pull request visual regression guide](https://snapvisor.io/visual-regression-testing-github) follows that path step by step.

Moving a Storybook setup off Lost Pixel? Its team announced on 2026-04-22 that they are sunsetting the product, and its GitHub repository is archived. See the [Snapvisor vs Lost Pixel comparison](https://snapvisor.io/compare/lost-pixel) for the sourced differences, and the [Lost Pixel migration guide](https://snapvisor.io/docs/migrate-from-lost-pixel) for how its shots, masks, breakpoints and thresholds map to Snapvisor.

## What the first build does

The first build on your base branch has nothing to compare against, so it becomes the baseline and is approved automatically. Run it on a base branch that already looks right. Later builds are diffed against the last approved build on the base branch, and approving a change promotes it to the new baseline for that branch.

Read more: [Baseline builds](https://snapvisor.io/docs/baseline-build), [Review workflow](https://snapvisor.io/docs/review-workflow).

## Frequently asked questions

### Do I need a screenshot call for every story?

No. With the Storybook Vitest addon a screenshot is captured for every story automatically. You only call argosScreenshot yourself to capture extra steps inside a play function.

### Should I use the Vitest addon or the Test Runner?

The Storybook Vitest addon is the recommended route. Use the Storybook Test Runner integration if that is how you already run your stories.

### How do I screenshot a story in a second state?

Give that state its own story, or take an extra argosScreenshot in the story's play function.

### Can Storybook and end-to-end screenshots be reviewed together?

They land in Snapvisor as builds on the same commit, and a summary check rolls them into one pass or fail status. The same review workflow applies to Playwright and Cypress screenshots.

### How does a design-system team review Storybook screenshots on a GitHub pull request?

Run the Storybook capture step in CI on the pull request. Snapvisor compares each story's screenshot with the approved baseline and posts a commit status on the pull request. A reviewer opens the per-story screenshot diffs, then approves or rejects them: approval turns the status green and a rejection makes it a failure. A change to a shared component shows up as a diff on every story it touches. The pull request workflow is described in the GitHub pull request visual regression guide.

### Is this a Chromatic alternative?

Chromatic pairs visual testing with a deep Storybook workflow. Snapvisor is CI-first and takes Storybook, Playwright and Cypress screenshots into one review. The sourced comparison is on the Snapvisor vs Chromatic page.

## Where to go next

[**Snapvisor vs Chromatic**Pricing, Storybook depth, browsers and AI-agent access side by side.](https://snapvisor.io/compare/chromatic) [**Self-hosted visual regression testing**Running the open-source engine on your own infrastructure.](https://snapvisor.io/self-hosted-visual-regression-testing) [**Visual regression testing in GitHub pull requests**What appears on the pull request and how a reviewer clears it.](https://snapvisor.io/visual-regression-testing-github)

## Sources

Every command, package name and option on this page comes from the Snapvisor documentation and the published `@snapvisor` packages:

- [SDKs](https://snapvisor.io/docs/sdks)
- [Migrate from Percy](https://snapvisor.io/docs/migrate-from-percy)
- [Getting started](https://snapvisor.io/docs/getting-started)
- [CI integration](https://snapvisor.io/docs/ci-integration)
- [Baseline builds](https://snapvisor.io/docs/baseline-build)
- [Summary checks](https://snapvisor.io/docs/summary-checks)
- [Review workflow](https://snapvisor.io/docs/review-workflow)

## Try Snapvisor free

[Start free](https://app.snapvisor.io/signup) [Getting started guide](https://snapvisor.io/docs/getting-started) [All SDKs](https://snapvisor.io/docs/sdks) [See pricing](https://snapvisor.io/pricing)

## Related pages

Guides [How visual regression testing works](https://snapvisor.io/visual-regression-testing) [Self-hosted visual regression testing](https://snapvisor.io/self-hosted-visual-regression-testing) [Visual regression testing in GitHub pull requests](https://snapvisor.io/visual-regression-testing-github) [Snapvisor MCP server](https://snapvisor.io/mcp)

Test runner and CI setup [Playwright visual testing setup](https://snapvisor.io/playwright) [Cypress visual testing setup](https://snapvisor.io/cypress) [Puppeteer visual testing setup](https://snapvisor.io/puppeteer) [Visual regression testing in GitLab CI](https://snapvisor.io/gitlab-ci)

Compare Snapvisor [Snapvisor vs Percy](https://snapvisor.io/compare/percy) [Snapvisor vs Chromatic](https://snapvisor.io/compare/chromatic) [Snapvisor vs Applitools](https://snapvisor.io/compare/applitools) [Snapvisor vs Argos](https://snapvisor.io/compare/argos) [Snapvisor vs Lost Pixel](https://snapvisor.io/compare/lost-pixel) [Snapvisor vs Happo](https://snapvisor.io/compare/happo) [Snapvisor vs Playwright snapshots](https://snapvisor.io/compare/playwright) [Visual regression testing pricing compared](https://snapvisor.io/visual-regression-testing-pricing) [Alternatives to other visual testing tools](https://snapvisor.io/alternatives)

Free tools [Image diff checker](https://snapvisor.io/tools/image-diff) [Screenshot calculator](https://snapvisor.io/tools/screenshot-calculator)
