August 28th 2024

New

📸 Visual Comparison Widget

Playwright has a built-in ability to perform a Visual Comparison.

test('example test', async ({ page }) => { 
  await page.goto('https://playwright.dev'); 
  await expect(page).toHaveScreenshot({ maxDiffPixels: 100 });}
);

Playwright will fail a test if the current snapshot differs from a reference image.

We’ve released a first-class support for displaying the visual comparison screenshots, including browsing the diff, actual, expected, side by side and slider widget.

The support is automatic and doesn’t require any action other than just using toHaveScreenshot directive.