Description Public fields Active bindings Methods Examples
An R6 class suitable for testing that simulates the session
parameter
provided to Shiny server functions or modules.
env
The environment associated with the session.
singletons
Hardcoded as empty. Needed for rendering HTML (i.e. renderUI)
clientData
Mock client data that always returns a size for plots
output
The shinyoutputs associated with the session
input
The reactive inputs associated with the session
userData
An environment initialized as empty.
progressStack
A stack of progress objects
returned
The value returned from the module
request
An empty environment where the request should be. The request isn't meaningfully mocked currently.
reactlog()
No-op
MockShinySession$reactlog(logEntry)
logEntry
Not used
incrementBusyCount()
No-op
MockShinySession$incrementBusyCount()
new()
Create a new MockShinySession
MockShinySession$new()
onFlush()
Define a callback to be invoked before a reactive flush
MockShinySession$onFlush(fun, once = TRUE)
fun
The function to invoke
once
If TRUE
, will only run once. Otherwise, will run every time reactives are flushed.
onFlushed()
Define a callback to be invoked after a reactive flush
MockShinySession$onFlushed(fun, once = TRUE)
fun
The function to invoke
once
If TRUE
, will only run once. Otherwise, will run every time reactives are flushed.
onEnded()
Define a callback to be invoked when the session ends
MockShinySession$onEnded(sessionEndedCallback)
sessionEndedCallback
The callback to invoke when the session has ended.
isEnded()
Returns FALSE
if the session has not yet been closed
MockShinySession$isEnded()
isClosed()
Returns FALSE
if the session has not yet been closed
MockShinySession$isClosed()
close()
Closes the session
MockShinySession$close()
cycleStartAction()
Unsophisticated mock implementation that merely invokes the given callback immediately.
MockShinySession$cycleStartAction(callback)
callback
The callback ato be invoked.
fileUrl()
Base64-encode the given file. Needed for image rendering.
MockShinySession$fileUrl(name, file, contentType = "application/octet-stream")
name
Not used
file
The file to be encoded
contentType
The content type of the base64-encoded string
setInputs()
Sets reactive values associated with the session$inputs
object
and flushes the reactives.
MockShinySession$setInputs(...)
...
The inputs to set.
s <- MockShinySession$new() s$setInputs(x=1, y=2)
.scheduleTask()
An internal method which shouldn't be used by others.
MockShinySession$.scheduleTask(millis, callback)
millis
The number of milliseconds on which to schedule a callback
callback
The function to schedule
elapse()
Simulate the passing of time by the given number of milliseconds.
MockShinySession$elapse(millis)
millis
The number of milliseconds to advance time.
.now()
An internal method which shouldn't be used by others.
MockShinySession$.now()
defineOutput()
An internal method which shouldn't be used by others.
MockShinySession$defineOutput(name, func, label)
name
The name of the output
func
The render definition
label
Not used
getOutput()
An internal method which shouldn't be used by others.
MockShinySession$getOutput(name)
name
The name of the output
registerDataObj()
No-op
MockShinySession$registerDataObj(name, data, filterFunc)
name
Not used
data
Not used
filterFunc
Not used
allowReconnect()
No-op
MockShinySession$allowReconnect(value)
value
Not used
reload()
No-op
MockShinySession$reload()
resetBrush()
No-op
MockShinySession$resetBrush(brushId)
brushId
Not used
sendCustomMessage()
No-op
MockShinySession$sendCustomMessage(type, message)
type
Not used
message
Not used
sendBinaryMessage()
No-op
MockShinySession$sendBinaryMessage(type, message)
type
Not used
message
Not used
sendInputMessage()
No-op
MockShinySession$sendInputMessage(inputId, message)
inputId
Not used
message
Not used
setBookmarkExclude()
No-op
MockShinySession$setBookmarkExclude(names)
names
Not used
getBookmarkExclude()
No-op
MockShinySession$getBookmarkExclude()
onBookmark()
No-op
MockShinySession$onBookmark(fun)
fun
Not used
onBookmarked()
No-op
MockShinySession$onBookmarked(fun)
fun
Not used
doBookmark()
No-op
MockShinySession$doBookmark()
onRestore()
No-op
MockShinySession$onRestore(fun)
fun
Not used
onRestored()
No-op
MockShinySession$onRestored(fun)
fun
Not used
exportTestValues()
No-op
MockShinySession$exportTestValues()
getTestSnapshotUrl()
No-op
MockShinySession$getTestSnapshotUrl( input = TRUE, output = TRUE, export = TRUE, format = "json" )
input
Not used
output
Not used
export
Not used
format
Not used
ns()
Returns the given id prefixed by mock-session-
.
MockShinySession$ns(id)
id
The id to modify.
flushReact()
Trigger a reactive flush right now.
MockShinySession$flushReact()
makeScope()
MockShinySession$makeScope(namespace)
clone()
The objects of this class are cloneable with this method.
MockShinySession$clone(deep = FALSE)
deep
Whether to make a deep clone.
1 2 3 4 5 6 | ## ------------------------------------------------
## Method `MockShinySession$setInputs`
## ------------------------------------------------
s <- MockShinySession$new()
s$setInputs(x=1, y=2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.