Storybook Quickstart
Set up Argos with Storybook and Vitest to get visual testing and live deployment URLs on every pull request.
Prerequisites
1
Install
npm i --save-dev @argos-ci/storybookyarn add --dev @argos-ci/storybookpnpm add --save-dev @argos-ci/storybookbun add --dev @argos-ci/storybooknpm i --save-dev vitest @vitest/browser @vitest/browser-playwright playwrightyarn add --dev vitest @vitest/browser @vitest/browser-playwright playwrightpnpm add --save-dev vitest @vitest/browser @vitest/browser-playwright playwrightbun add --dev vitest @vitest/browser @vitest/browser-playwright playwright2
Add the Argos plugin to your Vitest config
import path from "node:path";
import { fileURLToPath } from "node:url";
import { defineConfig } from "vitest/config";
import { playwright } from "@vitest/browser-playwright";
import { storybookTest } from "@storybook/addon-vitest/vitest-plugin";
import { argosVitestPlugin } from "@argos-ci/storybook/vitest-plugin";
const dirname =
typeof __dirname !== "undefined"
? __dirname
: path.dirname(fileURLToPath(import.meta.url));
// More info at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon
export default defineConfig({
test: {
projects: [
{
extends: true,
plugins: [
// The plugin will run tests for the stories defined in your Storybook config
// See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest
storybookTest({ configDir: path.join(dirname, ".storybook") }),
// The plugin will capture screenshots of your stories and upload them to Argos.
// See options at: https://argos-ci.com/docs/storybook
argosVitestPlugin({
// Upload to Argos on CI only.
uploadToArgos: !!process.env.CI,
}),
],
test: {
name: "storybook",
browser: {
enabled: true,
headless: true,
provider: playwright({
// Stabilize text rendering so screenshots match across macOS and CI.
launchOptions: {
args: ["--disable-lcd-text", "--font-render-hinting=none"],
},
}),
instances: [{ browser: "chromium" }],
},
setupFiles: [".storybook/vitest.setup.ts"],
},
},
],
},
});3
4
Set up CI
name: Argos
on:
pull_request:
push:
branches:
- main
jobs:
argos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
- run: npm ci
# Run visual tests
- run: npx playwright install --with-deps chromium
- run: npx vitest run --project=storybook
env:
ARGOS_TOKEN: ${{ secrets.ARGOS_TOKEN }}
# Build and deploy the Storybook
- run: npm run build-storybook
- run: npx --no-install argos deploy ./storybook-static
env:
ARGOS_TOKEN: ${{ secrets.ARGOS_TOKEN }}You're all set
Next steps
Last updated
Was this helpful?