-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Description
🚀 Feature Request
Scenario
I'm running visual regression tests in my pipeline with the --update-snapshots flag enabled, so screenshots are automatically updated and can be committed by the pipeline in case they change.
Problem
I would like to record a trace if a test case fails and updates its snapshot. However, since snapshot test cases don't technically fail with --update-snapshots enabled, Playwright doesn't record any traces when using the retain-on-failure mode.
As far as I'm aware my only options at the moment are to either:
A. Use the trace mode on, which isn't ideal since then every test case always records a trace.
B. Run my tests first without the --update-snapshots flag to get a trace for failing test cases, and then run them again with the flag enabled to get updated screenshots. This approach would be better than always recording traces, but it adds unnecessary complexity to the pipeline IMO.
Feature Proposal
My proposal to solve this would be to either:
A. Adapt the retain-on-failure trace mode to also count updating a snapshot as a failure.
B. Introduce a new trace mode, e.g. retain-on-snapshot-change for this specific use case.
Example
In playwright.config.ts:
use: {
trace: {
mode: 'retain-on-snapshot-change',
}
}Motivation
I think this would be a valid addition to Playwright, as it makes it simpler to set up snapshots tests without requiring complicated workarounds to also leverage tracing.