tests/testthat/apps/hello/app.R

library(shiny)

ui <- fluidPage(
  textInput("name", "What is your name?"),
  actionButton("greet", "Greet"),
  textOutput("greeting"),
  tags$br(),
  # consistenly sized box and consistent across OS
  tags$div(
    id = "custom_div",
    style = "width: 100px;height: 100px;"
  )
)
server <- function(input, output, session) {
  output$greeting <- renderText({
    shiny::req(input$greet)
    paste0("Hello ", shiny::isolate(input$name), "!")
  })
}

shinyApp(ui, server)
rstudio/shinytest2 documentation built on March 29, 2025, 10:58 p.m.