EVOLUTION-MANAGER
Edit File: expect_snapshot_value.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Snapshot testing for values</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for expect_snapshot_value {testthat}"><tr><td>expect_snapshot_value {testthat}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Snapshot testing for values</h2> <h3>Description</h3> <p>Captures the result of function, flexibly serializing it into a text representation that's stored in a snapshot file. See <code><a href="expect_snapshot.html">expect_snapshot()</a></code> for more details on snapshot testing. </p> <h3>Usage</h3> <pre> expect_snapshot_value( x, style = c("json", "json2", "deparse", "serialize"), cran = FALSE, tolerance = testthat_tolerance(), ..., variant = NULL ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>Code to evaluate.</p> </td></tr> <tr valign="top"><td><code>style</code></td> <td> <p>Serialization style to use: </p> <ul> <li> <p><code>json</code> uses <code><a href="../../jsonlite/html/fromJSON.html">jsonlite::fromJSON()</a></code> and <code><a href="../../jsonlite/html/fromJSON.html">jsonlite::toJSON()</a></code>. This produces the simplest output but only works for relatively simple objects. </p> </li> <li> <p><code>json2</code> uses <code><a href="../../jsonlite/html/serializeJSON.html">jsonlite::serializeJSON()</a></code> and <code><a href="../../jsonlite/html/serializeJSON.html">jsonlite::unserializeJSON()</a></code> which are more verbose but work for a wider range of type. </p> </li> <li> <p><code>deparse</code> uses <code><a href="../../base/html/deparse.html">deparse()</a></code>, which generates a depiction of the object using R code. </p> </li> <li> <p><code>serialize()</code> produces a binary serialization of the object using <code><a href="../../base/html/serialize.html">serialize()</a></code>. This is all but guaranteed to work for any R object, but produces a completely opaque serialization. </p> </li></ul> </td></tr> <tr valign="top"><td><code>cran</code></td> <td> <p>Should these expectations be verified on CRAN? By default, they are not, because snapshot tests tend to be fragile because they often rely on minor details of dependencies.</p> </td></tr> <tr valign="top"><td><code>tolerance</code></td> <td> <p>Numerical tolerance: any differences (in the sense of <code><a href="../../base/html/all.equal.html">base::all.equal()</a></code>) smaller than this value will be ignored. </p> <p>The default tolerance is <code>sqrt(.Machine$double.eps)</code>, unless long doubles are not available, in which case the test is skipped.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Passed on to <code><a href="../../waldo/html/compare.html">waldo::compare()</a></code> so you can control the details of the comparison.</p> </td></tr> <tr valign="top"><td><code>variant</code></td> <td> <p>If non-<code>NULL</code>, results will be saved in <code style="white-space: pre;">_snaps/{variant}/{test.md}</code>, so <code>variant</code> must be a single string suitable for use as a directory name. </p> <p>You can use variants to deal with cases where the snapshot output varies and you want to capture and test the variations. Common use cases include variations for operating system, R version, or version of key dependency. Variants are an advanced feature. When you use them, you'll need to carefully think about your testing strategy to ensure that all important variants are covered by automated tests, and ensure that you have a way to get snapshot changes out of your CI system and back into the repo.</p> </td></tr> </table> <hr /><div style="text-align: center;">[Package <em>testthat</em> version 3.1.5 <a href="00Index.html">Index</a>]</div> </body></html>