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

Abierto
#43,045 2 comentarios 2 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@yury-s ya está trabajando en esto.

Desde el 5/10/2026.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
55/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
typescript, wasm
Área
testing-qa

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.
Lenguaje dominante
TypeScript
Estrellas
100k
Forks
6.9k
Merge medio
16 h 8 min
PR fusionados (30 d)
281

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoft/playwright

Todos los issues de microsoft/playwright

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.