-
Notifications
You must be signed in to change notification settings - Fork 340
Description
I'm working on a project that's using snapshot tests. For confidentiality reasons, we can't commit the snapshots to the main GitHub repository as the documentation recommends. Instead, we've set up another repo (testdata), hosted on an on-premises server. This repo should include test inputs and CSV-formatted test outputs in addition to the snapshot files themselves. I figured the easiest way to set this up would be to put the _snaps directory inside the local checkout of testdata. But I couldn't see a way to configure the snapshot directory; it seems to be hardcoded to tests/testthat/_snaps (at least in the publicly facing functions; the internals all seem to let you pass in a snapshot directory).
Is a configuration setting to change the snapshot directory something that can be added? Or is there a reasonable workaround for this use case that fits with the spirit of testthat?
Other options I've thought of/tried:
- Just using
tests/testthat/_snapsas the local checkout oftestdata. Doesn't work because testthat clears out the snapshot directory after running the tests, obliterating all the test inputs and CSV-formatted outputs. - Making
tests/testthatthe local checkout oftestdata. Doesn't work because now the tests themselves get caught up in thetestdatarepo, and I can't ignore them without also ignoring them in the main repo. - Automatically copying the files back and forth. This seems to have timing issues; I can't see how to automatically copy existing snapshots from
testdatabefore they get locked in as the reference snapshots, and copying new snapshots back intotestdatashould really happen at the same time assnapshot_accept, so we'd have to use our own function instead ofsnapshot_accept. - Replacing
_snapswith a symlink totestdata/_snaps. Unfortunately, we're stuck on Windows workstations that require administrator permission to make symlinks. I don't want to add "go find an administrator" as a step in the setup procedure, there are enough barriers to adopting a testing workflow as it is.
In any case, all of these seem unnecessarily convoluted compared to just letting me choose where _snaps goes.