expect_snapshot_print {tinysnapshot}R Documentation

Test if printed output matches a target printout

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 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"),
  ...
)

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

...

Additional arguments are passed to diffobj::diffPrint()

Value

A tinytest object. A tinytest object is a logical with attributes holding information about the test that was run


[Package tinysnapshot version 0.0.5 Index]