Once a recording is completed, it will create or append a new
shinytest2 test to the testthat test_file.
record_test(
app = ".",
...,
name = NULL,
seed = NULL,
load_timeout = NULL,
shiny_args = list(),
test_file = NULL,
open_test_file = rlang::is_interactive(),
allow_no_input_binding = NULL,
record_screen_size = TRUE,
run_test = TRUE,
record_in_package = TRUE
)A AppDriver object, or path to a Shiny
application.
Must be empty. Allows for parameter expansion.
Name provided to AppDriver. This value should be unique between all tests within a test file. If it is not unique, different expect methods may overwrite each other.
A random seed to set before running the app. This seed will also be used in the test script.
Maximum time to wait for the Shiny application to load, in milliseconds. If a value is provided, it will be saved in the test script.
A list of options to pass to runApp(). If a value
is provided, it will be saved in the test script.
Base file name of the testthat test file. If NULL, a
default name will be used. If recording within a package, the test file
will be saved to the package's tests/testthat/ directory. If not within a
package, the test file will be saved to the app's tests/testthat/ directory.
If within a package, the default name is test-app-<appdir>.R, where <appdir> is the
name of the app directory. If not within a package, the default name is
test-shinytest2.R.
If TRUE, the test file will be opened in an editor
via file.edit() before executing.
This value controls if events without input bindings are recorded.
If TRUE, events without input bindings are recorded.
If FALSE, events without input bindings are not recorded.
If NULL (default), if an updated input does not have a corresponding
input, a modal dialog will be shown asking if unbound input events should
be recorded.
See AppDriver$set_inputs() for more information.
If TRUE, the screen size will be recorded when initialized and changed.
If TRUE, test_file will be executed after saving the recording.
If TRUE and if the current working directory is
within a package, the test file will be saved to the package's
tests/testthat/ directory. If FALSE, the test file will be saved to the
app's tests/testthat/ directory.
Files that are uploaded to your Shiny app must be located somewhere within
the tests/testthat subdirectory or available via system.file().
Files that are uploaded during recording that do not have a valid path will
have a warning inserted into the code. Please fix the file path by moving the
file to the tests/testthat subdirectory or by using system.file(). After
fixing the path, remove the line of warning code.
test_app()
if (FALSE) {
record_test("path/to/app")
}
Run the code above in your browser using DataLab