Title: | Shiny JavaScript Testing |
---|---|
Description: | Run JavaScript testing on Shiny applications. This will act as a user clicking within the browser. Methods have been added to unify how testing is done. |
Authors: | Barret Schloerke [aut, cre] , RStudio [cph, fnd] |
Maintainer: | Barret Schloerke <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.0.9010 |
Built: | 2024-11-01 11:25:21 UTC |
Source: | https://github.com/schloerke/shinyjster |
Verify that all jster apps tested successfully
assert_jster(dt)
assert_jster(dt)
dt |
|
Wraps supplied text in an htmltools::tags$script
call after turning it into JS
code.
js_script(...)
js_script(...)
... |
JavaScript text to be put in a script. |
Run an application with shinyjster enabled
run_jster( appDir, port = 8000, host = "127.0.0.1", browser = getOption("browser") ) run_jster_apps( apps, type = c("serial", "callr", "lapply"), cores = parallel::detectCores(), port = NULL, host = "127.0.0.1", browser = getOption("browser") )
run_jster( appDir, port = 8000, host = "127.0.0.1", browser = getOption("browser") ) run_jster_apps( apps, type = c("serial", "callr", "lapply"), cores = parallel::detectCores(), port = NULL, host = "127.0.0.1", browser = getOption("browser") )
appDir |
The application to run. Should be one of the following:
|
port |
The TCP port that the application should listen on. If the
|
host |
The IPv4 address that the application should listen on. Defaults
to the |
browser |
a non-empty character string giving the name of the program to be used as the HTML browser. It should be in the PATH, or a full path specified. Alternatively, an R function to be called to invoke the browser. Under Windows |
apps |
Vector of |
type |
Single value to determine how applications are executed.
|
cores |
Number of cores (if needed) to execute on. |
run_jster()
: Run a single shiny application with shinyjster enabled
run_jster_apps()
: Run a set of Shiny applications with shinyjster enabled
Opens a selenium driven browser and waits until shinyjster is finished.
selenium_chrome( timeout = 2 * 60, dimensions = "1200x1200", headless = !interactive(), verbose = TRUE ) selenium_firefox( timeout = 2 * 60, dimensions = "1200x1200", headless = !interactive(), verbose = TRUE ) selenium_edge(timeout = 2 * 60, dimensions = "1200x1200", verbose = TRUE) selenium_ie(timeout = 2 * 60, dimensions = "1200x1200", verbose = TRUE) selenium_safari(timeout = 2 * 60, dimensions = "1200x1200", verbose = TRUE)
selenium_chrome( timeout = 2 * 60, dimensions = "1200x1200", headless = !interactive(), verbose = TRUE ) selenium_firefox( timeout = 2 * 60, dimensions = "1200x1200", headless = !interactive(), verbose = TRUE ) selenium_edge(timeout = 2 * 60, dimensions = "1200x1200", verbose = TRUE) selenium_ie(timeout = 2 * 60, dimensions = "1200x1200", verbose = TRUE) selenium_safari(timeout = 2 * 60, dimensions = "1200x1200", verbose = TRUE)
timeout |
Number of seconds before selenium closes the browser |
dimensions |
A string in the form of |
headless |
Logical which determines if the browser can run headless. Defaults to |
verbose |
Logical which determines if the selenium output is displayed as it's received |
This function assumes selenium is installed and all appropriate web browsers are installed.
selenium_chrome()
: Opens a Chrome web browser
selenium_firefox()
: Opens a Firefox web browser
selenium_edge()
: Opens an Edge web browser
selenium_ie()
: Opens an IE web browser
selenium_safari()
: Opens an Safari web browser
Function to be called first inside the definition of the Shiny UI.
shinyjster_js(..., set_timeout = TRUE)
shinyjster_js(..., set_timeout = TRUE)
... |
JavaScript text to be put in a script. |
set_timeout |
If |
This function also includes shinyjster_ui()
and wraps all JavaScript using js_script()
.
shinyjster HTML Dependencies
shinyjster_js_dependencies()
shinyjster_js_dependencies()
htmltools::htmlDependency's to allow shinyjster to function.
Function to be called within the shiny server
shinyjster_server(input, output, session = shiny::getDefaultReactiveDomain())
shinyjster_server(input, output, session = shiny::getDefaultReactiveDomain())
input , output , session
|
Shiny server function parameters |
Function to be called first inside the definition of the Shiny UI.
shinyjster_ui()
shinyjster_ui()
This function will add the shinyjster JS dependencies and add a text based progress bar in the bottom left corner of the application.
This method will test your shiny application using the shinyjster code you have provided on all of the available browsers shinyjster can test with on the given platform.
For each browser, each app will be tested using run_jster_apps()
.
test_jster( apps = "../", browsers = c(selenium_chrome(), selenium_firefox(), if (platform() == "win" || platform() == "mac") c(selenium_edge()), if (platform() == "win") c(selenium_ie()), if (platform() == "mac") c(selenium_safari())), type = c("serial", "lapply"), assert = TRUE, host = "127.0.0.1", port = NULL )
test_jster( apps = "../", browsers = c(selenium_chrome(), selenium_firefox(), if (platform() == "win" || platform() == "mac") c(selenium_edge()), if (platform() == "win") c(selenium_ie()), if (platform() == "mac") c(selenium_safari())), type = c("serial", "lapply"), assert = TRUE, host = "127.0.0.1", port = NULL )
apps |
Defaults the app in the directory above |
browsers |
By default, as many browsers as selenium support on the given platform |
type |
Single value to determine how applications are executed.
|
assert |
A logical value that determines if |
host |
The IPv4 address that the application should listen on. Defaults
to the |
port |
The TCP port that the application should listen on. If the
|
A data frame with the columns appDir
, successful
, returnValue
, and browser
. One row of information per browser
and apps
combination.
This method will test a single application on all of the available browsers
shinyjster can test with on the given platform. For each browser, the app
will be tested using test_jster()
.
testthat_shinyjster( test_name = NULL, app_dir = "../../", ..., browsers = c("chrome", "firefox", "edge"), timeout = 2 * 60, dimensions = "1200x1200" )
testthat_shinyjster( test_name = NULL, app_dir = "../../", ..., browsers = c("chrome", "firefox", "edge"), timeout = 2 * 60, dimensions = "1200x1200" )
test_name |
suffix to add to the test name for |
app_dir |
Defaults the app in the directory above |
... |
Ignored |
browsers |
Names of each browser to be tested. |
timeout , dimensions
|
Parameters to be supplied to each browser |
This method should be called from a test file in the ./tests/testthat/
directory.
For each browser, a new testthat::test_that()
test will be run. This allows
for browsers to not effect the other tests.
This creates a testing file to be used with shiny::runTests('.')
. It will call test_jster()
which will cycle through all avaiable shinyjster selenium browsers.
use_jster(appDir = ".")
use_jster(appDir = ".")
appDir |
Location of shiny application to test |