diff --git a/R/write_kbl.R b/R/write_kbl.R index a353039..8b97307 100644 --- a/R/write_kbl.R +++ b/R/write_kbl.R @@ -97,8 +97,12 @@ write_kbl <- if (device %in% c("html", "pdf", "png", "jpeg")) { browser_path <- check_chromium_browser() if (!is.null(browser_path)) { - # Set the path to the browser - options(chromote.browser_path = browser_path) + if (file.exists(browser_path)) { + # Set the path to the browser + options(chromote.browser_path = browser_path) + } else { + stop("The detected browser path does not exist: ", browser_path) + } } else { msg <- paste0("A Chromium-based browser (e.g., Google Chrome, ", "Chromium, Microsoft Edge, or Brave) is required on your system ", @@ -150,6 +154,5 @@ check_chromium_browser <- function() { if (chrome_env != "" && file.exists(chrome_env)) { return(chrome_env) } - return(NULL) } diff --git a/tests/testthat.R b/tests/testthat.R index 2ee8d98..40fceb2 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -22,10 +22,11 @@ cleanup_crashpad <- function() { testthat::setup(cleanup_crashpad) testthat::teardown(cleanup_crashpad) -# Function to check if Chromium is available +# Function to check if Chromium is +# available and can be initialized is_chromium_available <- function() { tryCatch({ - chromote::find_chrome() + chromote::Chromote$new() TRUE }, error = function(e) { FALSE