Storybook Quickstart
Prerequisites
1
2
Add Argos plugin to your Vitest configuration
import path from "node:path";
import { fileURLToPath } from "node:url";
import { defineConfig } from "vitest/config";
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,
// Set your Argos token (required if not using GitHub Actions).
token: "<YOUR-ARGOS-TOKEN>",
}),
],
test: {
name: "storybook",
browser: {
enabled: true,
headless: true,
provider: "playwright",
instances: [{ browser: "chromium" }],
},
setupFiles: [".storybook/vitest.setup.ts"],
},
},
],
},
});3
Capture screenshots
import { argosScreenshot } from "@argos-ci/storybook/vitest";
export const Example: Story = {
play: async (ctx) => {
// It captures a screenshot of the current story and uploads it to Argos
// See options at: https://argos-ci.com/docs/storybook
await argosScreenshot(ctx, "example-screenshot");
},
};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 --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 }}Congratulations on installing Argos! 👏
Additional resources
Last updated
Was this helpful?