CI
Use this guide to run the visual tests in a CI job and keep the baselines that the job needs. Platforms and CI explains why baselines differ by operating system.
How the plugin detects CI
Section titled “How the plugin detects CI”The plugin uses is-ci to choose the folder, as Platforms and CI describes.
__vis__/ local/ # your machine, not committed linux/ # CI on Linux, committed __baselines__/Commit the __baselines__ folder of each CI platform.
Ignore local, __results__ and __diffs__, as Configuration shows.
Run the tests
Section titled “Run the tests”A job needs the browser that the provider drives. For Playwright, install it before the tests:
name: teston: [pull_request]jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 - uses: actions/setup-node@v4 with: node-version: lts/* cache: pnpm - run: pnpm install - run: pnpm exec playwright install --with-deps chromium - run: pnpm exec vitest runSee Playwright on CI for the options of the install command.
Create the baselines for CI
Section titled “Create the baselines for CI”A snapshot with no baseline fails, on CI too.
Create the baselines on the platform that checks them, with vitest run -u or createMissingBaseline: true.
Updating baselines explains both and the review before you merge.
Read a failure from CI
Section titled “Read a failure from CI”__results__ and __diffs__ are ignored by git, so a failing job leaves them on the runner.
Upload __vis__/**/__diffs__ as an artifact to read the review image, as Reviewing failures describes.
- uses: actions/upload-artifact@v4 if: failure() with: name: snapshot-diffs path: '**/__vis__/**/__diffs__'Options that matter
Section titled “Options that matter”| Option | Page |
|---|---|
snapshotRootDir, to change the folder or the CI naming |
vis config |
shortenLongSnapshotPaths, for long Windows paths |
vis config |
timeout, for a slow runner |
Troubleshooting |