diff --git a/tests/testthat/_snaps/app-image/screen1-001.png b/tests/testthat/_snaps/app-image/screen1-001.png index c1e7fa73..17608e01 100644 Binary files a/tests/testthat/_snaps/app-image/screen1-001.png and b/tests/testthat/_snaps/app-image/screen1-001.png differ diff --git a/tests/testthat/_snaps/app-image/screen2-001.png b/tests/testthat/_snaps/app-image/screen2-001.png index c1e7fa73..17608e01 100644 Binary files a/tests/testthat/_snaps/app-image/screen2-001.png and b/tests/testthat/_snaps/app-image/screen2-001.png differ diff --git a/tests/testthat/helper-skip-if.R b/tests/testthat/helper-skip-if.R index 810be819..9b55c93d 100644 --- a/tests/testthat/helper-skip-if.R +++ b/tests/testthat/helper-skip-if.R @@ -9,3 +9,11 @@ skip_if_no_local_apps <- function() { skip(paste0("Local app test folder has been ignored")) } } + +skip_if_chrome_older_than <- function(app, major) { + product <- app$get_chromote_session()$Browser$getVersion()$product + version <- as.integer(sub("^[^/]*/([0-9]+).*", "\\1", product)) + if (version < major) { + skip(paste0("Chrome ", version, " is older than ", major)) + } +} diff --git a/tests/testthat/test-app-image.R b/tests/testthat/test-app-image.R index 35786f25..edd1ced7 100644 --- a/tests/testthat/test-app-image.R +++ b/tests/testthat/test-app-image.R @@ -123,6 +123,8 @@ test_that("screenshot can be expected", { # across platforms, but chromote/Chrome produce non-deterministic PNG bytes # (zlib compression differs by environment). Byte comparison (threshold = # NULL) fails on those identical-but-re-encoded images. + # Chrome < 156 crops the 100px tall `#green` box to 99px. + skip_if_chrome_older_than(app, 156) app$expect_screenshot(threshold = 10) }) test_that("screenshot can be expected", { @@ -136,6 +138,7 @@ test_that("screenshot can be expected", { # This directly calls `app$get_screenshot()`, no need for extra testing # Should take a picture of `#green`, not app # See note above re: pixel `threshold` vs non-deterministic PNG bytes. + skip_if_chrome_older_than(app, 156) app$expect_screenshot( screenshot_args = list(selector = "#green"), threshold = 10