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"))
  }
})
r-lib/testthat documentation built on Feb. 18, 2024, 8:59 p.m.