VARIANCE AUTHORITY
BrowseJest

Your test suite

Jest

Variance Authority keeps a record of the lines each Jest test ran, and your Jest 30 suite uses it from the next run on. You wrap jest.config.mjs once. Then CI runs only the test files your change reached, you can read what one test did and ask which tests cover a line, and visual review runs on your machine and in CI with no hosted service.

Try it

npm install --save-dev @variance-authority/sense @variance-authority/cli
// jest.config.mjs
import { withTestSelection } from '@variance-authority/sense/jest';

export default withTestSelection({
  // the configuration you have today, unchanged
  testEnvironment: 'node',
});

Jest does not say which config file it loaded, so name it as a precondition:

{ "suites": { "unit": { "kind": "unit", "before": ["jest.config.mjs"] } } }

Save that as variance.config.json, run npx jest once to write the record, change a source file, and run again:

$ VARIANCE_AUTHORITY_SINCE= npx jest
variance-authority: selected 12 of 340

Under Node 24 or newer, run a recorded suite with NODE_OPTIONS=--no-async-context-frame, so Jest frees each finished test file.

What you get

Leave out the test files a change did not reach

The wrap leaves files out in Jest's filter, before --shard, so every shard sees the same list, and your transforms, setup files, reporters and classic coverage setup stay as they are. VARIANCE_AUTHORITY_AT_DISTANCE=0-1 keeps only the tests within one import of the change. Cut a Jest run down to a diff lists every option of the wrap.

Skip the cases a change did not reach

Add VARIANCE_AUTHORITY_GRAIN=case, and a jest-circus handler marks the cases that ran none of the changed code as skipped before they run, as it.skip would. Skip the cases your edit did not reach says when a file still runs whole.

Place shards by recorded time

npx jest --shard 3/4 places whole test files by the time each took on the last recorded run, longest first. Split a test suite across CI jobs gets those times to CI, and keeps Jest's transforms between runs.

Read one test's story

Name one test to npx jest -t with VARIANCE_AUTHORITY_STORY=1 set, then run variance story. The story lists the calls of your code the test made, in order, with the branch each one took. Test stories shows how to read one and compare two.

Ask which tests cover a line

variance covering --file src/cart.ts --line 40 names the Jest tests that ran line 40. Covering lists every way to ask.

Visual review

A test in jsdom writes a capture of what it mounted, and a later variance run paints it in Chromium. The test stays without a browser and keeps its own assertions. Add visual review to the unit tests you already have sets it up, with no wrap needed.

Not yet

  • A browser inside the test: Jest has no browser mode, so visual review starts from a capture painted after the run, and a test story is of the code that ran in Node.
  • Selection in watch mode, or under --filter or --skipFilter on the command line.
  • A project named by path in projects: write it inline to have it recorded.

Go further