tests/testthat/test-is_reproducible.R

test_that("isReproducible returns TRUE on test_json.Rmd", {
  rmd <- testthat::test_path("testdata", "test_json.Rmd")
  html <- testthat::test_path("testdata", "test_json.html")
  json <- testthat::test_path("testdata", ".repro_test_json.Rmd_somenumbers.json")

  if (file.exists(html)) file.remove(html)
  if (file.exists(json)) file.remove(json)

  on.exit({
    if (file.exists(html)) file.remove(html)
    if (file.exists(json)) file.remove(json)
  }, add = TRUE)

  # render once
  rmarkdown::render(input = rmd, quiet = TRUE)

  # render twice
  res <- reproducibleRchunks::isReproducible(rmd, engine="rmarkdown")
  expect_true(res)
})

Try the reproducibleRchunks package in your browser

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

reproducibleRchunks documentation built on Aug. 8, 2025, 6:38 p.m.