The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
The goal of snapr is to provide convenient snapshot testing functions for R packages:
expect_snapshot_data() - for data.frames (adapted with permission
from the {ssdtools}
package)expect_snapshot_object() - generalizes
expect_snapshot_data() for use with any R objectYou can install the released version of snapr from CRAN with:
install.packages("snapr")You can install the development version of snapr from GitHub with:
# install.packages("pak")
pak::pak("d-morrison/snapr")snapr works best with the d-morrison/diffviewer
fork of diffviewer,
which wraps diffobj to
provide rich, visual diffs when reviewing RDS snapshots via
testthat::snapshot_review(). Install it with:
pak::pak("d-morrison/diffviewer")library(snapr)
# In a testthat test file:
test_that("iris data is correct", {
expect_snapshot_data(iris[1:5, ], name = "iris_sample")
})library(snapr)
# Snapshot a list (RDS format by default - works for any R object)
test_that("config object is correct", {
config <- list(
name = "my_app",
version = "1.0.0",
settings = list(debug = TRUE, timeout = 30)
)
expect_snapshot_object(config, name = "config")
})
# Snapshot with JSON format for human-readable diffs
test_that("simple data is correct", {
data <- list(x = 1:5, y = letters[1:5])
expect_snapshot_object(data, name = "simple_data", writer = save_json)
})
# Snapshot a model (use RDS for complex objects)
test_that("model structure is correct", {
model <- lm(mpg ~ wt, data = mtcars)
expect_snapshot_object(model, name = "model")
})These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.