playwright icon indicating copy to clipboard operation
playwright copied to clipboard

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

Open mag09 opened this issue 1 year ago • 0 comments

🚀 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.

mag09 avatar Jan 17 '25 13:01 mag09