CI
Goal: run the same snapshot tests on CI and keep the baselines trustworthy. The reasons behind this are in Platforms and CI.
What changes on CI
Section titled “What changes on CI”The addon checks whether it runs on CI (with the is-ci package).
The default snapshot root changes with it:
| Where | Snapshot root |
|---|---|
| Your machine | __vis__/local |
| CI | __vis__/<process.platform>, such as __vis__/linux or __vis__/win32 |
So CI never overwrites your local images, and each operating system has its own baselines.
Commit the __baselines__ folders of the CI platforms.
Ignore __vis__/local, __results__ and __diffs__, as in Configuration.
- Install dependencies and the browser for your provider (for Playwright,
npx playwright install chromium). - Run
npx vitest run. A story without a baseline or with a difference fails. - To create or update baselines on CI, run
npx vitest run -uon the platform and commit the result. See Updating baselines. - Upload
__results__and__diffs__as an artifact on failure, so a reviewer can look at them. The folders are ignored by git, so they exist only on the runner.
This repository does the same for its own test cases: CI renders on Ubuntu and Windows, and a bot opens a pull request with the new baselines for review.
See docs/snapshot-workflow.md.
Check your result locally
Section titled “Check your result locally”vitest run on your machine writes to local, so it does not compare with the CI baselines.
To reproduce a CI failure, run the same operating system, for example in a container, or read the diffs from the CI artifact.