expect_visual_equal_with_diff: Test for plot equality with 'diff' generation

View source: R/visual.R

expect_visual_equal_with_diffR Documentation

Test for plot equality with 'diff' generation

Description

This tinytest-compatible expectation compares two plots supplied as files (which should be png files) and returns visual difference in a plot file (for which the designated file has to be supplied).

The labels “old” (for the reference plot compared against), “new” (for the candidate plot, and “diff” can be set as value to the global option tinysnapshot_plot_diff_style. For example settings c("old", "new", "diff") shows all three, setting c("new", "diff") just these two. The default is to only show the ‘diff’ plot.

Usage

expect_visual_equal_with_diff(proposed, reference, difference, ...)

Arguments

proposed

Character value with filename of proposed solution, should be png

reference

Character value with filename of reference plot, should be png

difference

Character value with filename for difference plot (if plots differ)

...

Passes on to tinysnapshot::expect_equivalent_images()

Value

The tinytest result object where the diff attribute contains the suitable value that can be passed onto the JSON output, i.e. a character string beginning with "date:image/png;base64," followed with the base64 encoded file. The class attribute is set to c("ttvd", "tinytest") to signal that it is a 'visual diff' result.


ttdo documentation built on April 3, 2025, 11:51 p.m.