microsoft / microsoft/playwright

[Feature]: Add flag to update reference screenshots from latest test results without re-running tests

Open
#34,376 4 comments 2 reactions 0 assignees View on GitHub
feature-visual-regression-testing
Dominant language
TypeScript
Stars
96.3k
Forks
6.5k
Avg merge
1d 6h
Merged PRs (30d)
180

Description

### 🚀 Feature Request

### Current Behavior
To update reference screenshots after detecting UI changes, we need to:
1. Run tests first time - differences are detected and stored in test-results folder
2. Run tests second time with -u or --update-snapshots flag to update reference images
This means running the same tests twice, which is time-consuming.

### Proposed Solution
Add new flag --update-snapshots-latest-run that would:
1. Take actual screenshots from test-results folder of the latest test run
2. Update reference images using these screenshots
3. Do this without running tests again

### Example

```
bash# First run - detect differences
$ npm test

# Update references using screenshots from test-results folder
$ npm test --update-snapshots-latest-run
```

### Motivation

### Benefits
- Eliminates need for second test run
- Saves significant time on reference image updates
- Uses already existing screenshots from test-results folder
- Perfect for updating multiple screenshots after intended UI changes

### Technical Details
- The flag would look for latest screenshots in test-results directory
- Only failed screenshot comparisons would be updated
- No test execution required

Would you consider implementing this optimization? It would significantly improve the workflow when updating reference images.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the existing --update-snapshots option and how screenshots are stored in the test-results folder. Confirm how the latest run and failed comparisons should be selected, then add coverage showing references update without executing the tests again.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.