Test if printed output matches a target printout
Source:R/expect_snapshot_print.R
expect_snapshot_print.RdThis 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 text file is saved to the inst/tinytest/_tinysnapshot folder.
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_print(
current,
label,
mode = getOption("tinysnapshot_mode", default = "unified"),
format = getOption("tinysnapshot_format", default = "ansi256"),
ignore_white_space = getOption("tinysnapshot_ignore_white_space", default = FALSE),
fn_current = getOption("tinysnapshot_fn_current", default = identity),
fn_target = getOption("tinysnapshot_fn_target", default = identity),
...
)Arguments
- current
an object which returns text to the console when calling
print(x)`- label
a string to identify the snapshot (alpha-numeric, hyphens, or underscores). Each plot in the test suite must have a unique label.
- mode
"unified", "sidebyside", "context", or "auto". See
?diffobj::diffPrint- format
"raw", "ansi8", "ansi256", "html", or "auto". See
?diffobj::diffPrint- ignore_white_space
TRUEto ignore horizontal white space and empty lines.- fn_current
A function to apply to the current output before comparison.
- fn_target
A function to apply to the target output before comparison.
- ...
Additional arguments are passed to
diffobj::diffPrint()