Migrate from Vitest toMatchScreenshot to Argos
Move from Vitest's built-in toMatchScreenshot() to Argos. Stop committing __screenshots__ reference images and review visual changes on the pull request.
To migrate from Vitest's built-in toMatchScreenshot() to Argos, install @argos-ci/vitest, add argosVitestPlugin() to your Vitest config, replace each toMatchScreenshot() assertion with await argosScreenshot("name"), and delete the committed __screenshots__ folders. Your browser mode tests stay the same; Argos picks baselines from your Git history and reports visual changes as a check on your pull request.
Why teams move off toMatchScreenshot()
toMatchScreenshot() works, but it puts three problems on your team:
References are committed images. Vitest stores reference screenshots in
__screenshots__folders next to your tests, and you commit them. Screenshots of deleted or renamed tests aren't removed automatically.References are platform-specific. File names include the browser and the platform, for example
button-chromium-darwin.png, so references captured on macOS are not used on Linux CI. Vitest recommends a controlled environment, such as Docker or CI-only runs, to keep them consistent.There is no review step. A mismatch fails the test. To accept an intended change, you re-run with
--updateand commit the new images, and the diff image is written to.vitest/attachments/on the machine that ran the test.
Argos keeps your Vitest tests but removes all three: baselines are selected from your Git history, screenshots are captured on CI, and changes are reviewed and approved on the pull request.
What changes semantically
With toMatchScreenshot(), a visual difference fails the test. With Argos, argosScreenshot saves the screenshot and the comparison runs in Argos once the files are uploaded: the visual result becomes a commit status that you review and approve, independent of whether the test passed.
Concept mapping
Vitest toMatchScreenshot()
Argos
await expect(page.getByRole("button")).toMatchScreenshot("button")
await argosScreenshot("button")
A screenshot of one element
await argosScreenshot("button", { element: "button" }) (a CSS selector)
__screenshots__/ folders committed to Git
Baselines from Git history
vitest --update
Approve in the Argos review UI
comparatorOptions (threshold, allowedMismatchedPixelRatio, …)
The threshold option of argosScreenshot, and the diff algorithm
screenshotOptions.mask
The argosCSS option, for example visibility: hidden on dynamic elements
timeout (retries until the screenshot is stable)
Argos stabilization: waits for fonts, images, and aria-busy elements
Diff images in .vitest/attachments/
The build page and the pull request comment
A mismatch fails the test
A pull request check to review and approve
Migrate the project
Install the Argos Vitest SDK
You keep vitest, @vitest/browser, @vitest/browser-playwright, and playwright: the SDK requires Vitest 4 or later and captures screenshots with the Playwright provider. If your browser mode uses another provider, switch to @vitest/browser-playwright.
Replace toMatchScreenshot() with argosScreenshot()
Before (Vitest)
After (Argos)
By default, argosScreenshot captures the rendered output of the test. To capture a single element, pass a CSS selector: await argosScreenshot("button", { element: "button" }). Per-call options must be serializable, so pass a selector string, not a locator. The name is optional: omit it and Argos derives one from the current test.
Seed the baseline and wire up CI
Run your tests in CI with ARGOS_TOKEN set. Run on your default branch first so Argos has a baseline; until then, pull request builds are marked as orphan.
ARGOS_TOKEN comes from Settings → Authentication → Project token. On GitHub Actions you can use OIDC or tokenless authentication instead of a secret.
Frequently asked questions
Next steps
Vitest quickstart — the full setup, including
argosSnapshot.Vitest SDK reference — every option of
argosScreenshotand the plugin.Stabilize screenshots — keep your screenshots free of flaky diffs.
Vitest visual testing — a guide to browser mode screenshots, on the Argos blog.
Last updated
Was this helpful?