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

Aperta
#43,045 2 commenti 2 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@yury-s ci sta già lavorando.

Dal 5/10/2026.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript, wasm
Ambito
testing-qa

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.
Lingua principale
TypeScript
Stelle
100k
Fork
6.9k
Merge medio
16h 8m
PR unite (30g)
281

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/playwright

Tutte le issue di microsoft/playwright

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.