A Single Page Application does not reload the page on every click: it rewrites the interface continuously, and every navigation, every transition and every piece of data loaded asynchronously produces a new visual state. A multi-page site displayed one state per page; an SPA packs dozens into a single document. Any of them can render wrongly, and your functional tests do not look at what the user sees. This article details why SPAs multiply the states to verify, which visual pitfalls client-side routing and state management bring, and how to structure a visual regression test that covers these states without writing code.
Key takeaways
- An SPA mechanically generates more visual states than a traditional multi-page site, and every state can contain a regression
- Client-side navigation, animated transitions and conditional rendering create visual combinations that functional tests do not cover
- Automated visual testing is the only realistic approach to capture and verify every state of an SPA
- Ignoring visual testing in an SPA means accepting that most of your interface states will never be verified
A Single Page Application is a web application that interacts with the user by dynamically rewriting the current page rather than loading entire new pages from the server, which results in a smoother user experience, close to a native application.
This technical definition is elegant. The QA reality that follows from it is much less so.
Because by dynamically rewriting the page rather than loading new pages, an SPA packs into a single HTML document a number of visual states that far exceeds what a traditional site can produce. And every state is a place where something can display incorrectly.
The essentials on one page: what a no-code tool really automates and how it compares: No-code test automation.
Multi-page sites had an advantage nobody acknowledged
Before the SPA era, each URL corresponded to a distinct page, loaded entirely from the server. It was slow, sometimes jerky, but it had a considerable advantage from a QA point of view: each page was a discrete, stable state. You could capture it, verify it, and move on to the next one.
A twenty-page site had twenty main states. You could literally list them on a board and tick them off one by one. It was manageable.
SPAs broke this simplicity. A React, Vue or Angular application of medium complexity cannot be reduced to its routes. Each route can display dozens of different states depending on the data loaded, interactions, permissions, error conditions and loading states.
Take a dashboard page. It can show an initial loading state with skeletons. Then the state with data. Then the empty data state (first launch). Then the network error state. Then the state with an active filter. Then the state with a modal open. Then the state with a tooltip visible. Each state has a distinct visual appearance that your users will see.
Multiply by the number of routes, and you understand why manually testing an SPA is an illusion.
Visual challenges specific to SPAs
Navigation without reloading
In a traditional site, navigation triggers a full reload. The browser destroys the existing DOM, loads the new HTML, applies the CSS, runs the JS. Each page starts from a clean state.
In an SPA, navigation modifies the existing DOM without reloading. Components are mounted and unmounted. Global state persists between views. Side effects accumulate.
This creates a subtle but real problem: the appearance of a view can depend on the navigation path taken to reach it. A component that mounts correctly when you go straight to the route can display differently when you arrive after navigating from another view.
Functional tests that access each route directly by URL completely miss these regressions linked to sequential navigation. Only a test that reproduces the real user journey and visually captures the result can detect them.
Transitions and animations
SPAs make heavy use of transitions to smooth navigation. A component does not disappear instantly: it animates out while the next one animates in.
And this is a prolific source of visual bugs. An interrupted CSS animation can leave two components overlapping. Poorly calibrated timing can create a flash of content. An animation that does not finish cleanly can leave an element in an intermediate state indefinitely.
Automated visual testing can capture the intermediate transition states by taking captures at precise moments of the animation cycle.
Conditional rendering
SPAs love conditional rendering. Show this component if the user is logged in. Show this banner if the feature is in beta. Change this button if the cart has items. Hide this section if the subscription has expired.
Each condition creates a fork in the tree of possible visual states. With five independent conditions, theoretically thirty-two different visual combinations. With ten, more than a thousand.
Nobody tests a thousand combinations manually. Nobody lists them exhaustively. Yet they exist and your users run into them.
Asynchronous loading states
In a multi-page site, loading is binary: the page is loaded or it is not. In an SPA, loading is continuous and partial. One component can be loaded while another waits for its data.
These partial loading states are visually significant. Your skeletons, spinners and placeholders are interface elements in their own right. A poorly sized skeleton that does not match the size of the final content creates an unpleasant visual jump.
State management is a multiplier of visual states
The modern architecture of an SPA relies on centralized state management (Redux, Vuex, Pinia, NgRx, Zustand). The application state is stored in a global store that determines what appears on screen.
This architectural pattern is excellent for maintainability. It is terrible for visual testability, because it exponentially multiplies the possible combinations of states.
A logged-in user with an empty cart, unread notifications and dark mode enabled does not see the same thing as an anonymous visitor in light mode. And both must be tested visually.
Client-side routing and its visual pitfalls
Scroll position. In a multi-page site, each navigation resets the scroll to the top. In an SPA, the scroll position is kept between views unless the router is configured to reset it. The result: a user who navigates from a long page to a short one can end up with a blank screen, scrolled past the content.
Deep linking. Users can land directly on any route via a shared link. The rendering must be correct even without the normal navigation context.
Back navigation. The browser "back" button in an SPA does not reload the page: it restores a history state. If the restoration is incomplete, the displayed view can be visually different from the original.
A structured approach to visual testing for SPAs
Route coverage: each route must have at least one reference capture in its default state.
State coverage: for each route, identify the visually distinct states (empty, loaded, error, loading) and create a reference for each.
Interaction coverage: modals, dropdowns, tooltips and side panels that open on interaction are visual states in their own right.
Journey coverage: some visual bugs only appear in a specific navigation context.
SPAs deserve more visual testing, not less
An understandable temptation: faced with complexity, some teams reduce their visual testing effort. "Too many states, we cannot cover everything, let us focus on the functional side."
This reaction is the opposite of what is needed. The more visual states your application has, the more visual testing is necessary. It is precisely because SPAs are visually complex that manual testing is insufficient and visual automation becomes essential.
Every visually untested state is a state that can regress silently. And in an SPA, the number of untested states quickly exceeds the tested ones, unless you use a tool able to capture them automatically.
FAQ
Does visual testing work with all SPA frameworks?
Yes. Visual testing is framework-agnostic. It captures the final appearance rendered by the browser, whether it is React, Vue, Angular, Svelte or anything else.
How do I handle animations and transitions in SPA visual tests?
The best approach is to disable CSS and JS animations during captures to get stable comparisons. Some tools offer this option natively.
How do I visually test states that depend on dynamic data?
The standard solution is API mocking. You configure the tests to intercept network calls and return deterministic data.
How many visual states should I test for an average SPA?
At least three per route: nominal, empty, error. For an SPA with 20 routes, that is a minimum of 60 reference captures. With interaction states, you easily reach 100-150.
Does visual testing replace unit and e2e tests in an SPA?
No, and that is not its purpose. Unit tests verify logic. E2E tests verify functional journeys. Visual testing verifies appearance. The three are complementary.
Aren't SPA visual tests too slow?
A modern SPA renders in a few hundred milliseconds. Capturing adds a few dozen. The comparison is almost instantaneous. For 100 captures, count 2-5 minutes in total.
Does your SPA have dozens of visual states that nobody tests? It is time to change that.