[Feature]: Support compression effort option for WebP screenshots and visual regression
维护者通常 1 天内回复
@yury-s 已经在做这个了。
开始于 2026年10月5日。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 55/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- typescript, wasm
- 领域
- testing-qa
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
🚀 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: 0andeffort: 6produce 100% pixel-identical RGBA buffers.effort: 0encodes quickly with minimal CPU usage, making it suitable for test-run screenshots and comparisons.effort: 4–6can 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:
- Store smaller WebP baseline snapshots in their repositories and reduce repository bloat.
- Keep CI runs fast by generating comparison screenshots with
effort: 0while validating against high-effort baselines with zero pixel difference.
- 主要语言
- TypeScript
- 星标
- 100k
- 派生
- 6.9k
- 平均合并
- 16 小时 8 分钟
- 30 天内合并 PR
- 281
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/playwright 的其他 Issue
-
[MCP]: page snapshots in .playwright-mcp/ are not git-ignored (.playwright-cli/ is, since #42318)未关闭
难度 2/5 1-3 小时 新手友好度 62/100
microsoft/playwright#44289 ·
维护者通常 1 天内回复
-
agent-triage-done
难度 2/5 1-3 小时 新手友好度 72/100
microsoft/playwright#44264 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 12/100
microsoft/playwright#44290 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 22/100
microsoft/playwright#44288 ·
维护者通常 1 天内回复
-
[Bug]: page.goto never returns for a load started as a newer service worker takes over (Chromium)未关闭
难度 5/5 一周以上 新手友好度 12/100
microsoft/playwright#44287 ·
维护者通常 1 天内回复
查看 microsoft/playwright 的全部 Issue
相似的 Issue
-
The manager preset saves launch definitions without the required file and digest pair可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭bug
难度 2/5 1-3 小时 新手友好度 80/100
维护者通常 1 天内回复