Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fh-mthomson opened this issue Jan 25, 2024 · 2 comments
Open

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

fh-mthomson opened this issue Jan 25, 2024 · 2 comments

Comments

@fh-mthomson
Copy link

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!

@hadley
Copy link
Member

hadley commented Feb 13, 2024

How about git clean -f?

@fh-mthomson
Copy link
Author

Mhm that should work, but is (1) slightly riskier (example below) and (2) more git jargon words to remember (instead of testthat functions which are trivial to call given great naming!)

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

git clean -f drops both .R (wanted, in progress) and .new.md (unwanted), which is not desirable.

Again, totally workable via git, mostly sharing as a "maybe one day" idea :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants