Component vs Full-Page Visual Tests

Component vs Full-Page Visual Tests

A component snapshot and a page snapshot are different assertions, not two zoom levels of one test. Where each level is blind, and how to layer them per surface.

A component snapshot and a page snapshot are not two resolutions of the same test. They catch different, only partly overlapping defect classes: the component level sees isolation regressions with stable baselines and precise attribution, the page level sees composition, cascade-in-context, and real data shape. Neither is a superset of the other, so a green component suite says nothing about whether the assembled page is intact. The working split is broad component coverage for shared primitives, narrow page coverage for load-bearing compositions, decided per surface by the defect class that surface actually risks.

Two levels, two different assertions

When a visual test captures a component in isolation, the assertion it makes is narrow and specific: this component renders correctly given these props, in a container that holds nothing else. When a visual test captures a full page, the assertion is different in kind: these components compose correctly together, under real layout constraints, with real data flowing through them and the real global cascade applied.

Those are not the same claim at two zoom levels. They are separate claims about separate failure modes. An isolated render can be pixel-perfect while the page it belongs to is broken, because the break lives in how the pieces interact. A page can look intact while a component inside it has a regression that happens not to be visible against this particular composition and this particular data.

The trap is treating either level as a superset of the other. A team that snapshots only pages assumes composition coverage implies component coverage, and misses isolation defects that this page's content happens to hide. A team that snapshots only components assumes the reverse, and ships a page where nothing is individually wrong but the assembly is. Both assumptions leave a structural blind spot that no amount of added captures at the wrong level will close.

What component-level buys

The isolated render has three properties that make it the efficient level for a large share of visual coverage.

Baselines are small and stable. An isolated component has no unrelated page around it, so its captured image contains only the component. The baseline churns when the component itself changes, not when an unrelated page does (the global styles its test harness loads and the rendering environment can still move it). A shared button's snapshot does not need regenerating because a marketing page three routes away got a new hero image.

Failure attribution is precise. A red diff on an isolated component names the component. A red diff on a page names a page where dozens of elements could have shifted, and someone has to localize the change before they can judge it. At the component level, the localization is free.

State enumeration is cheap. Variants, sizes, disabled and error states, and prop combinations are rendered directly rather than navigated to through the application. The isolated component is the natural home for exercising a component's state space, because reaching each state costs a render call rather than a user journey.

On the runner landscape (as of November 2026, re-verify against current documentation): test runners that drive a real browser now ship component-level visual testing. Vitest browser mode renders components in a real browser and added a screenshot-comparison assertion when it reached its stable fourth major version. Playwright's component testing serves the same altitude. Since Playwright 1.62 (July 2026), it runs stories on a gallery page served by the project's own dev server through the built-in mount fixture; the documentation describes this model as stable, and it replaces the earlier experimental component-testing packages. Both are named here as market reality, not ranked against each other; the choice between them is downstream of the framework and build setup a team already runs.

What only the page can see

Some regression classes are invisible at the component level by construction, because the thing that breaks is the relationship between components.

Composition defects. Margin collapse between adjacent siblings, z-index stacking that goes wrong where two components' layers meet, overflow that only manifests when a flex or grid container is constrained by its real neighbors, reflow at content widths the component's showcase never used. None of these exist in an isolated render because the isolated render has no siblings and no real container.

Cascade and theming in context. Global stylesheets, token values resolved against the real document, and specificity conflicts between a component's styles and the application's styles are fully exercised only when the component sits inside the actual page. An isolated render applies the component's own styles plus whatever global styles the test harness is set up to load, not the full cascade of the page it will sit in.

Real data shape. Production-length strings, empty lists, lists long enough to scroll, values that overflow their containers, and the null-ish states that a component's tidy fixtures rarely include. The page sees the component under the data the application actually produces.

The honest corollary follows directly: a fully green component suite certifies that each component renders correctly alone. It does not certify that the page they form is intact, and it should never be reported as if it does.

Layering the two levels

The two levels combine well when each is pointed at the defect class it can actually see.

Where the component level goes. Broad coverage across the design system and the shared primitives: buttons, inputs, cards, navigation atoms, layout wrappers. These are reused everywhere, their isolation defects multiply across the product, and their state spaces are large enough to make direct enumeration worth it.

Where the page level goes. Narrow coverage on the compositions that carry weight: the checkout flow, the dashboard shell, the marketing hero, the handful of screens where a composition break has direct cost. These are captured as whole pages precisely because the risk they carry is a composition risk.

The pattern to avoid is double-covering one defect class while still single-covering the other. A page snapshot of a screen, plus component snapshots of every element on that screen, pays twice for the isolation-level defects (once in each component capture, once inside the page capture) and still only once for composition. The extra component captures inside an already-covered page add cost without adding a new failure class.

QuestionComponent levelPage level
Baseline stabilityHigh — unaffected by changes to unrelated pagesLower — churns on any change to anything on the page
Failure attributionNames the component directlyNames a page; change must be localized first
State enumerationCheap — render props directlyExpensive — navigate to each state
Composition defectsInvisible by constructionVisible — this is its job
Cascade in contextOnly as far as the harness loads global stylesExercised against the real document
Real data shapeOnly what fixtures supplyWhatever the application produces
Diff reviewerThe component's ownerCan need whoever owns the composition

Diff-review ergonomics differ by level too. A component diff is judged by whoever owns that component. A page diff can need the person who owns the composition, because deciding whether a shifted element is intended requires knowing what the page was supposed to do.

Choosing per surface, not per ideology

The level is a per-surface decision, and the thing it follows is the defect class the surface actually risks. A surface whose realistic failure mode is an isolation defect (a shared control rendering wrong) points at the component level. A surface whose realistic failure mode is a composition defect (elements colliding, layout breaking under real content) points at the page level. Where a surface has a dominant risk, that risk names the level.

Suites drift levels over time, legitimately. A component that starts life inside one page and later gets extracted into the design system should migrate its visual coverage down with it: what was a page-level concern becomes a component-level one because the component is now shared. Coverage tracking the component's real role is correct, not churn.

The granularity decision also multiplies with the matrix decision and the state decision, each of which is its own concern. For example, twelve engine-and-viewport combinations times a component's state grid is a large number of captures whether the base unit is a component or a page. The discipline that keeps a visual suite affordable is deciding each of these axes deliberately, per surface, rather than inheriting a default and discovering the cost later.

Project Inquiry