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

Đang mở
#43,045 2 bình luận 2 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@yury-s đang làm issue này rồi.

Từ ngày 5/10/2026.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
55/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript, wasm
Lĩnh vực
testing-qa

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
TypeScript
Star
100k
Fork
6.9k
Merge trung bình
16 giờ 8 phút
Pull request đã merge (30 ngày)
281

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/playwright

Tất cả issue của microsoft/playwright

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.