Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified tests/testthat/_snaps/app-image/screen1-001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testthat/_snaps/app-image/screen2-001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions tests/testthat/helper-skip-if.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
3 changes: 3 additions & 0 deletions tests/testthat/test-app-image.R
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand All @@ -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
Expand Down
Loading