HelixOverviewComponentsMapsGraphIntroductionInstallationDeriving a themeSandboxTheme builderVisual testingCortexDocsEngramActiveTraceActiveRecallActiveServicesInsightsGet in touchSource on GitHub
Tooling
Visual testinghelix visual takes pictures of your pages and components in a real browser,
compares each one to a baseline kept in your git repository, and fails the run
when a picture changes. It ships in @fusion.dev/helix-cli, and it pictures
any web project, with Helix or without it.It pictures HTML files, any server's pages, Storybook stories, and entries from
a JSON catalog, and it has a GitHub Action.Installnpm install --save-dev @fusion.dev/helix-cli playwright
npx playwright install --with-deps chromiumCapture runs in Playwright, which you install beside the command line. The
rest of helix needs no browser, so Playwright is an optional peer, and
helix visual test names it when it is missing. A config in TypeScript needs
Node 22.18 or later. On an older Node, write it as visual.config.mjs.On macOS and Windows, a run skips until you choose where baselines are taken.test and update say so, compare nothing, and exit 0, because text draws
differently on each platform. Take baselines on Linux, or set platform: 'any'
to compare on the machine in front of you.Commandshelix visual test compare every shot, and fail on a difference
helix visual test button only the entries named button
helix visual update write only the baselines the comparison rejects
helix visual test --shard0--of4 the first of four shards, for CI
helix visual report open the report of the last run
helix visual compare a.png b.png compare two PNG files, with no browser
helix visual test pictures every entry and compares each shot with its
baseline. It exits 1 when a shot differs, changes size, has no baseline, or
cannot be taken, and writes an image of each difference beside its baseline,
named <stem><suffix>.diff.png. Add *.diff.png to your .gitignore.
helix visual update pictures every entry and writes a baseline only
where the comparison would fail. Review the files it writes before you
commit them.
helix visual report opens the report the last run wrote. --markdown
prints its summary as Markdown, for a CI job's summary page. --merge takes
the reports of a run's shards and prints their changes as one set of groups.
helix visual compare compares two PNG files. --diff writes the image
of the difference, and --threshold sets how far apart two colors may be
and still count as the same pixel.
Each run ends with one line that says what it compared and what it skipped.
helix --json visual … prints one JSON document on stdout and moves the
sentences to stderr.Picture a sitePicture a production build, because a dev server draws its own overlays, and they
differ from run to run. visual.config.ts, for a Next.js site:import{defineConfig}from'@fusion.dev/helix-cli/visual'exportdefaultdefineConfig({sources:[{baselines:'visual/baselines',kind:'server',name:'site',routes:['/','/pricing',{name:'not-found',path:'/nope',status:404}],start:'npm run start -- --port 3100',url:'http://localhost:3100',},],})npm run build
npx helix visual updateupdate writes the baselines and the fingerprint, and its report shows each
picture it wrote. Look at them, commit them, and run helix visual test from then
on. Any page that answers 400 or above fails the entry, unless its route names that
status.The configvisual.config.ts, in the directory you run helix visual from:import{defineConfig}from'@fusion.dev/helix-cli/visual'exportdefaultdefineConfig({serve:{'/theme.css':'dist/theme.css'},shots:[{name:'wide',scheme:'light',width:1280},{name:'phone',scheme:'light',width:390},{name:'dark',scheme:'dark',width:1280},],sources:[{glob:'{name}/example.html',kind:'html',name:'components',root:'src',styles:['/theme.css'],},],})
sources is where the entries come from. html reads every file its
glob matches under root and pictures each inside a document that links
styles. server pictures a server's routes and every route its
sitemap lists. storybook pictures every story in a running Storybook.
catalog pictures every { id, url } in a JSON file. pairs compares two
renders of each entry with each other.
shots is the pictures taken of each entry: a wide width, a phone
width, and dark when you give none. Each baseline is written beside its
entry as <stem>.<name>.png.
serve is URL paths served from disk, relative to the config.
baselines is, on a server source, the directory its baselines are written
in, relative to the config.
platform is where baselines are taken and compared: linux unless you set
any.
network is what a page may reach. origin, the default, refuses every
request to another host and names each host in the log and in run.json.
{ allow: ['tiles.example.com'] } lets those hosts through, and open lets every
host through.
mask is selectors whose elements are painted over in every picture, for
what changes on its own, such as a clock. A mask paints over the element's box and
anything drawn on top of it. The run names a mask that matches nothing on a page,
or only elements with no box.
style is a stylesheet applied while each picture is taken, to hold still
what mask cannot.
settle.selector names what a page matches once it has drawn what it draws
late, such as a map's tiles. The entry fails when nothing matches within
settle.timeout, 30 seconds unless you set it.
settle.readyProperty names a property your elements carry holding a
promise that resolves once they have rendered. The run awaits it before each
shot, for 5 seconds, and then names the tags still waiting.
settle.elements limits the custom elements a run waits for to one tag
prefix, for a framework that writes hyphenated tags it never defines.
aria keeps each entry's accessibility snapshot beside its baselines
and compares it as text, so a lost label fails even when no pixel moved.
checks adds judgments that need no baseline: code fails a code block
drawn in one color, clipped fails a box that cuts off its own text, and
overlap fails two boxes of text or controls that draw over each other.
The command's own reference, with every option, is the README of
@fusion.dev/helix-cli.How Fusion uses itFusion runs helix visual on every Helix example and on the site's pages on
every push, and keeps the baselines in git. A change to how a component draws
fails the run with a picture of the difference, and a retake opens a pull
request of new baselines for review.