expect_snapshot_plot {tinysnapshot} | R Documentation |
Test if the new plot matches a target (snapshot) plot
Description
This expectation can be used with tinytest
to check if the new plot matches
a target plot.
When the expectation is checked for the first time, the expectation fails and
a reference plot is saved to the inst/tinytest/_tinysnapshot
folder.
When the expectation fails, the reference plot, the new plot, and a diff are
saved to the inst/tinytest/label
folder. Call the review()
function to compare.
To update a snapshot, delete the reference file from the _tinysnapshot
folder and run the test suite again.
See the package README file or website for detailed examples.
Usage
expect_snapshot_plot(
current,
label,
width = getOption("tinysnapshot_width", default = NULL),
height = getOption("tinysnapshot_height", default = NULL),
tol = getOption("tinysnapshot_tol", default = 0),
metric = getOption("tinysnapshot_metric", default = "AE"),
fuzz = getOption("tinysnapshot_fuzz", default = 0),
device = getOption("tinysnapshot_device", default = "svg"),
device_args = getOption("tinysnapshot_device_args", default = list()),
os = getOption("tinysnapshot_os", default = Sys.info()["sysname"])
)
Arguments
current |
an object of class |
label |
a string to identify the snapshot (alpha-numeric, hyphens, or underscores). Each plot in the test suite must have a unique label. |
width |
of the snapshot. PNG default: 480 pixels. SVG default: 7 inches. |
height |
of the snapshot. PNG default: 480 pixels. SVG default: 7 inches. |
tol |
distance estimates larger than this threshold will trigger a test failure. Scale depends on the |
metric |
string with a metric from |
fuzz |
relative color distance between 0 and 100 to be considered similar. |
device |
"svg", "png", "ragg" or "svglite" |
device_args |
list of arguments to pass to the device call (e.g., |
os |
character vector of operating systems on which the test should be run (e.g., "Windows", "Linux", "Darwin"). Tests are skipped when no element of the vector matches the output of: |
Value
A tinytest
object. A tinytest
object is a logical
with attributes holding information about the test that was run