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
.
expect_snapshot_doc(
name,
x,
tolerance = 0.001,
engine = c("tinytest", "testthat")
)
A tinytest::tinytest()
or a testthat::expect_snapshot_file object.
file <- system.file(package = "doconv",
"doc-examples/example.docx")
if (FALSE) { # \dontrun{
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")
}
} # }