save_csv <- function(x) {
path <- tempfile(fileext = ".csv")
readr::write_csv(x, path)
path
}
expect_snapshot_data <- function(x, name, digits = 6) {
fun <- function(x) signif(x, digits = digits)
x <- dplyr::mutate(x, dplyr::across(dplyr::where(is.numeric), fun))
path <- save_csv(x)
testthat::expect_snapshot_file(
path,
paste0(name, ".csv"),
compare = testthat::compare_file_text)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.