Skip to content

Commit abbd07d

Browse files
authored
More documentation on snapshot cleanup (#2194)
Fixes #1615
1 parent e4b8747 commit abbd07d

File tree

7 files changed

+38
-6
lines changed

7 files changed

+38
-6
lines changed

β€ŽR/snapshot-file.Rβ€Ž

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,14 @@
3131
#' `compare_file_text()` compares lines-by-line, ignoring
3232
#' the difference between Windows and Mac/Linux line endings.
3333
#' @param variant If not-`NULL`, results will be saved in
34-
#' `_snaps/{variant}/{test}/{name}.{ext}`. This allows you to create
34+
#' `_snaps/{variant}/{test}/{name}`. This allows you to create
3535
#' different snapshots for different scenarios, like different operating
3636
#' systems or different R versions.
37+
#'
38+
#' Note that there's no way to declare all possible variants up front which
39+
#' means that as soon as you start using variants, you are responsible for
40+
#' deleting snapshot variants that are no longer used. (testthat will still
41+
#' delete all variants if you delete the test.)
3742
#' @inheritParams expect_snapshot
3843
#'
3944
#' @section Announcing snapshots:

β€ŽR/snapshot.Rβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@
5353
#' carefully think about your testing strategy to ensure that all important
5454
#' variants are covered by automated tests, and ensure that you have a way
5555
#' to get snapshot changes out of your CI system and back into the repo.
56+
#'
57+
#' Note that there's no way to declare all possible variants up front which
58+
#' means that as soon as you start using variants, you are responsible for
59+
#' deleting snapshot variants that are no longer used. (testthat will still
60+
#' delete all variants if you delete the test.)
5661
#' @param transform Optionally, a function to scrub sensitive or stochastic
5762
#' text from the output. Should take a character vector of lines as input
5863
#' and return a modified character vector as output.

β€Žman/expect_snapshot.Rdβ€Ž

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žman/expect_snapshot_file.Rdβ€Ž

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žman/expect_snapshot_output.Rdβ€Ž

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žman/expect_snapshot_value.Rdβ€Ž

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žvignettes/snapshotting.Rmdβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ test_that("bullets", {
128128
If this is a deliberate change, you can follow the advice in the message and update the snapshots for that file by running `snapshot_accept("pizza")`; otherwise you can fix the bug and your tests will pass once more.
129129
(You can also accept snapshot for all files with `snapshot_accept()`).
130130

131+
If you delete the test, the corresponding snapshot will be removed the next time you run the tests. If you delete all snapshots in the file, the entire snapshot file will be deleted the next time you run all the tests.
132+
131133
### Snapshot format
132134

133135
Snapshots are recorded using a subset of markdown.

0 commit comments

Comments
Β (0)