r2rtf
r2rtf copied to clipboard
Blank `Rplots.pdf` generated when running snapshot tests interactively from RStudio
To reproduce the issue:
usethis::create_package("zzz/")
usethis::use_testthat()
Run usethis::use_r("myfun")
and put this function into it:
#' @export
myfun <- function(path) {
head(datasets::iris) |>
r2rtf::rtf_body() |>
r2rtf::rtf_encode() |>
r2rtf::write_rtf(file = path)
}
Run usethis::use_test("myfun")
to create this test:
test_that("myfun snapshot", {
path <- tempfile(fileext = ".rtf")
myfun(path)
local_edition(3)
expect_snapshot_file(path, "myfun.rtf")
})
Run devtools::document()
and devtools::load_all()
.
Clicking the "Run Tests" button or the "Test" button in the Build panel in RStudio will generate a blank, redundant tests/testthat/Rplots.pdf
, while no such Rplots.pdf
is generated when running devtools::test()
or devtools::test_active_file()
in the R console.
Reproduced under macOS, Windows, and Posit Cloud.