October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

How to Test Storybook Stories in Different Modes

Storybook stories can power render, interaction, accessibility, visual, and integration tests. Learn what each mode proves and how to choose a compatible runner.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use different Storybook test modes to answer different questions: render tests check that a story mounts; interaction tests check how it responds to user actions; accessibility tests flag some automated-rule violations; visual tests compare rendered appearance; and markup snapshot tests compare HTML. Stories can also be reused in unit and end-to-end tests. Choose a mix based on what could break—not one test type as proof that everything works.

What each Storybook test mode tells you

Mode What it checks Useful when
Render or component test Whether the story mounts with its configured state and fixtures. You want to catch basic rendering failures across representative component states.
Interaction test Whether a user action produces an expected, observable result. A component has important behavior such as submitting, toggling, or saving.
Accessibility check Whether automated rules flag issues in the rendered DOM. You want an automated accessibility signal alongside manual review.
Visual test Whether a rendered story differs from an accepted visual baseline. Appearance changes matter and reviewers can inspect diffs.
Markup snapshot Whether rendered markup differs from a stored snapshot. A markup change itself is useful to notice, though other test types often provide more coverage with less effort.
Unit or end-to-end test using stories Whether a story fixture works in a traditional unit-test environment or a larger application workflow. You need to test beyond the isolated component, such as behavior involving the running application stack.

A passing render test does not establish that interactions work or that a component integrates correctly into the application. Likewise, a visual match does not prove behavior, and a passing automated accessibility scan is not a certification of accessibility.

As an Amazon Associate I earn from qualifying purchases.

How to write an interaction test in a story

A story describes the initial state; its play function can query the rendered UI, perform a user action, and assert on the result. The following is the shape of a test, not a drop-in file for every Storybook version or framework: use the test and user-event imports supported by your installed Storybook setup.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
export const CanSave = {
  play: async ({ canvas, userEvent, args }) => {
    await userEvent.click(canvas.getByRole('button', { name: /save/i }));
    await expect(args.onSave).toHaveBeenCalled();
  },
};

In a real story, provide the button and the mocked onSave argument in the story’s component configuration. Querying by accessible role and name tests the control the way a user encounters it; asserting the mock was called checks an observable outcome. Adapt the imports and story syntax to your project rather than assuming this snippet works unchanged in every framework.

#1 Best Overall
Sale
Clifford's Good Deeds (Classic Storybook)
  • Another classic tale of Clifford
  • Paperback
  • 32 pages

Run and debug the steps

When the selected Storybook integration supports it, open the story’s Interactions panel to inspect the play-function steps. Pause, resume, rewind, and inspect the point of failure. Depending on the runner and configuration, tests may also run from an editor, terminal, or CI. Interaction tests can be expensive to maintain if applied indiscriminately, so prioritize important behavior and combine them with other checks.

Choose a runner by compatibility and test needs

Storybook’s current documentation describes two distinct routes: the Vitest addon and Storybook Test Runner. Their framework compatibility, required test types, execution environment, and support status differ. Check the compatibility guidance for your installed Storybook version and framework before changing configuration; these product details are version-sensitive.

Rank #2
Teacher Record Book
  • Keep track of everything from attendance to test scores
  • Spiral bound
  • Measures 8-1/2" x 11"
Consideration Vitest addon Storybook Test Runner
Underlying runner Vitest; transforms stories into tests and runs them in browser mode. Jest-orchestrated.
Project requirements Designed for Vite-based Storybook frameworks, with a documented Next.js framework route. Does not require a running Storybook instance. Works across frameworks, but requires a running or published Storybook.
Documented test coverage Interaction, accessibility, and visual tests; not markup snapshot tests. Interaction, accessibility, and markup snapshot tests; not visual tests.
Where it fits into the workflow Storybook UI and editor integrations. CLI-oriented execution.
Support status Storybook’s current guidance recommends checking addon compatibility for Vite-based projects. The official listing says official support has ended.

