No description
  • TypeScript 93.7%
  • JavaScript 4.6%
  • MDX 0.9%
  • Svelte 0.7%
Find a file
Steve Juma b6d82689d3
Some checks failed
Publish Storybook to GitHub Pages / Build static Storybook (push) Has been cancelled
Publish Storybook to GitHub Pages / Deploy static Storybook (push) Has been cancelled
Version and tag release / Update Version Packages pull request (push) Has been cancelled
Version and tag release / Create release tag (push) Has been cancelled
Visual Delta CI / Package typecheck and unit tests (push) Has been cancelled
Visual Delta CI / Panel browser acceptance (push) Has been cancelled
Visual Delta CI / Chromium, Firefox, and WebKit acceptance (push) Has been cancelled
Visual Delta CI / Manager browser acceptance (push) Has been cancelled
Document link-only sibling resolution in Visual Delta
2026-08-15 20:29:09 +01:00
.changeset Adopt configurable shared spec validation 2026-08-15 20:26:39 +01:00
.github Adopt configurable shared spec validation 2026-08-15 20:26:39 +01:00
.storybook Eliminate remaining canonical run slow paths 2026-08-03 19:26:13 +01:00
.visual-delta/artifacts/examples/interactions Regenerate visual baselines at the default tolerance 2026-08-03 12:22:31 +01:00
docker/visual-delta-ci Stabilize native image smoke tooling 2026-08-01 19:30:42 +01:00
scripts Adopt configurable shared spec validation 2026-08-15 20:26:39 +01:00
spec Document link-only sibling resolution in Visual Delta 2026-08-15 20:29:09 +01:00
src Keep live baseline progress through reconciliation 2026-08-05 23:38:47 +01:00
tests Keep live baseline progress through reconciliation 2026-08-05 23:38:47 +01:00
.dockerignore Add manually published Visual Delta CI image 2026-08-01 19:13:28 +01:00
.gitignore Unify Visual Delta artifacts and canonical actual reuse 2026-08-03 03:16:14 +01:00
.markdownlint-cli2.jsonc Consolidate Visual Delta documentation into canonical spec 2026-08-01 12:06:54 +01:00
AGENTS.md Document link-only sibling resolution in Visual Delta 2026-08-15 20:29:09 +01:00
CHANGELOG.md Add Changesets versioning with tag-driven npm publish. 2026-08-15 20:26:38 +01:00
DEVELOPMENT.md Add Changesets versioning with tag-driven npm publish. 2026-08-15 20:26:38 +01:00
LICENSE Add environment-aware visual filters 2026-08-01 19:13:28 +01:00
package.json Adopt configurable shared spec validation 2026-08-15 20:26:39 +01:00
playwright.browsers.config.ts Add canonical ARM64 visual capture profile 2026-08-01 19:13:29 +01:00
playwright.config.ts Stage external snapshot inputs for Diff Browser 2026-08-03 08:12:30 +01:00
playwright.manager.config.ts Make manager acceptance green and gate it in package CI. 2026-08-01 12:07:05 +01:00
playwright.panel.config.ts Regenerate visual baselines at the default tolerance 2026-08-03 12:22:31 +01:00
pnpm-lock.yaml Adopt configurable shared spec validation 2026-08-15 20:26:39 +01:00
pnpm-workspace.yaml Adopt configurable shared spec validation 2026-08-15 20:26:39 +01:00
README.md Add Changesets versioning with tag-driven npm publish. 2026-08-15 20:26:38 +01:00
spec-validator.config.mjs Exclude Visual Delta gap identifiers 2026-08-15 20:26:39 +01:00
svelte.config.js Give Visual Delta its own React Storybook and move self-test CSF. 2026-08-01 12:06:58 +01:00
tsconfig.base.json Stand up standalone Visual Delta package repo after history extract. 2026-08-01 12:07:04 +01:00
tsconfig.json Stand up standalone Visual Delta package repo after history extract. 2026-08-01 12:07:04 +01:00
tsconfig.node-build.json Stand up standalone Visual Delta package repo after history extract. 2026-08-01 12:07:04 +01:00
vitest.config.ts Stand up standalone Visual Delta package repo after history extract. 2026-08-01 12:07:04 +01:00

Visual Delta for Storybook

npm release and provenance npm version Storybook

Visual Delta is a local-first visual regression testing addon for Storybook. It compares stories with committed Playwright screenshots and adds baseline review, overlays, diffs, and visual test controls to Storybook.

Public npm releases use Changesets and exact vX.Y.Z tags; see npm release administration.

Requirements

  • A Storybook project using Vite
  • React, which renders the addon panel
  • Playwright for browser capture
  • Docker for the default authoritative Linux ARM64 capture runner

Visual Delta supports Chromium, Firefox, and WebKit. New projects enable Chromium only.

Install

From your Storybook project, install and register the addon:

