Skip to contents

Creates a self-contained example project under tempdir(), including:

  • _resultcheck.yml (project root marker)

  • analysis.R with snapshot(model, "model")

  • matching and mismatched snapshot files

  • tests/testthat/test-analysis.R

then temporarily sets the working directory to that project while evaluating code.

Usage

with_example(code, mismatch = FALSE)

Arguments

code

Code to evaluate inside the temporary example project.

mismatch

Logical. If TRUE, replaces the active snapshot with a mismatched version before evaluating code.

Value

The value of code.

Examples

with_example({
  root <- find_root()
  print(root)
})
#> [1] "/tmp/RtmpGfNOM5/resultcheck-example-19cc6cc946db"