tests/testthat/test-test-state.R

test_that("set_state_inspector() verifies its inputs", {
  expect_snapshot(set_state_inspector(function(x) 123), error = TRUE)
})

test_that("can detect state changes", {
  local_options(x = NULL)
  set_state_inspector(function() list(x = getOption("x")))
  withr::defer(set_state_inspector(NULL))

  expect_snapshot_reporter(CheckReporter$new(), test_path("reporters/state-change.R"))
})

Try the testthat package in your browser

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

testthat documentation built on Oct. 6, 2023, 5:10 p.m.