npx storybook add @lapismd/storybook-addon-visual-delta
pnpm add -D playwright react
pnpm exec playwright install chromium
pnpm exec visual-delta init

visual-delta init creates the Playwright suite, Playwright configuration, snapshot directory, and package scripts. It preserves existing files unless you pass --force.

The generated files are:

playwright.config.ts
tests/visual/storybook.spec.ts
tests/visual/storybook.spec.ts-snapshots/

It also adds build-storybook, test:visual, test:visual:affected, and visual-delta scripts when they do not already exist.

Check an installation

Run the fast, read-only doctor after setup or an upgrade:

pnpm exec visual-delta doctor

It validates Storybook registration, the portable Playwright suite, package dependencies and scripts, resolved capture settings, snapshot ownership, and Visual Delta artifact/cache placement. The default check does not build Storybook, start Docker, launch a browser, or write files.

Use the opt-in checks and repairs when needed:

pnpm exec visual-delta doctor --runner
pnpm exec visual-delta doctor --build
pnpm exec visual-delta doctor --strict --json
pnpm exec visual-delta doctor --fix

--runner performs the existing Docker or custom-runner probe. --build refreshes static Storybook before authoritative orphan analysis. --fix only moves verified v4 actual/diff/result evidence into .visual-delta/artifacts/, quarantines obsolete derived files under .visual-delta/cache/doctor-quarantine/, and migrates the legacy change-set cache. It never modifies committed baseline PNGs, story sources, or project configuration, and it never overwrites a destination.

Register the addon manually

If the Storybook CLI did not update your configuration, add the package to the existing addons array in .storybook/main.ts:

export default {
  addons: ["@lapismd/storybook-addon-visual-delta"],
};

If you do not want to use visual-delta init, create the suite and Playwright configuration yourself.

// tests/visual/storybook.spec.ts
import {
  defineVisualSuite,
} from "@lapismd/storybook-addon-visual-delta/playwright";

defineVisualSuite();
// playwright.config.ts
import {
  defineVisualPlaywrightConfig,
} from "@lapismd/storybook-addon-visual-delta/playwright";

export default defineVisualPlaywrightConfig();

Create a baseline

Start Storybook and open a story:

pnpm storybook

Open the Visual Delta panel, select the browser, and choose Create visual. Review the captured PNG before committing it to your repository.

The default snapshot directory is tests/visual/storybook.spec.ts-snapshots. Baseline names contain the story and browser, for example components-button--primary-chromium.png.

Run visual tests

Check the full capture environment before the first authoritative run (the legacy runner-only spelling remains supported):

pnpm exec visual-delta doctor --runner

Run every eligible story:

pnpm test:visual

Run only stories affected by local changes:

pnpm test:visual:affected

Missing baselines and visual mismatches are warnings by default. Use strict mode when they should fail CI:

pnpm exec visual-delta test --all --failure-mode strict

Compare one exact story with the same runner-backed suite used by Diff Browser:

pnpm exec visual-delta test --story-id examples-card--default --browser chromium

Compare-only commands never create or update baselines. They write mirrored .actual.png, .diff.png, and .result.json evidence to .visual-delta/artifacts/; affected planning state lives in .visual-delta/cache/, including UI change-set history at .visual-delta/cache/change-sets/ and verified canonical Storybook builds at .visual-delta/cache/canonical-build/. Both roots are ignored by default, but projects may cache or commit them. Add --fresh to bypass a reusable actual once while retaining the canonical build cache; add --rebuild to force a new canonical Storybook build. Affected selection is enabled conservatively when the addon option is omitted; set affectedTests: false to opt out.

Configure browsers and comparison defaults

Add .visual-delta/config.json when the built-in defaults are not suitable:

{
  "browsers": ["chromium", "firefox", "webkit"],
  "captureWorkspaceIgnore": [".nx/cache"],
  "workflow": {
    "visualTestFailureMode": "strict",
    "reuseActualComparisons": true
  }
}

Install local browser binaries only when developing the host-local diagnostic capture path or invoking Playwright directly:

pnpm exec playwright install chromium firefox webkit

captureWorkspaceIgnore accepts root-relative derived-cache directories that the clean runner should omit. The runner already excludes common caches such as .turbo; use this setting for tool-specific caches without waiting for another package release.

The built-in comparison allows up to 0.063% differing pixels and uses a 0.063 per-pixel color threshold. Project and story settings can override these values.

The default runner executes authoritative comparisons in the pinned Linux ARM64 capture profile. Diff Browser, the Testing Module, and command-line tests all invoke the same packaged Playwright worker through that runner. Projects that cannot use Docker can provide .visual-delta/runner.mjs to transport the same capture job through another environment.

Further documentation

License

MIT

jj b s -r @- main && jj tag set --allow-move v0.0.4 -r main && jj git push -b main && git push -f origin v0.0.4