Learn R Programming

doconv (version 0.4.0)

expect_snapshot_flextables: Visual snapshot test for flextable object(s)

Description

Renders flextable objects to PNG with flextable::save_as_image() and compares against a reference snapshot using expect_snapshot_doc().

When x is a list of flextable objects, individual renderings are assembled into a single composite image via images_to_miniature(). By default each table occupies its own row; use ncol to arrange several tables per row. The snapshot is always a single file named <name>.png, stored in testthat's _snaps directory.

If a table fails to render, its slot is replaced by a blank white rectangle (200 x 50 px), making the failure visible in the diff.

On the first run the reference snapshot is created and the test is reported as a new snapshot. Subsequent runs compare the current rendering against the stored reference.

Usage

expect_snapshot_flextables(x, name, res = 200, ncol = NULL, tolerance = 0.001)

Value

The result of expect_snapshot_doc().

Arguments

x

a flextable object or a list containing flextable objects.

name

a unique string used as the snapshot file name (<name>.png). Must be unique across the test file.

res

resolution in DPI, default 200.

ncol

number of images per row in the composite when x is a list (default NULL, one image per row).

tolerance

ratio of different pixels allowed, default 0.001.