Playwright Quickstart
Set up visual testing with Vera CI and Playwright in under 5 minutes.
Prerequisites
- Playwright installed and running
- Playwright configured to run in your CI/CD pipeline
- A project created in Vera CI
Install the reporter
Add the @vera-ci/playwright-reporter package to your project:
npm install --save-dev @vera-ci/playwright-reporterConfigure Playwright
Add the Vera CI reporter to your playwright.config.ts:
import { defineConfig } from "@playwright/test";
export default defineConfig({
reporter: [
["html", { open: "never" }],
[
"@vera-ci/playwright-reporter",
{
// Reads from VERA_API_KEY env var by default
uploadTraces: true,
uploadVideos: true,
},
],
],
use: {
trace: "on-first-retry",
screenshot: "on",
},
});Tip
VERA_API_KEY and VERA_PROJECT_ID from environment variables, so you don't need to hardcode them in your config.Capture screenshots
Use the veraSnapshot helper to capture named, stable screenshots in your tests:
import { test } from "@playwright/test";
import { veraSnapshot } from "@vera-ci/playwright-reporter";
test("homepage", async ({ page }) => {
await page.goto("/");
await veraSnapshot(page, "homepage");
});
test("header component", async ({ page }) => {
await page.goto("/");
await veraSnapshot(page, "header", {
element: "header",
});
});
test("full page capture", async ({ page }) => {
await page.goto("/about");
await veraSnapshot(page, "about-full", {
fullPage: true,
});
});Screenshot options
fullPage. Capture the full scrollable page (default:false)element. CSS selector or Playwright Locator to capture a specific elementwaitForStable. Milliseconds to wait for animations to settle (default:500)
Set environment variables
Set the following environment variables in your CI provider:
VERA_API_KEY=your-api-key
VERA_PROJECT_ID=your-project-idYou can find your API key and project ID in your Vera CI project settings.
Info
Run your tests
Run your Playwright tests as usual:
npx playwright testAfter tests complete, the reporter uploads results to Vera CI and prints a summary with a link to your run:
[Vera] Uploading results...
✓ [Vera] Run uploaded successfully
→ 12 tests · 10 passed · 2 failed · 15 snapshots
→ https://vera-ci.com/org/team/project/runs/abc123After installation
Once your changes are pushed, Vera CI status will appear on your pull requests. You'll see a summary of visual changes with links to approve or reject each diff.
Info
For the full list of reporter options, see the Playwright Reporter SDK reference.