ContactSign inSign up
Contact

Vitest Visual Testing sneak peek

Fast, reliable visual tests, debuggable snapshots, collaborative review

loading
Kyle Gach
Last updated:

Vitest Browser Mode makes it easier to test components in a real browser. But even when your assertions pass, your UI can still be wrong.

Chromatic for Vitest adds visual testing to your browser tests, with cloud snapshots, debugging, and team review built in. The integration is built by Vitest core maintainer Ari Perkkio for a native developer experience.

  • Cover visual states in Vitest: Snapshot key UI states from Browser Mode.
  • Capture real interactions: Verify appearance after clicks, typing, and loading.
  • Run browsers in the cloud: Avoid drift with consistent, parallel infrastructure.
  • Debug what rendered: Inspect the DOM, styles, assets, and UI state.
  • Review before merge: Accept or request changes in a shared workspace.
Sign up for Early Access

Compare component to previous versions → Pinpoint UI changes

But doesn’t Vitest already have visual testing?

Yes. Vitest includes a visual regression API for taking screenshots, comparing diffs, and storing snapshots alongside your tests. For small teams that can be enough.

Chromatic is for teams that need that workflow to scale. It moves visual testing into a consistent cloud environment, parallelizes capture for speed, helps stabilize flaky results, and turns diffs into a review process your whole team can use.

How visual testing with Chromatic works

Vitest Browser Mode creates the component state. Chromatic captures what that state looks like.

When your Vitest suite runs, Chromatic uploads the test output, renders each snapshot in a standardized cloud browser, and compares it against the accepted baseline.

If a visual change appears, Chromatic reports it in your pull request so your team can inspect the diff and decide whether to accept it.

Write a Vitest browser test. Capture the UI state with Chromatic. Review visual changes in CI before merge.

Add Chromatic to your Vitest tests

Chromatic snapshots the end of each test by default. You can also capture snapshots at specific points in a test with takeSnapshot, which is useful for interactions like opening a menu or typing into an input.

// Accordion.test.ts
import { test, expect } from 'vitest';
import { page } from 'vitest/browser';
import { render } from 'vitest-browser-react';
👉 import { takeSnapshot } from '@chromatic-com/vitest';

import { Accordion } from '../src/components/Accordion';

test('can open accordion', async () => {
  await render(
    <Accordion header="Shipping details">
      Ships within 3 business days
    </Accordion>
  );
  
  👉 await takeSnapshot('closed');

  const toggle = page.getByRole('button', { name: 'Shipping details' });
  await toggle.click();
  
  const content = page.getByText('Ships within 3 business days');
  await expect.element(content).toBeInTheDocument();

  👉 await takeSnapshot('open');
});

In this example Vitest test, the assertion verifies that the accordion opens. Chromatic adds snapshots to verify how the closed and open states render. The same test catches both behavioral problems and visual regressions.

Run visual tests in a standardized cloud environment

Visual tests are sensitive to browser versions, fonts, operating systems, timing, animations, viewport differences, and asset loading.

Chromatic runs visual tests in a dedicated cloud environment optimized for UI rendering stability. Test runs are parallelized by default, so teams get the fastest possible test times without tying speed to the size of your CI runner.

When Chromatic detects potential flake from things like loading states or animations, features like SteadySnap help stabilize the result automatically.

Vitest test suite → Cloud browsers, standardized, parallel

Debug tests, not screenshots

Screenshot diffs can show that something changed, but not always why. Chromatic captures the image alongside the rendered test output: HTML, CSS, JavaScript, and assets.

When a visual test fails, you can open the captured state in a browser and inspect the rendered DOM with your own dev tools. Because that state is published to Chromatic, you can share a link with a teammate so they can debug the same output without pulling a branch or rerunning the test suite.

Visual test summary view in Chromatic

Visual tests catch mistakes from AI agents

AI agents can generate UI changes faster than teams can manually inspect them. The code compiles, the tests pass, and the behavior looks covered. But the rendered UI can still be wrong.

Visual testing helps catch the kind of UI mistakes that agents can’t see themselves.

Get early access

Sign up to early access to get hands-on setup help from our team and a chance to shape the Vitest workflow before general availability. Free usage during early access.

Sign up for Early Access

Did this article help you?

Get free UI development guides and tutorials like this emailed to you.

4,234 developers and counting

We’re hiring!

Join the team behind Storybook and Chromatic. Build tools that are used in production by 100s of thousands of developers. Remote-first.

View jobs

Popular posts

React Native visual testing sneak peek

Test on real iOS and Android simulators, fast and flake-free.
loading
Varun Vachhar

Chromatic changelog: April 2026

PR comments, automatic flake tracing, and published MCP
loading
Varun Vachhar

Published Storybook MCP servers

Give your entire organization access to a shared MCP instance to improve generated code quality. Chromatic manages publishing, auth, and versioning.
loading
Varun Vachhar
Company
AboutCareersTerms of ServicePrivacySecurity • SOC 2StatusContact Sales
Chromatic
© Chroma Software Inc. Made by the maintainers of Storybook.