Argos CI + Playwright Visual Regression Setup
In this article
This guide walks you through setting up Argos CI with Playwright for automated visual regression testing. You'll learn how to capture screenshots of your web app during Playwright test runs, upload them to Argos, and get visual diffs on every pull request. You'll need a Node.js project with Playwright already installed and a free Argos account.
What You'll Need
- A Node.js project (version 18 or later recommended)
- Playwright installed (
npm init playwright@latest) - A Git repository (GitHub, GitLab, or Bitbucket)
- An Argos account (free tier available at argos-ci.com)
Step-by-Step
- Create an Argos project
Log in to Argos, click "New Project", give it a name (e.g., "my-app-visual"), and copy the
ARGOS_TOKENfrom the project settings. This token is unique to your project and will be used to upload screenshots. - Install the Argos Playwright SDK
In your project root, run:
npm install --save-dev @argos-ci/playwright. This package provides theargosScreenshothelper that captures and uploads screenshots. - Configure Playwright to use Argos
In your
playwright.config.js, add the Argos reporter and set the output directory for screenshots. Example:const { defineConfig } = require('@playwright/test'); module.exports = defineConfig({ testDir: './tests', reporter: [ ['list'], ['@argos-ci/playwright/reporter', { uploadToArgos: false }] ], use: { screenshot: 'only-on-failure', trace: 'on-first-retry', }, });TheuploadToArgos: falseis set because you'll upload in a separate CI step, which is the recommended approach for most CI pipelines. - Add visual regression tests
In your test files, import
argosScreenshotand call it after navigating to a page. Example:const { test, expect } = require('@playwright/test'); const { argosScreenshot } = require('@argos-ci/playwright'); test('homepage visual test', async ({ page }) => { await page.goto('https://example.com'); await argosScreenshot(page, 'homepage'); });The second parameter is a unique name for the screenshot. You can call it multiple times per test to capture different states (e.g., mobile viewport). - Run Playwright tests locally
Execute
npx playwright testto run your tests. Argos will save screenshots to thetest-results/argos-screenshotsdirectory by default. You can override this withARGOS_DIRECTORYenvironment variable. - Set up CI upload step In your CI pipeline (e.g., GitHub Actions), after running Playwright, add a step to upload screenshots to Argos. Here's a GitHub Actions example: - name: Run Playwright tests run: npx playwright test - name: Upload screenshots to Argos run: npx @argos-ci/cli upload test-results/argos-screenshots env: Make sure to add ARGOS_TOKEN as a secret in your repository settings.
- Trigger Argos on pull requests Argos automatically detects commits and pull requests from your CI. For GitHub, install the Argos GitHub app to see check statuses directly on PRs. For GitLab or Bitbucket, configure webhooks in the Argos project settings.
- Review visual diffs When a PR is opened, Argos compares the new screenshots against the baseline (usually from the main branch). It shows a diff image with highlighted changes. Review the diff and approve or reject it in the Argos dashboard. If the change is intentional, approve it; Argos will update the baseline.
Common Mistakes
- Forgetting to set the token – The
ARGOS_TOKENmust be present in the environment of the CI step that uploads. Double-check your secret name and that it's available to the job. - Uploading screenshots from local runs – If you run tests locally, Argos will upload them to the default branch and may pollute your baseline. Set
uploadToArgos: falsein the reporter config to avoid this. - Not using unique screenshot names – If you use the same name for different pages or states, Argos will treat them as the same screenshot and produce false diffs.
- Ignoring dynamic content – Animations, carousels, or date-dependent content cause flaky diffs. Use Argos's
hideElementsoption or freeze time before screenshots.
Tips
- Use
argosScreenshotwith theviewportoption to capture multiple screen sizes (e.g., desktop and mobile) in one test. - Set a stable network condition in Playwright (e.g.,
page.routeto mock API responses) to reduce variability. - Run visual tests only on a scheduled basis or on PRs that touch UI code, not on every commit, to save CI time.
- Use Argos's "threshold" setting to ignore tiny pixel differences (e.g., anti-aliasing) if they cause noise.
- Keep your baseline updated by approving changes in the Argos dashboard after a deliberate UI update.
Troubleshooting
- No screenshots uploaded – Check that the
test-results/argos-screenshotsdirectory exists after running tests. If not, ensure you calledargosScreenshotin your tests. Also verify the upload command path is correct. - Upload fails with 401 Unauthorized – Your
ARGOS_TOKENis invalid or expired. Regenerate it in Argos project settings and update your CI secret. - Argos doesn't show a check on GitHub – Install the Argos GitHub app and ensure the repository is linked in Argos. Also check that the CI job has permissions to create commit statuses.
- Diffs appear even when nothing changed – Likely due to dynamic content or browser rendering differences. Use
page.clockto set a fixed date/time or hide elements withhideElementsoption inargosScreenshot. - Baseline not found for new screenshots – The first time you upload a screenshot, there's no baseline. Argos will create a baseline after you approve the first run. Make sure you run the tests on the main branch once to establish a baseline.
Frequently Asked Questions
Do I need to install Argos CLI separately?
Yes, the upload step uses @argos-ci/cli. You can install it as a dev dependency (npm install -D @argos-ci/cli) or use npx directly.
Can I use Argos with other testing frameworks?
Argos has SDKs for Cypress, Storybook, and Puppeteer, but this guide focuses on Playwright. The concepts are similar.
How do I ignore a specific element in screenshots?
Use the hideElements option in argosScreenshot: await argosScreenshot(page, 'homepage', { hideElements: ['.dynamic-banner'] }).
Does Argos support local development?
Yes, you can run Argos locally, but it's not recommended for baseline management. Use the Argos CLI to upload screenshots from your local machine if needed, but be aware it may affect your baseline.
What is the cost of Argos?
Argos offers a free tier with limited screenshots per month. For larger teams, there are paid plans. Check the pricing page on their website for current details.
Can I run visual tests only on specific branches?
Yes, you can conditionally run the upload step in CI based on branch names. For example, only upload to Argos on pull requests and main branch.