# Playwright

> Send Playwright screenshots to VisualCI, with a baseline per browser project and a threshold for anti-aliasing.

Source: https://visualci.com/docs/screenshots/playwright/
All of VisualCI's documentation: https://visualci.com/llms.txt

Save screenshots in your tests where VisualCI can find them. The path, without `.png`, becomes the snapshot's name:

```ts
import { test } from '@playwright/test'

test('signup form', async ({ page }, testInfo) => {
  await page.goto('/signup')
  await page.screenshot({ path: `screenshots/${testInfo.project.name}/signup_form.png`, fullPage: true })
})
```

Upload each browser project as its own platform, after the tests:

```sh
export VISUALCI_BUILD_ID=$(visualci build create)
npx playwright test
visualci upload --platform chromium-linux --threshold 0.1 screenshots/chromium
visualci upload --platform webkit-linux --threshold 0.1 screenshots/webkit
visualci build finalize
```

Use this instead of `toHaveScreenshot`: the baselines live on VisualCI, a change waits for review instead of failing the test, and no PNGs are committed. Hide content that changes on every run (times, avatars) with Playwright's `mask` option, or wait for animations to finish, before the screenshot.

Run the tests in CI's browsers, not on a laptop: see [Platforms](https://visualci.com/docs/screenshots.md#platforms) and [Local runs](https://visualci.com/docs/local-runs.md).
