expect_snapshot_r_process: testthat snapshot test with asciicast

View source: R/test.R

expect_snapshot_r_processR Documentation

testthat snapshot test with asciicast

Description

This function is very similar to testthat::expect_snapshot_output(), but it runs the code in an asciciast subprocess, using record_output().

Usage

expect_snapshot_r_process(
  ...,
  interactive = TRUE,
  echo = TRUE,
  startup = NULL,
  transform = NULL,
  variant = NULL
)

Arguments

...

Code to run (unnamed arguments) and arguments to pass to record_output() (named arguments). The code is evaluated in a new asciicast subprocess. Their output is returned and used in a testthat snapshot test.

interactive

Whether to use an interactive R process to evaluate the code.

echo

Whether to echo the code in the subprocess before running it.

startup

Expression to evaluate in the subprocess before recording the snapshot. By default it loads and attaches the calling package, including its internal functions.

transform

Passed to testthat::expect_snapshot().

variant

Passed to testthat::expect_snapshot().

Details

THe Code part of the snapshot is always the same, but the Output part shows the code, assuming echo = TRUE (the default).

Examples


Sys.getpid()
testthat::local_edition(3)
expect_snapshot_r_process(Sys.getpid())


r-lib/asciicast documentation built on Jan. 31, 2024, 1:19 p.m.