# Variance Authority > Open-source tools for developers and coding agents: source intelligence, live test inspection, test selection and reduction, UI analysis, and change verification. Every documented page serves the Markdown it is built from beside it: append `/index.md` to the page's path. Links within that Markdown point at the Markdown of the page they name. ## Start here - Install the CLI: `npm install --save-dev @variance-authority/cli`. It installs the `variance` command and ships the agent skills under `node_modules/@variance-authority/cli/skills/`. - [Link the agent skills](https://variance-authority.dev/agents/cli/index.md#point-an-agent-at-it) into your agent's own skills directory. - [Choose an agent workflow](https://variance-authority.dev/agents/index.md): Three questions with three different owners: a hung test, a screenshot that changed, and a symbol you cannot name. Only the last can be answered without a run behind it. Each is matched below to the reading it needs and the guide that sets that reading up. - [Visual review integrations](https://variance-authority.dev/start/index.md): One question picks your guide: which harness already puts the app in the UI state you want to review — a Playwright spec, a built Storybook, a served route, a jsdom unit test, Vitest browser mode, an Rstest suite, or a mount nobody else owns. Whichever row of the table below you land on ends the same way: that state gets a baseline image you approved, and a later run that moves pixels reports the component that drew them and the file:line it was written at. - [Source](https://github.com/Variance-Authority/variance-authority): every package's README, beside the code it documents. ## Examples Repositories to clone and run, each installing the published packages. - [example-playwright](https://github.com/Variance-Authority/example-playwright): visual review from inside a Playwright test - [example-storybook](https://github.com/Variance-Authority/example-storybook): visual review of every story in a Storybook - [example-vitest](https://github.com/Variance-Authority/example-vitest): visual review from a unit test - [example-running-app](https://github.com/Variance-Authority/example-running-app): visual review against an application that is already running - [example-static-site](https://github.com/Variance-Authority/example-static-site): visual review of a built static site - [example-divergence](https://github.com/Variance-Authority/example-divergence): one input rendered two ways, and where the renderings part - [example-history](https://github.com/Variance-Authority/example-history): what a design token has drifted to across many approved reviews - [example-tribunal](https://github.com/Variance-Authority/example-tribunal): a storefront read twice and reviewed once in the review console - [example-workers](https://github.com/Variance-Authority/example-workers): test selection across Cloudflare Workers, joined by a Sentry trace - [example-tester-army](https://github.com/Variance-Authority/example-tester-army): end-to-end tests with coverage-based test selection, on a local model ## Documentation - [Questions](https://variance-authority.dev/docs/index.md): Pick the question that brought you here. Each path below tells you what evidence it needs, what answer it can produce, and where that answer stops. Use one path on its own or combine several as the investigation grows. - [Theory](https://variance-authority.dev/docs/theory) - [Reference](https://variance-authority.dev/docs/reference) - [Comparisons and case studies](https://variance-authority.dev/docs/comparisons) - [All pages](https://variance-authority.dev/docs/all) ## Theory - [Tests preserve the paths we care about](https://variance-authority.dev/docs/tests/index.md): A test turns one path through your product into a repeatable proof: the same starting conditions, the same action, the outcome you expected. What you earn is confidence that this one promise has been preserved under the conditions the test ran under. That is worth stating precisely, because it is also the boundary of what a green run can show you. - [On testing](https://variance-authority.dev/docs/on-testing/index.md): A test earns its place by producing credible information soon enough to change a decision. Its level, speed, coverage and age matter through that job. A suite is not strong because it owns many tests or because each test is small. It is strong when each important risk has evidence at the cheapest boundary that can still expose the real failure, and when you can tell what each test adds. - [On dependencies](https://variance-authority.dev/docs/on-dependencies/index.md): An import looks like one line of syntax. Added up, the imports of a repository are its "uses" relation, and the shape of that relation decides which parts of the system can be built, tested and understood without the rest. Software design has argued for a direction in that relation for fifty years, and dependency-analysis tools have long extracted it from code. Variance Authority uses that derived structure as a review signal: it shows when an ordinary import changes the dependency hierarchy before anyone has to declare what that hierarchy should be. - [Coverage-based test selection](https://variance-authority.dev/docs/coverage-test-selection/index.md): Coverage-based test selection runs, after a change, only the tests that executed the code you changed, according to a recording of an earlier run. Variance Authority records that relation on the suite you already run, for no more than 8% of its run time, and parses each changed file as it was recorded and as your diff leaves it before it selects a test. On an unmodified Zod checkout, a one-line edit selects 6 test files, 8 runs in all, where rerunning every file that loads the changed module selects 197. - [See what changed](https://variance-authority.dev/docs/changed/index.md): A diff records what you edited, and a screenshot or an assertion records the result. When a change goes wrong, what you need is the path between them: which branch ran, which component rendered, which input changed. That path exists only while the program runs. Variance Authority records it during the run, so you answer what did this change actually do? from the record instead of running the suite again to find out. - [Follow the reasoning loop](https://variance-authority.dev/docs/reasoning/index.md): You already have visual regression covered — toHaveScreenshot, Chromatic, Percy, jest-image-snapshot — and the question you bring to a red build is rarely did these pixels change. It is which tests this edit could affect, whether the change on screen is the change somebody authored, or why one state keeps disagreeing with itself. Variance Authority answers those from different readings — a parse of the source, a completed run report, a record of what each test covered, a suite still running — and asking the wrong one pays for a full suite render to get an answer a source reading already had. This page is how you pick the reading before you pay for it. - [Use the evidence you have](https://variance-authority.dev/docs/evidence-field/index.md): A red build from toHaveScreenshot, Chromatic, Percy or Argos hands back a count of differing pixels and two images; every question after that — which component drew the region, whether the same state reads the same way twice, whether your edit could reach it at all — is answered by somebody opening the diff. This page is about those later questions, and about answering them from readings the run already took rather than from a second tool asked to take them again. - [What one run leaves you](https://variance-authority.dev/docs/great-data/index.md): Your build went green, or you approved the diff and closed the report. Everything a Variance Authority run observed while getting there is still there, and most of what you can now ask it has nothing to do with pixels. - [Evidence instruments](https://variance-authority.dev/docs/instruments/index.md): A subject came back changed. Whether that difference is real, and what caused it, are two further questions, and by eye they are answered one image at a time. The instruments catalogued here are the repeatable alternative: each one holds everything still, varies exactly one thing, and reads a representation cheap enough to read again. - [Why it does so many things](https://variance-authority.dev/docs/adjacent-possible/index.md): Variance Authority starts with visual regression and does not end there. It also shows you where to start in an unfamiliar codebase, selects the tests a change needs, names the tests that run a line, helps you shrink an oversized test, and records what a Java service ran for each test. Visual regression no longer defines it, the same way guitars do not define Yamaha. One phrase explains the list: self-reinforcing adjacent possibilities. Solving one problem builds a capability, and that capability makes the next problem cheap. - [Why visual review costs less here](https://variance-authority.dev/docs/visual-review-cost/index.md): A visual regression suite costs you twice: machine time for every picture it takes, and an engineer's time for every difference it shows. Both grow with one number — how many comparisons the suite makes, and how many of those it puts in front of a person. A screenshot tool takes every picture first and compares afterwards, so that number is fixed before anything clever runs. Variance Authority runs beside the tool and the tests you already have, and decides earlier. It runs only the specs and stories that executed the code you changed, settles a state whose DOM and styles are unchanged without painting a pixel, and when it does show you a difference, it names the component and the file:line that drew it. - [Extend what you already use](https://variance-authority.dev/docs/extend-what-you-use/index.md): You already have tools built around how your software works. Your test runner runs the suite. Playwright drives a browser. React Testing Library helps tests address the interface. Your visual regression service compares screenshots and records approvals. Your debugger, editor, search tools and documentation service answer other questions. Replacing any one of them is a separate decision. ## Code exploration - [Find where to start](https://variance-authority.dev/docs/orientation/index.md): Orientation turns a question about an unfamiliar codebase into an address you can inspect: a source name, a file, an import neighbourhood, or a captured UI subject. It comes before diagnosis and editing. Its answer is where to read next, not a claim that the code is correct. - [Find a name in source](https://variance-authority.dev/agents/workspace-api/index.md): rg tells you where text is written. This server tells you which name matches your words in the part of the import graph you are working in — an exported name first, then one a file keeps to itself — then gives you its declaration, signature and documentation, and for an exported name its import line and existing import sites. It answers from a dated workspace generation — no build, run, generated API site, or variance.config.json in between. - [Use the packages your project already installed](https://variance-authority.dev/docs/tech-stack/index.md): Your project's tech stack is the packages its code builds on and builds with. Variance Authority reads it from your checkout: which packages the file you are editing can already use, which installed package does a job, the signature of a name at the version in nodemodules, and the agent skills a package's authors ship with it. Your agent asks with variance ask stack, search and symbol, or through the same tools on the MCP server, before it writes code against a library. Every answer comes from the files you installed. Nothing is fetched and nothing is installed for you. - [Find the subject you mean](https://variance-authority.dev/docs/locate/index.md): You know which thing you want to look at. You do not know what it is called. - [How subject search works](https://variance-authority.dev/docs/lexicon/index.md): This is the recorded-vocabulary half of orientation: use it when you can describe a captured UI state but do not know its subject id. For source names in the current checkout, use the workspace API. - [See the structure your imports build](https://variance-authority.dev/docs/boundaries/index.md): variance layers numbers every package by the longest chain of packages it imports beneath it, and tells you in a pull request which packages changed number. It needs no declaration of an architecture: it derives the depth from the imports already in the source index, so the layers are the ones your code has, not the ones a config says it should have. Declare a few line budgets and it also places every package in a tier by how much code it pulls in. variance restrictions adds policy when you want to state a relationship, a depth limit or a size limit that must hold. Neither asks you to tag packages. ## Your test suite - [Make a test suite faster and more reliable](https://variance-authority.dev/docs/better-tests/index.md): While a test runs, the machinery under it can observe which code executed, which elements the test queried or clicked, and what setup ran before it began. Teardown is normally where all of that disappears, and the run ends with a pass, a fail and a pixel count. Variance Authority keeps the record instead. - [Own fewer tests](https://variance-authority.dev/docs/own-fewer-tests/index.md): Your suite only grows. Every test in it was justified when it was written, and a merged coverage report cannot tell you which of them are still worth keeping: it shows that a line ran, not which tests ran it, not whether six of them ran it for the same reason. Variance Authority records the half coverage drops: for each test case, which regions of your source that case covered. Point at a line and it hands back the named cases that walked it, which is where the question why do all of these tests need this code? starts having an answer. - [Test-level coverage](https://variance-authority.dev/docs/test-level-coverage/index.md): Ordinary coverage is a union: every region some test covered, with nothing left recording which test covered it. Test-level coverage keeps the relation that union was folded from — for each named test case, the regions of your source that case walked — so a line answers which tests walk me rather than did anybody. It is one axis added to a recording your suite can already make, and it is what separates a question you can act on from a percentage you can only watch. - [Record the state each test ran under](https://variance-authority.dev/docs/case-preconditions/index.md): Test-level coverage tells you which tests ran a piece of code. A case precondition records the state each of those tests ran it under: a feature flag, what a mock returns, which user a fixture signs in. Coverage gives you the code path; case preconditions give that path its scenario. A breadcrumb records the other side: the value the code under test read, so you can check that the scenario a test claims is the one that ran. - [Run relevant work](https://variance-authority.dev/docs/run-relevant-work/index.md): Not every subject in your suite can be touched by the file you just edited. Variance Authority rules out the ones that cannot, before a browser opens. - [Run the tests an edit needs](https://variance-authority.dev/docs/test-an-edit/index.md): Set VARIANCEAUTHORITYSINCE and the Vitest or Jest run you already call leaves out every test file a recorded run shows never executed the code you changed. Nothing goes on the command line and no script sits between you and the runner, so the edit-and-test loop you or your coding agent already runs stays the same loop, only shorter. - [How test selection works](https://variance-authority.dev/docs/selecting/index.md): A change to a few lines should not run every test that imports the file. With execution recording, Variance Authority records which parts each test actually covered. It selects the tests that reached those lines and shows when no test did — what a record shows that no graph can. - [Split a suite across CI jobs](https://variance-authority.dev/docs/sharding/index.md): Shard a Vitest, Jest or Playwright suite with --shard k/n, and each shard takes whole test files by how long they took on the last recorded run, not by how many there are. Each file goes in turn, longest first, to the shard with the least time so far, so the shards finish close together. Each shard computes the split from the record it reads and the files it collects, without talking to the others, so shards that read one record at one commit run every file in exactly one shard. A Playwright setup or teardown project is the exception: Playwright runs it in every shard that keeps a test depending on it. - [Changes before and beyond](https://variance-authority.dev/docs/changes-before-and-beyond/index.md): Two changes widen a run that no import graph can narrow: a config file nothing imports, and a package you never wrote. Selection answers from the names files import from each other, so a change with no name in those imports is either the whole suite or nothing at all — and which of the two is a choice you make rather than one the walk makes for you. This page is about those two changes, about the files a suite ignores because none of its results can move with them, and selection is about everything between them. - [Measure test distance](https://variance-authority.dev/docs/distance/index.md): After a source change, test selection narrows your suite to the test files that change could have reached. On a shared module that narrowed set is still most of the suite, and nothing in it tells you which file to run first. Distance orders it: for each selected test file it counts the import steps — hops — between the changed source and that test, so you can run the closest files first and read an answer while the edit is still fresh. - [Select Java tests from the methods each one ran](https://variance-authority.dev/docs/jvm/index.md): A Java agent records which methods each test entered, so a change to a Java method runs only the tests that reached it. A test is a JUnit test class, or a Jest case or browser spec that reached the method in a service over HTTP. The record is one row per test, and variance select answers a diff from it without an import graph, which a request to another process never shows. - [Make one test cost less](https://variance-authority.dev/docs/optimize-a-test/index.md): Selection decides which tests run after an edit. It does not change what one of them costs while it runs, and it does not change how often the next edit reaches it. Both of those are properties of the boundary the test loads. - [Distil a test to what it witnesses](https://variance-authority.dev/docs/distill/index.md): A checkout test may render a navigation bar, a clock and an order form, whether that markup comes from React, another framework, or no framework at all. But which elements does it actually use to set up the order, submit it and check the result? Rendering the whole page does not make every part of it part of the promise the test protects. ## Visual review integrations - [Visual review integrations](https://variance-authority.dev/start/index.md): One question picks your guide: which harness already puts the app in the UI state you want to review — a Playwright spec, a built Storybook, a served route, a jsdom unit test, Vitest browser mode, an Rstest suite, or a mount nobody else owns. Whichever row of the table below you land on ends the same way: that state gets a baseline image you approved, and a later run that moves pixels reports the component that drew them and the file:line it was written at. - [Playwright](https://variance-authority.dev/start/playwright/index.md): The state you want to review only exists after your test has navigated, logged in and waited for it — so keep all of that. This page adds one Variance Authority observation and one assertion inside the test body, at the point where the page is already right, and the locator you pass becomes a subject with a baseline image of its own. - [Storybook](https://variance-authority.dev/start/storybook/index.md): Story ids already name your UI states, and storybook-static/index.json already lists every one. This page turns that list into screenshots you approved — build, run, review, accept, rerun — and a story whose pixels move afterwards is reported by the component that changed and its file:line. - [Application routes](https://variance-authority.dev/start/routes/index.md): A server owns your routing and page state here, and the route as it ships — not a component mounted alone — is what you want under an approved image. Name one URL, run it, approve the first image, and watch the second run come back unchanged. That loop is the whole of this page. - [Vitest or Jest (jsdom)](https://variance-authority.dev/start/unit/index.md): Your Vitest or Jest tests already mount components in jsdom and assert on them. This path puts those same mounted states into visual review: the test writes a capture, a later process paints it in Chromium, and the screenshot is compared against an approved baseline. You get visual coverage of the components you already cover, without writing and maintaining a second Playwright or Storybook suite for them. - [Vitest browser mode](https://variance-authority.dev/start/vitest-browser/index.md): Vitest browser mode has already mounted your component in a real browser, which is the expensive part. This page spends one call and one assertion on top of it: the mounted subtree is read as a document rather than photographed, repainted by a Chromium the Vitest process owns, and compared against an image you approved. - [Rstest](https://variance-authority.dev/start/rstest/index.md): Rstest runs a suite two ways, and each one is a different adoption of visual review. - [Custom collectors](https://variance-authority.dev/start/custom/index.md): Whatever renders your states can go under approved baselines, provided a state's name is the only input to the bytes it produces. This page is that route for a harness nobody wrote an adapter for: one module you write, then a new verdict, an approval, and unchanged on the rerun — every step after that module identical to a built Storybook's. - [Visual review from the CLI](https://variance-authority.dev/start/cli/index.md): Four commands make the review loop, and @variance-authority/cli is all four: ## Investigate a run - [Understand an execution](https://variance-authority.dev/docs/understand-execution/index.md): A comparison or an assertion has shown you that something changed, and now you need to find out where. This page indexes what the same run kept about the execution behind that answer: one test's work, from the moment your runner starts it to the moment it ends, across every process it touched. - [Watch a run that has not finished](https://variance-authority.dev/docs/vantage/index.md): Your suite is still running and one test has been on the same line for longer than it should. Variance Authority can show you what that test has heard, and from whom, while it is still in flight rather than after teardown has thrown all of it away. - [See what a test addressed](https://variance-authority.dev/docs/eyes/index.md): A passing test proves that its assertion succeeded. It does not reveal which UI the test deliberately operated, which React work arrived alongside that interaction, or which executed source was merely present. Eyes records that missing surface as one authored Arrange–Act–Assert chronology. - [Read the path an execution took](https://variance-authority.dev/docs/journeys/index.md): Three stories mount CartCard. One of them clicks Remove. The onClick body is a region the other two have never been inside — same file, same import graph, same props — and no reading of the file can distinguish the three, because the difference is not in the file. It is in what each execution did with it. - [Follow a test into other services](https://variance-authority.dev/docs/across-dimensions/index.md): A test runs in one process, and the code it checks often runs in others: a gateway it calls, the services behind that gateway, a JVM backend, a Worker behind a service binding. Each process, runtime or language one test passes through is a dimension of that test. This page is for a suite whose tests cross them. It explains why no import graph can tell which of those tests a change beyond the first process reaches, and how Variance Authority follows each test's execution into the other processes and joins what they ran back to the test after the run. - [Compare state transitions](https://variance-authority.dev/docs/scenarios/index.md): A snapshot test checks that one UI state looks the way it did. It cannot check that clicking Delete does the same thing on a page with one article as on a page with two. A runtime scenario records that: a named starting state, a fixed sequence of authored steps, and what the UI looked like after each one. Read this page when you want to compare two such recordings. - [Understand an interface](https://variance-authority.dev/docs/understand-interface/index.md): Three readings describe a rendered interface without comparing it to anything: the measured relationships of the layout, the elements your test actually addressed, and the React component that owns each of them. All three read one live page inside a Playwright or Vitest run you already have, and none of them needs a previous image, an approved baseline, or a stored comparison. - [Inspect presentation relationships](https://variance-authority.dev/docs/presentation/index.md): You make a UI edit and the screenshot changes, which shows that the interface changed, but not what changed about the way it reads. One repeated row may have drifted from its peers, a heading may no longer stand apart from its body, or two groups may have become hard to tell apart even though every word is still present. Measure those relationships before the edit and again after it, and a person or a coding agent can say whether the edit did what it was meant to do. - [React state and effects](https://variance-authority.dev/docs/framework/index.md): A form renders correctly and its screenshot passes. A child component declared inside the form is nevertheless rebuilt on every parent render, so the next validation update discards what the user typed. Before that interaction, the stable and broken versions produce the same document. The capture describes what is on screen; it cannot show whether that component will survive. - [Explain variance](https://variance-authority.dev/docs/explain-variance/index.md): Something moved, and the report you are reading names a region but not a reason. Which page helps depends on the kind of explanation that is missing: a component name, the input that changed, a second reading that disagrees with the first, or a declaration that the region was never the subject. Each row below names one and the page that produces it. - [Trace a visible change to source](https://variance-authority.dev/docs/attribution/index.md): A pixel differ answers one question — how many pixels differ — and 5482 cannot be read, cannot be assigned, and leaves you opening the image to look, which is the expensive act the tool was supposed to replace. Attribution turns the count into this region, inside Toggle, in main → region "Todos" → item 2 of 3, written at examples/todomvc/src/ds/components.tsx:107. - [Compare A with B](https://variance-authority.dev/docs/a-b-testing/index.md): Before you read a comparison of A with B, you need to know what is different between them. When one thing differs, every difference in the result belongs to it. When two things differ, nothing in the result shows which one you are looking at. Every pair that Variance Authority compares states the one thing that differs between its sides — the revision, the time, the page it was read on, an authored Act, or the subject itself — and a pair where a second, undeclared thing also differs is refused rather than reported. - [Which input changed, not just which pixels](https://variance-authority.dev/docs/parting/index.md): A diff shows that a
on one side and a on the other. That is a symptom, and acting on it means opening the component, guessing which branch ran, and guessing why. partingOf takes those two readings and names the input that sent them apart — a prop, a context value, an external store, or a hook cell — along with the component that changed it. Read on when you have a difference in hand and want its cause rather than its coordinates.
- [Compare related states](https://variance-authority.dev/docs/variations/index.md): Your suite has variants: a feature flag's second version, the same page in the dark scheme, a story at a narrow viewport, a route whose backend answers with the empty state. What each of them does to the page is the difference you care about, and it is the one difference an ordinary run never reports. This page is for making a run measure it instead.
- [Group repeated changes](https://variance-authority.dev/docs/composition/index.md): One token edit turns forty stories red, and every comparison you have is one subject — a story, route, fixture or data value your config names — against its own baseline: two revisions of one thing, forty times, with nothing marking the forty as one change. Composition is the other axis — many subjects, one revision, joined on the components they share — and there is no baseline anywhere in it.
- [Trace instability to its owner](https://variance-authority.dev/docs/flakiness/index.md): Visual regression becomes hard to trust when several different causes are all reported as “flake.” When a subject changes, the run varies one condition at a time: again holds the world and advances time to test whether the subject drifts in place; when again agrees, alone rebuilds the world at the same time to test whether the shared session changed it. These are evidence-producing checks, never retries. A moving animation, a changed environment, an unstable component, and leaked state need different responses; treating them alike leads to tolerances that may quiet the report without explaining what happened.
- [Page stabilization](https://variance-authority.dev/docs/stabilization/index.md): A spinner caught mid-turn, a web font that arrived late, a scrollbar one machine draws and another does not: any of them reports a change your code did not make. A run, one execution of npx variance run or one observation in your test, holds your page still before it reads it, so that two readings of an unchanged UI agree. Read on for what it does to get your page there, what you can change about it, and how far into your page it goes.
- [Wait for content that loads late](https://variance-authority.dev/docs/late-content/index.md): A component that loads its code or its data after its first render shows a placeholder, then its content, and a screenshot records whichever of the two is on screen. A run waits for the late content React reports as pending: a React.lazy component, a promise read with use() inside