isInteractive: Alternative to 'interactive()' for unit testing

View source: R/helpers.R

isInteractiveR Documentation

Alternative to interactive() for unit testing

Description

This is a suggestion from https://github.com/MangoTheCat/blog-with-mock/blob/master/Blogpost1.Rmd as a way to test interactive code in unit tests. Basically, in the unit tests, we use testthat::with_mock, and inside that we redefine isInteractive just for the test. In all other times, this returns the same things as interactive().

Usage

isInteractive()

reproducible documentation built on June 22, 2024, 10:18 a.m.