tests/testthat/test-snapshot/test-snapshot.R

test_that("errors reset snapshots", {
  if (nzchar(Sys.getenv("TESTTHAT_REGENERATE_SNAPS"))) {
    expect_snapshot(print(1))
  } else {
    expect_snapshot(stop("failing"))
  }
})

test_that("skips reset snapshots", {
  if (nzchar(Sys.getenv("TESTTHAT_REGENERATE_SNAPS"))) {
    expect_snapshot(print(1))
  } else {
    expect_snapshot(skip("skipping"))
  }
})

Try the testthat package in your browser

Any scripts or data that you put into this service are public.

testthat documentation built on Jan. 21, 2022, 1:10 a.m.