Skip to content

Commit 26787b5

Browse files
authored
Add variant support (#147)
1 parent cfed3fb commit 26787b5

File tree

6 files changed

+94
-3
lines changed

6 files changed

+94
-3
lines changed

NEWS.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# vdiffr (development version)
22

3+
* Added support for snapshot variants (#125).
4+
5+
36
# vdiffr 1.0.7
47

58
* Revert back to C++11 to work around a GCC issue (#137).
@@ -95,7 +98,7 @@ a bugfix.
9598
Font sizes are now precomputed for the first 50000 unicode points.
9699
This allows deterministic computation of text box extents without
97100
the freetype and harfbuzz dependencies.
98-
101+
99102
Note: The main visible change of this update is that points now look
100103
smaller. Points generated with the previous SVG engine were too large.
101104

R/expect-doppelganger.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
#' Internally, this argument is passed to
5555
#' [testthat::expect_snapshot_file()].
5656
#'
57+
#' @inheritParams testthat::expect_snapshot_file
5758
#'
5859
#' @section Debugging:
5960
#' It is sometimes difficult to understand the cause of a failure.
@@ -96,7 +97,8 @@ expect_doppelganger <- function(title,
9697
path = deprecated(),
9798
...,
9899
writer = write_svg,
99-
cran = FALSE) {
100+
cran = FALSE,
101+
variant = NULL) {
100102
testthat::local_edition(3)
101103

102104
fig_name <- str_standardise(title)
@@ -135,6 +137,7 @@ expect_doppelganger <- function(title,
135137
testcase,
136138
name = file,
137139
cran = cran,
140+
variant = variant,
138141
compare = testthat::compare_file_text
139142
),
140143
expectation_failure = function(cnd) {

man/expect_doppelganger.Rd

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 37 additions & 0 deletions
Loading
Lines changed: 35 additions & 0 deletions
Loading

tests/testthat/test-expect-doppelganger.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,10 @@ test_that("skips and unexpected errors reset snapshots (r-lib/testthat#1393)", {
8282
expect_true(file.exists("test-snapshot/_snaps/snapshot/error-resets-snapshots.svg"))
8383
expect_true(file.exists("test-snapshot/_snaps/snapshot/skip-resets-snapshots.svg"))
8484
})
85+
86+
test_that("`expect_doppelganger()` supports variants", {
87+
p1 <- ggplot2::ggplot()
88+
p2 <- ggplot2::ggplot() + ggplot2::geom_histogram()
89+
expect_doppelganger("variant", p1, variant = "foo")
90+
expect_doppelganger("variant", p2, variant = "bar")
91+
})

0 commit comments

Comments
 (0)