From 854127384606b498a28559ae1fcb0a52aa6a9d5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Wed, 18 Dec 2024 15:45:30 +0000 Subject: [PATCH 1/2] feat: TealAppDriver skips tests when shinytest2 or rvest are not installed --- R/TealAppDriver.R | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/R/TealAppDriver.R b/R/TealAppDriver.R index 70eb0da6e9..e5a1f5b9ac 100644 --- a/R/TealAppDriver.R +++ b/R/TealAppDriver.R @@ -10,12 +10,15 @@ TealAppDriver <- R6::R6Class( # nolint: object_name. "TealAppDriver", inherit = { - if (!requireNamespace("shinytest2", quietly = TRUE)) { - stop("Please install 'shinytest2' package to use this class.") - } - if (!requireNamespace("rvest", quietly = TRUE)) { - stop("Please install 'rvest' package to use this class.") - } + lapply(c("shinytest2", "rvest"), function(.x, use_testthat) { + if (!requireNamespace(.x, quietly = TRUE)) { + if (use_testthat) { + testthat::skip(sprintf("%s is not installed", .x)) + } else { + stop("Please install '", .x, "' package to use this class.", call. = FALSE) + } + } + }, use_testthat = requireNamespace("testthat", quietly = TRUE) && testthat::is_testing()) shinytest2::AppDriver }, # public methods ---- From 21bc01051ae4337d234f2fc2ec8a70a45ec20dd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Thu, 19 Dec 2024 12:40:35 +0000 Subject: [PATCH 2/2] feat: also check that testthat is installed --- R/TealAppDriver.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/TealAppDriver.R b/R/TealAppDriver.R index e5a1f5b9ac..f170e515a7 100644 --- a/R/TealAppDriver.R +++ b/R/TealAppDriver.R @@ -10,7 +10,7 @@ TealAppDriver <- R6::R6Class( # nolint: object_name. "TealAppDriver", inherit = { - lapply(c("shinytest2", "rvest"), function(.x, use_testthat) { + lapply(c("testthat", "shinytest2", "rvest"), function(.x, use_testthat) { if (!requireNamespace(.x, quietly = TRUE)) { if (use_testthat) { testthat::skip(sprintf("%s is not installed", .x))