Conditionally stop testing a tinytest test file if running on CI. This is determined by checking if the environment variable “CI” set and is a non-FALSE value

skip_on_ci()

exit_on_ci()

Value

If called within a tinytest test running on CI, triggers an exit condition; otherwise, either a string saying “On CI” or NULL invisibly

“Skip” vs “Exit”

tinyexpect provides both “skip_” and “exit_” versions of “stop testing” functions due to the different philosophies of tinytest and testthat; in testthat, tests are encapsulated by test_that() to create smaller testing units within a single test file. As such, if a series of tests need to be passed over for some reason, it makes sense to “skip” a test_that() block and move on to the next block

tinytest, however, treats each test file as a testing unit. Each file in inst/tinytest is equivalent to a testthat test_that() block; as such, if a series of tests need to be passed over for some reason, it makes sense to “exit” a test file and move on to the next file in inst/tinytest

In order to provide compatibility with users transitioning from testthat to tinytest, and to provide continuity with the tinytest philosophy, tinyexpect provides both skip_- and exit_- prefixed “stop testing” functions that work identically to one another

Examples

withr::with_envvar(c(CI = "true"), skip_on_ci())
#> [1] "On CI"