expect_snapshot_doc {doconv} | R Documentation |
Visual test for document
Description
This expectation can be used with 'tinytest' and 'testthat'
to check if a current document of type pdf, docx, doc, rtf, pptx or png
matches a target document. When the expectation is checked
for the first time, the expectation fails and a target miniature
of the document is saved in a folder named _tinytest_doconv
or
_snaps
.
Usage
expect_snapshot_doc(
name,
x,
tolerance = 0.001,
engine = c("tinytest", "testthat")
)
Arguments
name |
a string to identify the test. Each document in the test suite must have a unique name. |
x |
file path of a document |
tolerance |
the ratio of different pixels that is acceptable before triggering a failure. |
engine |
test package being used in the test suite, one of "tinytest" or "testthat". |
Value
A tinytest::tinytest()
or a testthat::expect_snapshot_file object.
Examples
file <- system.file(package = "doconv",
"doc-examples/example.docx")
## Not run:
if (require("tinytest") && msoffice_available()){
# first run add a new snapshot
expect_snapshot_doc(x = file, name = "docx file", engine = "tinytest")
# next runs compare with the snapshot
expect_snapshot_doc(x = file, name = "docx file", engine = "tinytest")
# cleaning directory
unlink("_tinytest_doconv", recursive = TRUE, force = TRUE)
}
if (require("testthat") && msoffice_available()){
local_edition(3)
# first run add a new snapshot
expect_snapshot_doc(x = file, name = "docx file", engine = "testthat")
# next runs compare with the snapshot
expect_snapshot_doc(x = file, name = "docx file", engine = "testthat")
}
## End(Not run)
[Package doconv version 0.3.2 Index]