This is good when not-interactive, but when run in an interactive session (like in RStudio or Positron) it would be a better UX to prompt the user to install webshot.
Suggest using rlang::check_installed("webshot") instead of requireNamespace("webshot") so the user is prompted to install if in an interactive session.
Here is a reprex:
if (rlang::is_installed("webshot")) {
stop("webshot is installed, uninstall it before testing")
}
temp_file <- tempfile()
on.exit({unlink(temp_file})
leaflet::leaflet() |>
mapview::mapshot(file = temp_file, selfcontained = FALSE)