For a Vite-based project, first check whether the Vitest addon supports your exact Storybook and framework versions. Do not assume it applies to a non-Vite setup. The Test Runner remains documented, but its ended official-support status is an important maintenance consideration for a new workflow. If neither route fits, assess the supported options for your project rather than choosing a runner by habit.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Confirm the framework, bundler, and Storybook version are compatible.
  • List the test modes you need: interaction, accessibility, visual, or markup snapshot.
  • Decide where tests must run and be debugged: Storybook UI, editor, CLI, or CI.
  • Check whether CI can provide a running or published Storybook if the chosen runner requires one.
  • Factor current maintenance and support status into the decision.

What accessibility checks can—and cannot—tell you

Storybook’s Accessibility addon uses axe-core to assess rendered DOM against automated heuristics based on WCAG rules and related practices. Storybook’s documentation, accessed in 2026, says axe-core automatically catches “up to 57% of WCAG issues.” That is a vendor-documented ceiling for automated detection, not an independent validation, a guarantee for your component, or a claim that a clean scan establishes compliance.

Review reported violations and fix confirmed problems. Investigate results marked “incomplete” manually because the automation could not decide them. Some accessibility questions require human judgment or checks that cannot be settled from the rendered markup alone.

Make CI behavior explicit

Accessibility findings do not necessarily fail a build by default. In the documented configuration, parameters.a11y.test set to error makes violations CI errors; other settings affect how results are presented. Check the value actually configured in your project and decide deliberately whether violations should fail the pipeline.

Visual snapshots and markup snapshots are different

A visual test compares a rendered story with a known-good image baseline, helping catch changes in appearance. Review diffs before accepting a new baseline: updating it without checking can normalize an unintended regression. Storybook identifies Chromatic as a cloud option for cross-browser visual testing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A markup snapshot instead compares rendered markup with a stored baseline. It may help surface markup changes associated with rendering errors or warnings, but a changed HTML snapshot is not the same evidence as a changed browser-rendered image. Storybook notes that other testing approaches often provide more coverage with less effort, so use markup snapshots selectively.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Reuse stories in unit and end-to-end tests

Stories can serve as reusable component-state fixtures outside Storybook. Import them into traditional unit-test environments such as Vitest or Jest where appropriate. For tests of broader workflows involving the application stack, Storybook documents using stories within Playwright or Cypress end-to-end tests. These tests complement focused component checks when the behavior depends on integration beyond an isolated component.

A practical layered workflow

  1. Cover representative states with render checks. This establishes that important story configurations mount; it does not assert behavior.
  2. Add play-function tests for consequential interactions. Assert observable outcomes for behaviors users rely on instead of writing interaction tests for every trivial state.
  3. Run accessibility checks and review incomplete results. Configure CI failure behavior intentionally and retain manual review.
  4. Use visual comparisons for appearance-sensitive components. Inspect diffs before changing the accepted baseline.
  5. Test integration at the right scope. Reuse stories in unit or end-to-end tests when the question extends beyond isolated rendering.

Capture a Storybook page as a supplementary visual artifact

A screenshot of a deployed Storybook story can be useful as an artifact or an input to a separate visual-review workflow. It is not a substitute for assertions, a visual-diff system, or a test runner. For browser-based visual tests, keep the assertions and baseline comparison in the testing workflow you selected.

Or skip the browser setup:

For a deployed story URL, ScreenshotNeo can return a screenshot in one GET request. Use a publicly reachable Storybook URL in place of the example URL below; a local development server is not a public URL.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://storybook.js.org/ -o shot.webp

See the ScreenshotNeo API documentation for request options. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The Free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000. ScreenshotNeo is a capture service, not a Storybook test runner. Sign up for 1,000 free screenshots a month, with no card.

Frequently Asked Questions

Do I need a separate test for every story?

No. Select representative states and behaviors based on the risks they cover; exhaustive interaction tests can add maintenance without proportionate value.

Does a clean automated accessibility scan mean a component is accessible?

No. Automated checks catch only some issues. Review incomplete results and use manual accessibility evaluation as part of the process.

Quick Recap

SaleBestseller No. 1
Clifford's Good Deeds (Classic Storybook)
Clifford's Good Deeds (Classic Storybook)
Another classic tale of Clifford; Paperback; 32 pages
$4.40
Bestseller No. 2
Teacher Record Book
Teacher Record Book
Keep track of everything from attendance to test scores; Spiral bound; Measures 8-1/2" x 11"
$4.89
SaleBestseller No. 3
SaleBestseller No. 5

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.