test_that("suppress output", {
if (getRversion() >= "4.0.0") {
cnd <- NULL
tryCatch(
suppressMessages(cli_text("foo"), "cliMessage"),
message = function(cnd2) cnd <<- cnd2
)
expect_null(cnd)
}
mysuppress <- function(expr) {
withCallingHandlers(
expr,
cliMessage = function(msg) invokeRestart("muffleMessage")
)
}
cnd <- NULL
tryCatch(
mysuppress(cli_text("foo")),
message = function(cnd2) cnd <<- cnd2
)
expect_null(cnd)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.