Upload from CI
Playwright
Write Playwright screenshots to a folder, upload them with the circi CLI, and review the changes in CirCI, with no plugin and no change to how you write tests.
CirCI has no Playwright plugin, and it doesn't need one. Playwright takes the screenshots, circi upload sends every PNG under a folder, and CirCI compares each one with its baseline and asks your team to review the changes. This page shows a Playwright setup that writes its screenshots where the CLI looks.
Write screenshots to a folder
Section titled “Write screenshots to a folder”Playwright's toHaveScreenshot() normally compares against reference images committed next to your tests and fails the test on a difference (when that's enough, and when it isn't). With CirCI doing the comparing, point it at an output folder and let it overwrite on every run:
import { defineConfig } from '@playwright/test'
export default defineConfig({ testDir: './e2e', // CirCI compares and gates: write every screenshot to ./screenshots, and never fail a test on pixels. snapshotPathTemplate: '{testDir}/../screenshots/{projectName}/{arg}{ext}', updateSnapshots: 'all', projects: [{ name: 'chromium', use: { browserName: 'chromium' } }],})import { expect, test } from '@playwright/test'
test('profile page', async ({ page }) => { await page.goto('/settings/profile') await expect(page).toHaveScreenshot('settings-profile.png', { fullPage: true })})That run writes screenshots/chromium/settings-profile.png. The name CirCI shows is the path without the extension, chromium/settings-profile; the project's name is in the path so that two Playwright projects (browsers or devices) never overwrite each other. Always pass a name: Playwright adds the browser and the operating system to a generated one, and a name that changes between machines has no baseline to compare with.
Add screenshots to .gitignore. Nothing is compared on the machine that runs the tests, so a test fails only when it can't take the screenshot.
Upload from CI
Section titled “Upload from CI”-
Put the project's CI token in your CI's secret store as
CIRCI_TOKEN, and your CirCI address inCIRCI_API_URL(Create a project). -
Run the tests, then upload the folder and wait for the result:
npx playwright test && npx @circi/cli upload ./screenshots --wait -
Open the build in the dashboard. The first build of a project has nothing to compare with, so every screenshot is added and waits for your approval (First review).
--wait exits 1 while changes need review, so the CI job is the merge gate, unless a linked git host's check is (How a build flows). The copy-paste workflows for GitHub Actions, GitLab CI, Bitbucket Pipelines and Jenkins are in CI examples, including sharded runs: npx playwright test --shard=2/4 and circi upload --shard 2/4 go together.
Browsers and devices
Section titled “Browsers and devices”Each Playwright project writes to its own folder (the {projectName} in the template), and one upload carries all of them as one build. To give each browser its own build, baselines and review, upload each folder with its own --name:
npx @circi/cli upload ./screenshots/chromium --name chromiumnpx @circi/cli upload ./screenshots/webkit --name webkitThe names then lose the project folder, which is fine: each build name has its own baselines (CI examples).
Make screenshots stable
Section titled “Make screenshots stable”CirCI marks a pixel as changed when its color moves past a fixed tolerance, and the default diff threshold is 0%, so one different pixel is a change (How screenshots are compared). What keeps a Playwright screenshot the same from run to run is mostly in the test:
- A fixed viewport, set in the project's
use, andfullPageonly for pages whose height is stable. A different size is always a change. - The same fonts on every machine. Run the tests in the same container image locally and in CI.
maskfor content that changes (dates, avatars, ads):toHaveScreenshot('home.png', { mask: [page.locator('.timestamp')] }).- Fixed data and a fixed clock in the test, not a live service.
For a part of a page that still moves, draw an ignore region in the dashboard, and for a screenshot that flips back and forth see Triage and flaky screenshots.
Other tools
Section titled “Other tools”For Storybook stories there's @circi/storybook, and for Cypress @circi/cypress. The step-by-step pipeline is in the GitHub Actions guide.
Host the Playwright report
Section titled “Host the Playwright report”The same job can put the HTML report next to the screenshots: npx @circi/cli site upload ./playwright-report --name playwright. See Hosted sites.