# Storybook

Run visual tests on your Storybook in Buddy - upload the built Storybook, compare stories against approved baselines, and get a hosted Storybook for every version.

Storybook is the fastest way to get visual test coverage of your components - no plugin and no test code required. You point Buddy at your built Storybook, and each session captures screenshots of your components and stories, then compares them with the previously approved version.

On top of the visual review you also get a **hosted Storybook for every tested version**, protected by Buddy authorization - handy for sharing a specific build with designers or reviewers without deploying anything.

## Prerequisites

- [`bdy` CLI installed](/docs/cli/getting-started.md) (requires Node.js v20+)
- Suite token exported as `BUDDY_VT_TOKEN` - copy it from the [suite settings](/docs/tests/visual-tests/suite-settings.md) (in Buddy pipelines the token is set automatically)

## Upload your Storybook

Build the Storybook and upload the static output from the build directory:

```bash
npm run build-storybook
cd storybook-static && bdy tests visual upload
```

Every upload creates a new session. Stories are rendered across all browsers, systems, and device resolutions enabled in the [suite settings](/docs/tests/visual-tests/suite-settings.md), and compared against the approved baseline. See the [`bdy tests visual upload` reference](/docs/cli/tests/visual/upload.md) for details.

<Hint type="info">
You can link a directory to a suite once with [`bdy tests visual link`](/docs/cli/tests/visual/link.md) (interactively, or non-interactively with `-w workspace -p project -s suite-id`) so subsequent uploads don't need any extra configuration.
</Hint>

## Storybook in a Buddy pipeline

The dedicated **Storybook** action covers the whole flow - select the suite in the **Visual Test Suite ID** field and keep the default commands:

![Storybook action with a visual test suite selected](/docs/tests/visual-tests/storybook-action.png 640x381)

```bash
npm install
npm run build-storybook
cd storybook-static && bdy tests visual upload
```

The suite token is provided to the action automatically. See [Running Visual Tests → Buddy Pipelines](/docs/tests/visual-tests/running-visual-tests/buddy-pipelines.md) for complete pipeline examples, including the approval gate.


---
Original source: https://buddy.works/docs/tests/visual-tests/storybook