testthat icon indicating copy to clipboard operation
testthat copied to clipboard

feature request: bulk delete X.new.md for snapshot changes

Open fh-mthomson opened this issue 1 year ago • 2 comments

If I make a silly mistake, then run tests, it can introduce N spurious changes to snapshot tests that I want to quickly "reset" in bulk.

For example, git status shows something like:

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        tests/testthat/_snaps/test_file_1.new.md
        tests/testthat/_snaps/test_file_2.new.md
....
        tests/testthat/_snaps/test_file_N.new.md

Normally, I'd do git restore . to get back to clean, but since they're untracked (net new files), I find myself doing either:

  1. Manually delete *.new.md files
  2. If N is large: lazily use git restore (risky) rm -rf tests/testthat/ && git restore .

AFAIK, snapshot_review() requires clicking "Skip" for each file. Is there another way to bulk ignore the proposed changes? E.g., a new snapshot_reset() operation?

thank you for the great snapshot testing tools - they've been a game-changer for testing user messaging, and more!

fh-mthomson avatar Jan 25 '24 00:01 fh-mthomson