[Feature]: Support compression effort option for WebP screenshots and visual regression

Open
#43,045 2 comments 2 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@yury-s is already working on this.

Since Oct 5, 2026.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript, wasm
Domain
testing-qa

Research direction

Start by tracing WebP encoding for page.screenshot(), locator.screenshot(), and expect(page).toHaveScreenshot(), including the playwright.config.ts expect settings and bundled libwebp WASM module. Done means all listed APIs accept an integer effort from 0 to 6 with a default of 0, and lossless screenshots remain pixel-identical while supporting the requested compression setting.

Written by the indexing model from the issue text.

Description

milestone
🚀 Feature Request

Add an effort option (integer from 0 to 6, defaulting to 0) for WebP screenshots across:

  • page.screenshot()

  • locator.screenshot()

  • expect(page).toHaveScreenshot()

    • Per assertion
    • Via playwright.config.ts
Example
playwright.config.ts
import { defineConfig } from '@playwright/test';

export default defineConfig({
  expect: {
    toHaveScreenshot: {
      type: 'webp',
      effort: 4, // Baseline snapshots encoded with method 4
    },
  },
});
Per screenshot / assertion
// Direct screenshot
await page.screenshot({
  path: 'snapshot.webp',
  type: 'webp',
  effort: 6,
});

// Visual regression
await expect(page).toHaveScreenshot('landing.webp', {
  effort: 4,
});
Motivation

WebP is already supported in Playwright for both direct screenshots and visual regression snapshots (toHaveScreenshot()). Lossless WebP snapshots can provide 20–30%+ file size reductions compared to PNG.

In libwebp, the compression effort (method, range 0–6) controls how intensively the encoder searches for spatial and entropy redundancies.

Because the compression is strictly lossless:

  • effort: 0 and effort: 6 produce 100% pixel-identical RGBA buffers.
  • effort: 0 encodes quickly with minimal CPU usage, making it suitable for test-run screenshots and comparisons.
  • effort: 4–6 can significantly reduce file size, making it suitable for baseline/golden files committed to Git repositories.

Currently, Playwright's bundled libwebp WASM module does not expose the method parameter.

Adding this option would allow users to:

  1. Store smaller WebP baseline snapshots in their repositories and reduce repository bloat.
  2. Keep CI runs fast by generating comparison screenshots with effort: 0 while validating against high-effort baselines with zero pixel difference.
Dominant language
TypeScript
Stars
100k
Forks
6.9k
Avg merge
16h 8m
Merged PRs (30d)
281

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/playwright

All issues in microsoft/playwright

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.