vdiffr (version 0.0.0.9000)

expect_doppelganger: Does a figure look like its expected output?

Description

If the test has never been validated yet, the test is skipped. If the test has previously been validated but fig does not look like its expected output, an error is issued. Use validate_cases() or manage_cases() to (re)validate the test.

Usage

expect_doppelganger(fig, fig_name, fig_path = "figs", ...)

Arguments

fig
A figure to test.
fig_name
The name of the test case. This will be used as the base for the SVG file name.
fig_path
The path where the test case should be stored, relative to the tests folder.
...
Additional arguments passed to compare() to control specifics of comparison.

Details

fig can be a ggplot object, a recordedplot, a function to be called, or more generally any object with a print method. If a ggplot object, a dependency for ggplot2 is automatically added (see add_dependency()).

Examples

Run this code
## Not run: 
# disp_hist_base <- function() hist(mtcars$disp)
# disp_hist_ggplot <- ggplot(mtcars, aes(disp)) + geom_histogram()
# 
# expect_doppelganger(disp_hist_base, "disp-histogram-base")
# expect_doppelganger(disp_hist_ggplot, "disp-histogram-ggplot")
# ## End(Not run)

Run the code above in your browser using DataLab