Skip to content

[Question] CLI tool to interactively review & update snapshot test results #14883

Closed as not planned

Description

Hey, at one of my projects there was a custom CLI tool that allowed interactive reviewing snapshot test results and updating the baseline images/texts. As far as I know there is something similar available for snapshot tests in Jest (Interactive Snapshot Mode).

What I mean is a CLI that will go through the test results one by one and give options to open files for review (expected, actual, diff), skip, or update the baseline (copy the actual result to the snapshots).

Is something like this already available in playwright?
And if there isn't - do you think it could be valuable to playwright users? If yes, then maybe I could write some proof of concept and create a PR.

Activity

  1. dgozman commented on Jun 15, 2022

    @dgozman
    Collaborator

    Piotr Gajowniczek (@piotrgajow) There is no such tool yet. You can manually go over failed screenshots in the html report, but that's it right now. We were thinking along these lines, so definitely such a tool would make sense.

    If you are willing to contribute, make sure to check your idea/design/thoughts with maintainers first, to make sure your contribution will be merged.

  2. dimkin-eu commented on Jun 16, 2022

    @dimkin-eu
    Contributor

    here comes the fun and sad part about naming - PW's snapshots actually are screenshots, but jest's snapshots are HTML, so one without any hassle can locally check diff, but for screens in CI - they could be different from local ones.

    GitLab (and for sure any other source control with UI ) shows the diff for pics nicely, but

    • there is no heatmap ( for subtle changes )
    • there is no easy way to revert/reject some screens

    still, this is a task not for PW, I think but for source control, as I'm not sure how PW's report or something could interact with source code ( but I'd like to see such a thing too :) )

  3. piotrgajow commented on Jun 20, 2022

    @piotrgajow
    Author

    Dmitry Gozman (@dgozman) How should I check the idea with maintainers first? Are there any steps to be followed in such case?

    Dmitry Munda (@dimkin-eu) What I meant was to have a CLI for the developer to help determine if changes detected for a snapshot were intended (and the snapshot should be updated) or not. And the tool I am thinking about relies on test results that PW currently creates (i.e. actual, expected and diff images). Nothing related to repositories/pipelines.

  4. frank-swp commented on Oct 6, 2022

    @frank-swp

    A approve Screenshot button in the test results html view might be easier to use than a new CLI tool, because the test results are usually already open. This was my idea in #17801.

  5. andrehil commented on May 24, 2023

    @andrehil

    Just wondering if there's any motion regarding this issue.
    I like frank-swp's idea very much.

  6. madjam002 commented on Jun 1, 2023

    @madjam002

    I feel like the new recently launched UI mode would be a great place to put something like this, in Playwright 1.34.0 you can already see the screenshot comparison in the attachments tab in the UI, so having an approve button right there where you can step through the test while updating snapshots would be great.

  7. nnson0310 commented on Jun 2, 2023

    @nnson0310

    I want this features too. Compare with BackstopJS report and feel very envious. The html report of BackstopJS is excellent although the tool itself is not very stable to run.

  8. weilbith commented on Jul 11, 2023

    @weilbith

    Just another up-vote for this feature. Would help the developer experience so much!

  9. neongreen commented on May 2, 2024

    @neongreen

    In the meantime, has anyone found any third-party tools that can help with the approval workflow?

    Right now I am doing "open visual diff in vscode" -> "cross eyes to check the pics are identical" -> "stage changes" -> "go to the next file". But it's not the best workflow.

  10. weilbith commented on May 8, 2024

    @weilbith

    Emily (@neongreen) unfortunately not. I tried to do some awkward integration with jest-image-snapshot (not do take snapshots, but for the comparison + UI part). But unfortunately their code is tightly coupled to the Jest runtime. I looked into their code and I don't see any chance to break this relationship that checks if Jest is used as test runner. 😕

  11. neongreen commented on May 8, 2024

    @neongreen

    I just wrote a script that goes through git diff and generates visual diffs using the same logic as playwright

    if there’s interest I can post the script

  12. weilbith commented on May 8, 2024

    @weilbith

    For me, the DX is key. Developers should not get desensibilized and get annoyed by failing visual regression tests without a good way for them to verify what has changed to take a solid decision to accept a new baseline or not. Therefore it must be easy and intuitive to use without developers just starting to blindly confirm, just because they get annoyed.
    And it should work properly in a CI pipeline too.

  13. karlhorky commented on May 8, 2026

    @karlhorky
    Contributor

    2026 updated workflow option (using AI), now that AI CLIs are widespread:

    a CLI that will go through the test results one by one and give options to open files for review (expected, actual, diff), skip, or update the baseline (copy the actual result to the snapshots)

    This behavior can now be prompted for on the command line using Codex CLI or OpenCode or Gemini CLI or GitHub Copilot CLI or Qwen Code or Kimi Code or Claude Code.

    Depending on the workflow that you're looking for, something like this may work for you to open the snapshots in your default image viewer on your computer and then either update the baseline or skip it (adapted from the issue description):

    go through the failing snapshots in the test results one by one and prompt me to choose one of the following three options:

    1. open the files for me to review in my default image viewer (expected, actual, diff) - if I choose this option, re-prompt me with the three options
    2. update the baseline (copy the actual result to the snapshots)
    3. skip

    We have also used a similar prompt to update snapshots from failing CI runs in GitHub Actions (which uses Linux, so the snapshots have slightly different rendering than our local macOS machines). We do this by pasting in the URL of a failing CI run on GitHub Actions:

    download the artifact from and unzip it in /tmp. go through the failing snapshots in the test results one by one and prompt me to choose one of the following three options:

    1. open the files for me to review in my default image viewer (expected, actual, diff) - if I choose this option, re-prompt me with the three options
    2. update the baseline (copy the actual result to the snapshots)
    3. skip

    An example URL of a failing CI run on GitHub Actions would look like this:


    I also added these prompts to my guide Playwright Tricks:

  14. theghost1980 commented on Oct 27, 2026

    @theghost1980

    Since this was closed as not planned, I built an open-source CLI for exactly this workflow, and it's now in beta: rebaseline.

    git clone -b try-rebaseline https://github.com/theghost1980/rebaseline-demo
    cd rebaseline-demo
    npx rebaseline@beta review --report sample-report
    

    npx rebaseline@beta review opens your Playwright HTML report in a local page (expected / actual / diff, a slider, keyboard shortcuts) and writes only the screenshots you accept to their baseline files. npx rebaseline@beta pull does the same with the report of your last failed GitHub Actions run, so you can update -linux.png baselines from a Mac or Windows machine. It finds each baseline by content, so any snapshotPathTemplate works.

    There's a demo repository to try it in a minute. I'm the author; feedback, especially when it fails, is very welcome in the beta feedback discussion.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions