Skip to content
masterclass Buddy

Playwright · Matcher

toHaveScreenshot

expect(page).toHaveScreenshot() waits for a stable page image and compares it with a visual snapshot. It is a Playwright Test assertion for PNG or WebP screenshots.

Last updated

Since
v1.23

Syntax

await expect(page).toHaveScreenshot(name);
await expect(page).toHaveScreenshot(options);

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • toHaveScreenshot(options)
  • toMatchSnapshot
  • TestConfig.expect
  • testConfig.snapshotPathTemplate
  • maxDiffPixels
  • stylePath

Source: PageAssertions | Playwright. Checked 2026-11-03.