# Mocks `requireNamespace` to return `FALSE` for
# provided dependency package "pkg" to test that
# error occurs when it's not installed.
expect_package_error <- function(pkg, code, msg) {
testthat::with_mocked_bindings({
testthat::expect_error(code, paste0("`", pkg, "` must be installed"))
},
requireNamespace = function(package, ...) package != pkg,
.package = "base"
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.