Testthat: cleanup `tests/testthat/_snaps` if there are no snapshots

Created on 15 Sep 2020  Â·  4Comments  Â·  Source: r-lib/testthat

The devel version seems to be leaving an empty _snaps folder if there are no snapshots. This is exposed during package build, so it would be nice to avoid if possible.

e.g.

* checking for empty or unneeded directories
Removed empty directory ‘usethis/tests/testthat/_snaps’
bug snapshot

All 4 comments

Is there a way to keep the _snaps folder even if there are no snapshots? I have saved some .Rdata in that directory and plan to use them in test files. The reason is that those are simulated data, and takes so long if running in test scripts.

@ashirazist the _snaps directory is "owned" by testthat. You should not put your own data there.

@hadley Thanks for reminding that. I know that, but I cannot figure out a place to put the data that's used in test files. Do you suggest anything?

You can put it anywhere else in tests/testthat. Best not to start the directory and file names with an underscore. I like to put them in fixtures.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lc0 picture lc0  Â·  8Comments

richierocks picture richierocks  Â·  7Comments

hadley picture hadley  Â·  5Comments

unDocUMeantIt picture unDocUMeantIt  Â·  11Comments

BroVic picture BroVic  Â·  3Comments