Accessing files in inst during testing

I have a bunch of template Rmd files in a package:

inst/templates/t1.Rmd
inst/templates/t2.Rmd
# etc

To access them I would normally do

system.file("templates", "t1.Rmd", package = "Z", mustWork = TRUE)

However, when I want to access the files for testing, the file can't be found

  • It can be found running devtools::test()
  • But not using R CMD check

How do I access the file in a testthat framework?


I presume this devtools shim should solve the problem, but I can't get it to work.