% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils-tests.R
\name{generate_plugin_args}
\alias{generate_plugin_args}
\alias{sink_msg}
\alias{new_mock_session}
\alias{with_mock_session}
\alias{with_mock_context}
\alias{get_s3_method}
\alias{export_safely}
\title{Testing utilities}
\usage{
generate_plugin_args(board, ..., mode = c("edit", "read"))

sink_msg(...)

new_mock_session()

with_mock_session(expr, session = new_mock_session())

with_mock_context(session, expr)

get_s3_method(generic, object)

export_safely(x)
}
\arguments{
\item{board}{A board object}

\item{...}{Forwarded to \code{\link[utils:capture.output]{utils::capture.output()}}}

\item{mode}{Edit plugins, such as \code{manage_blocks} get an additional argument
\code{update} over read plugins such as \code{preserve_board}.}

\item{expr}{Test code containing expectations. The objects from inside the
server function environment will be made available in the environment of
the test expression (this is done using a data mask with
\code{\link[rlang:eval_tidy]{rlang::eval_tidy()}}). This includes the parameters of the server function
(e.g. \code{input}, \code{output}, and \code{session}), along with any other values
created inside of the server function.}

\item{session}{The \code{\link[shiny]{MockShinySession}} object to use as the \link[shiny:domains]{reactive domain}. The same session object is used as the domain both
during invocation of the server or module under test and during evaluation
of \code{expr}.}

\item{generic}{Generic function name (passed as string)}

\item{object}{S3 Object}

\item{x}{Reactive object to use in \code{\link[shiny:exportTestValues]{shiny::exportTestValues()}}}
}
\value{
For testing plugins, \code{generate_plugin_args()} returns objects that
mimic how plugins are called in the board server (with reactive components
re-created on a \code{NULL} reactive domain so they outlive the
\code{\link[shiny:testServer]{shiny::testServer()}} session used to set them up), \code{sink_msg()} is called
mainly for the side-effect of muting shiny messages (and returns them
invisibly), \code{with_mock_session()} returns \code{NULL} (invisibly) and
\code{with_mock_context()} returns the result of a call to
\code{\link[shiny:withReactiveDomain]{shiny::withReactiveDomain()}}. Finally, \code{get_s3_method()} returns a
class-specific implementation of the specified generic (and throws an error
if none is found).
}
\description{
Several utilities for unit testing, mainly with \code{\link[shiny:testServer]{shiny::testServer()}} that
have proven themselves useful for testing this package are exported for
re-use in other packages.
}
