[Feature]: Add flag to update reference screenshots from latest test results without re-running tests #34376
Open
Description
🚀 Feature Request
Current Behavior
To update reference screenshots after detecting UI changes, we need to:
- Run tests first time - differences are detected and stored in test-results folder
- 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:
- Take actual screenshots from test-results folder of the latest test run
- Update reference images using these screenshots
- 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.