storybook-visual-testing

Make Storybook stories deterministic for UI Verify visual regression captures.

21|1|Updated Jul 22, 2026
One-click install
npx skills add https://github.com/uiverify/uiverify --skill storybook-visual-testing-uiverify
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: storybook-visual-testing
Source: https://github.com/uiverify/uiverify/tree/main/packages/skills/skills/storybook-visual-testing
Command: npx skills add https://github.com/uiverify/uiverify --skill storybook-visual-testing-uiverify

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Storybook stories that read the clock, fetch live data, or run infinite JS animations produce flaky visual diffs in UI Verify, flagging every run as "changed" without any real code change. This Skill identifies exactly which sources of run-to-run variation remain after the capturer's built-in neutralizations and shows how to eliminate each one. ## Core Features & Use Cases - Freeze dynamic data: Replace live fetches with static args/fixtures or MSW mocks so star counts, contributor lists, and timestamps stop churning between runs. - Freeze the clock: Pin Date per story with storybook-addon-mock-date or @sinonjs/fake-timers so relative timestamps and date pickers stop drifting. - Tame infinite animations: Honor prefers-reduced-motion (via framer-motion's MotionConfig) or branch on the window.__UI_VERIFY__ capture marker to render a settled end frame. - Use Case: A chart story diffs on every PR because its day axis reads the current date. Add mockingDate in .storybook/preview.ts and the story renders identically on every capture. ## Quick Start Review my Storybook stories and make them deterministic for UI Verify visual testing so they stop producing flaky diffs.

Frequently Asked Questions about storybook-visual-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I stop Storybook visual tests from flaking?▼

Give every story static args or fixtures instead of live data, freeze the clock with storybook-addon-mock-date, and make infinite JS animations honor prefers-reduced-motion. UI Verify already seeds Math.random, kills CSS animations, and waits for fonts, so only app-internal variation needs fixing.

How do I mock the date in Storybook stories?▼

Use storybook-addon-mock-date on Storybook 10+ and set parameters.mockingDate in .storybook/preview.ts, overridable per meta or story. On older Storybook, install @sinonjs/fake-timers in a decorator with install({ now: FROZEN_NOW }) to cover Date, Date.now, and timers.

Does UI Verify handle CSS animations and Math.random automatically?▼

Yes. The capturer kills CSS animations and transitions, disables the Web Animations API, emulates prefers-reduced-motion, seeds Math.random, and waits for fonts and images. You only need to fix the clock, infinite JS loops, live data, and non-Math.random randomness.

How do I detect a UI Verify capture inside a component?▼

Check navigator.userAgent for the UIVerify marker or test for the window.__UI_VERIFY__ global. Use that branch to render a settled end frame, for example disabling a chart animation or drawing one static canvas frame instead of starting a requestAnimationFrame loop.

Why does my Storybook story diff on every run with no code change?▼

The usual cause is live or dynamic data: star counts, timestamps, or reordered lists that change between captures. Replace them with fixed args or MSW-mocked responses, and pin any clock reads, since static data cannot churn run-to-run.

Should I stub scroll behavior or third-party scripts for Storybook visual tests?▼

No. Stories are isolated components with no page scroll, analytics, or consent scripts, so those concerns do not apply. Scroll-settling and third-party stubbing are real-page capture problems covered by the playwright-visual-testing skill, not story-level testing.