Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Detect and Remove Obsolete Snapshots in Playwright #34775

Open
Qambar opened this issue Feb 13, 2025 · 1 comment
Open

[Feature]: Detect and Remove Obsolete Snapshots in Playwright #34775

Qambar opened this issue Feb 13, 2025 · 1 comment

Comments

@Qambar
Copy link

Qambar commented Feb 13, 2025

🚀 Feature Request

🚀 Feature Request: Detect and Remove Obsolete Snapshots in Playwright

Problem Statement

When using Playwright's Visual Regression Testing (toHaveScreenshot()), old or unused snapshot files accumulate over time. Currently, Playwright does not have a built-in way to:

  • Detect obsolete snapshots that are no longer referenced in tests.
  • Automatically delete these stale snapshots.

This leads to bloated repositories with unnecessary files, making it harder to manage snapshot updates efficiently.


Proposed Solution

Introduce a new CLI flag, such as:

npx playwright test --cleanup-snapshots

Example

Currently, developers update snapshots using:

npx playwright test --update-snapshots

However, this only updates existing snapshots and does not remove obsolete ones.

With the proposed feature, developers could run:

npx playwright test --cleanup-snapshots

Motivation

Over time, as tests are renamed or removed, unused snapshot files accumulate in __snapshots__/, leading to:

  • Wasted storage: Unused snapshots bloat the repository.
  • Slower updates: The more snapshots exist, the longer updates take.
  • Harder maintenance: Developers have to manually clean snapshots.

By introducing a --cleanup-snapshots flag, Playwright can automatically remove outdated snapshots, improving efficiency and test maintainability.

This feature aligns with Playwright’s goal of providing developer-friendly and scalable test automation. 🚀

@QIAOYANGvg
Copy link

I also strongly agree with adding this feature. Screenshots have indeed become more and more difficult to maintain over time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants