Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion R/snapshot-file.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@
#' `compare_file_text()` compares lines-by-line, ignoring
#' the difference between Windows and Mac/Linux line endings.
#' @param variant If not-`NULL`, results will be saved in
#' `_snaps/{variant}/{test}/{name}.{ext}`. This allows you to create
#' `_snaps/{variant}/{test}/{name}`. This allows you to create
#' different snapshots for different scenarios, like different operating
#' systems or different R versions.
#'
#' Note that there's no way to declare all possible variants up front which
#' means that as soon as you start using variants, you are responsible for
#' deleting snapshot variants that are no longer used. (testthat will still
#' delete all variants if you delete the test.)
#' @inheritParams expect_snapshot
#'
#' @section Announcing snapshots:
Expand Down
5 changes: 5 additions & 0 deletions R/snapshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
#' carefully think about your testing strategy to ensure that all important
#' variants are covered by automated tests, and ensure that you have a way
#' to get snapshot changes out of your CI system and back into the repo.
#'
#' Note that there's no way to declare all possible variants up front which
#' means that as soon as you start using variants, you are responsible for
#' deleting snapshot variants that are no longer used. (testthat will still
#' delete all variants if you delete the test.)
#' @param transform Optionally, a function to scrub sensitive or stochastic
#' text from the output. Should take a character vector of lines as input
#' and return a modified character vector as output.
Expand Down
7 changes: 6 additions & 1 deletion man/expect_snapshot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions man/expect_snapshot_file.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion man/expect_snapshot_output.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion man/expect_snapshot_value.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vignettes/snapshotting.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ test_that("bullets", {
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.
(You can also accept snapshot for all files with `snapshot_accept()`).

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.

### Snapshot format

Snapshots are recorded using a subset of markdown.
Expand Down
Loading