A monorepo (monolithic repository) is a source code management architecture where multiple projects, applications, and shared libraries coexist in a single Git repository, managed by orchestration tools like Nx, Turborepo, or Lerna that optimize builds and tests based on the dependency graph.
Monorepos have won. Front-end teams managing multiple applications (a marketing site, an admin dashboard, a customer app, a partner portal) group them into a single repository. It's simpler for sharing code, more consistent for the design system, more efficient for cross-cutting updates.
But for visual testing, it's a logistical nightmare. Not because visual testing doesn't work in a monorepo. It works very well. The problem is that it works too well: a change in a shared package potentially triggers visual tests on every project that depends on it. And when your monorepo contains 15, 30, or 50 projects, "test everything on every commit" is no longer an option.
The essentials on one page, definition, no-code automation, a grid for choosing a tool: Automated regression testing, no code.
The fundamental problem: the dependency graph
In a monorepo, projects are not independent. They share packages: a design system, a utility library, common components, shared configurations. These dependencies form a graph, and that graph is what makes visual testing complex.
Take a concrete example. You have a "ui-components" package that contains your buttons, forms, and navigation components. This package is used by 12 applications in your monorepo. You change the padding of a button in "ui-components". Visually, this change potentially affects all 12 applications. Every page that contains a button could render differently.
If you run visual tests on all 12 applications, you potentially capture hundreds of screenshots. The CI/CD pipeline takes 45 minutes. Developers wait. And if one of the tests fails (a false positive tied to a headless rendering issue), it's the developer of the "ui-components" package who has to investigate a failure in an application they don't even know.
That's unsustainable. And it's exactly what happens in monorepos that have no visual testing strategy.
Test what changed, not everything: the affected principle
The first rule of visual testing in a monorepo is simple in theory, complex in practice: only test what is affected by the change.
Modern monorepo tools, Nx and Turborepo foremost, know how to compute the dependency graph and identify the projects "affected" by a change. When you modify a file in the "ui-components" package, Nx can tell you that applications A, C, F, and K depend on this package, but not B, D, and the others.
That's the foundation. But for visual testing, it isn't enough. Because "application A depends on ui-components" doesn't mean that every page of application A uses the modified component. If you changed the button, only the pages that contain a button are affected. Pages that don't contain one are stable.
Smart visual testing in a monorepo therefore operates on two levels of filtering. First level: which projects are affected by the change, according to the dependency graph. Second level: which pages or components of those projects actually use the modified element.
The first level is solved by monorepo tools. The second level is much harder: it requires either static code analysis (which pages import which component), or an explicit mapping maintained by the team (this component is used on these pages).
The reality of shared packages
Shared packages are the strength and the weakness of the monorepo. They enable consistency: a single design system, a single source of truth for visual components. But they also create a considerable blast radius effect.
There are three types of shared packages that pose specific problems for visual testing.
UI component packages. This is the most obvious case. A change in a button, a form, or a modal visually affects every page that uses them. The blast radius is proportional to the popularity of the component. A layout component used everywhere (Header, Footer, Sidebar) has a maximal blast radius.
Style and token packages. A change in design tokens (colors, spacing, typography) is often invisible in the traditional dependency graph. If you change the primary color in your tokens file, the dependency graph sees a change in the "design-tokens" package. But this change visually affects everything: every primary button, every link, every accent element in all applications. The blast radius is total.
Utility packages with visual side effects. Less obvious: utility functions that format dates, truncate text, or compute layouts. A change in a text truncation function (going from 100 to 80 characters max) has a direct visual impact on all the components that use it. But the dependency graph doesn't know it's a "visual" change.
Strategies that work
After watching dozens of teams handle visual testing in a monorepo, here are the strategies that produce the best results.
Strategy 1: layered visual testing
Organize your visual tests into three layers with different execution frequencies.
The component layer. Test each design system component in isolation, via Storybook or equivalent. These tests run only when the component package changes. They're fast (a few minutes) and protect the library itself. This is the first safety net, the one described in the article on visual testing in design systems.
The affected page layer. Test the pages of the applications affected by the change, identified by the dependency graph. These tests run on every pull request, but only on the affected projects. They are the core of your strategy.
The full layer. Test all the pages of all the applications. This layer doesn't run on every PR: it's too expensive. Run it once a day (nightly), or before each release. It catches the regressions that the dependency graph failed to predict.
Strategy 2: explicit component-to-page mapping
Maintain a configuration file that associates each shared component with the pages that use it. When the Button component changes, the file indicates that the /login, /signup, /checkout, and /settings pages of application A use this component. Only those pages are tested.
This mapping is tedious to maintain by hand. But it can be generated automatically by static code analysis, walking through each page's imports and going back up the dependencies. Nx offers plugins that make this kind of analysis easier.
The advantage is considerable: instead of testing 200 pages of application A when a component changes, you test only 12. The pipeline goes from 30 minutes to 3 minutes.
Strategy 3: shared baseline with override
In a monorepo with a common design system, visual baselines (the reference screenshots) have a particularity: shared components render the same in all applications (in theory). So you can maintain a design system baseline at the package level, and only recapture baselines at the application level when the integration context changes.
Concretely: when you modify the Button component, you update the Button baseline in the ui-components package. Applications that use the Button inherit this new baseline. Only the applications where the Button renders differently in context (because of specific CSS, theming, or overrides) need their own baselines.
Classic mistakes to avoid
Testing everything, all the time. It's the natural reaction, and it's the worst. Your pipelines get slow, your developers ignore the results because there's too much noise, and real bugs drown in false positives. Visual testing in a monorepo has to be surgical.
Ignoring the dependency graph. Some teams configure their visual tests independently of the monorepo tool. Result: the tests don't know which projects are affected and test either everything or nothing. Integrate your visual testing tool with Nx or Turborepo. Use their "affected" commands to trigger the right tests.
Putting all baselines in a single folder. Visual baselines must live next to the projects they protect. If you centralize all baselines in a root folder, you lose granularity: you no longer know which baseline belongs to which project, and cleaning up obsolete baselines becomes impossible.
Neglecting baseline versioning during cross-cutting updates. When you modify a design token that affects all projects, all baselines must be updated simultaneously. If you update them project by project in separate PRs, you create a window during which some projects have the new baselines and others the old ones. Tests become inconsistent.
The role of CI/CD in monorepo visual testing
The CI/CD configuration is critical. Your pipeline must be able to do three things.
First, compute the set of projects affected by the change. That's the job of Nx (nx affected) or Turborepo (turbo run --filter). This step determines the scope of the tests.
Second, parallelize visual tests per project. If three applications are affected, run the tests for the three applications in parallel, not in sequence. Each application has its own set of baselines and its own results report. Parallelization is the only way to keep pipeline times acceptable.
Third, aggregate the results and block the PR if needed. Even if the tests are parallelized, the final verdict must be unique: the PR passes or it doesn't. If application A has a visual regression and the others don't, the PR is blocked. The developer knows exactly which application is affected and can investigate.
When no-code simplifies everything
Code-based visual testing tools, Playwright, Cypress with visual plugins, fit well into a monorepo because they live in the same repository, next to the code they test. But they add test code to maintain, per-project configurations, and specific CI/CD scripts.
No-code tools like Delta-QA offer a different approach. Rather than testing from the source code, they test from the deployed URLs. You configure the URLs of each application, and the tool captures screenshots and compares them with the baselines. The monorepo is no longer a complexity factor: the tool only sees URLs, not packages.
The downside: you don't benefit from the dependency graph to filter tests. The upside: configuration is instant, there's no test code to maintain, and the test is independent of the repository architecture. For teams that have no developers dedicated to testing, it's often the right compromise.
FAQ
Is Nx or Turborepo better for visual testing in a monorepo?
Nx has a significant advantage thanks to its more detailed dependency graph and its static analysis plugins. The nx affected command precisely identifies the impacted projects, and Nx executors make it possible to integrate visual testing tasks into the task graph. Turborepo is simpler but offers less granular filtering.
How do you handle baselines when a design token changes and affects everything?
Treat it as a cross-cutting update. Create a dedicated PR that modifies the token and updates all affected baselines in a single operation. Run the full layer of visual tests, approve the expected changes in bulk, and merge. Never split a token update across several PRs, that's an open door to inconsistencies.
How long should a visual test take in a monorepo pipeline?
When targeting only the affected projects: under 10 minutes for a standard PR touching a single project. Under 20 minutes for a change in a shared package affecting 3 to 5 projects. If your tests take more than 30 minutes on a PR, your filtering strategy is insufficient. The full layer (nightly) can take longer, 30 to 60 minutes is acceptable.
Do you need separate baselines per environment (dev, staging, prod)?
Yes, if the environments have different content or configurations. No, if the rendering is identical. In practice, maintain a single baseline per project, captured in a stable staging environment. Comparing against production is tempting, but dynamic content (dates, user data, A/B tests) generates too many false positives.
Does visual testing in a monorepo work with Lerna?
Lerna is primarily a tool for version management and package publishing. Its dependency graph is less sophisticated than that of Nx or Turborepo. You can use it, but you'll probably need to complement it with a custom script to identify the affected projects. If you're starting a new monorepo, prefer Nx or Turborepo.
How do you keep developers from ignoring visual test results?
Three rules. Keep the false positive rate close to zero: if developers regularly see false positives, they stop looking. Block PRs on visual test failures: no merge without approval. And keep pipeline times short: if visual testing adds 45 minutes to the PR, developers will find ways around it.