I'm finishing writing tests and documentation for a package that generates R package citations on the fly in R Markdown/Quarto.
For example, the following .Rmd
/.qmd
---
bibliography: foo.bib
---
We created maps using `r bar::fun(ggplot2)`.
# References
will produce
We created maps using the 'ggplot2' package version 3.4.4 (Wickham 2016).
References
Wickham, Hadley. 2016. *Ggplot2: Elegant Graphics for Data Analysis*.
Springer-Verlag New York. <https://ggplot2.tidyverse.org>.
I'm using a few snapshot tests and use similar examples in the README
and pkgdown documentation.
The problem is that the tests/examples will change whenever I update the package used in the examples/tests. By 'examples' I mean examples in the README
+ pkgdown vignettes, not functions' help file.
What are the solutions to work around this? I only need to use one package for all my examples and tests so I'd prefer something that isn't overly complicated. Ideally, I'd like to have no extra dependencies for this to keep my package as minimal as possible.
testthat::expect_snapshot(transform =)
works fine for simple cases when testing but is of no help for the examples in the documentation. It's also not super convenient when snapshot testing bibTex citations.
I was thinking of using renv but I've no idea how to use it for that purpose inside a package, supposing that's actually possible. There's a vignette about package development but don't find it very helpful.
Another possibility might be to create a temporary package locally but that's probably overkill.
Any hints or recommendations?