tests/testthat/test-apps.R

app_dir <- test_path("apps/files-app-rmd")
if (!dir.exists(file.path(app_dir, "tests", "testthat"))) {
  skip("App test folders have been ignored")
}

# Test reporter displays info
# Similar to
# v |         4 | apps
# v |         1 | apps - custom name - shinytest2 [0.3s]
# ✔ |         4 | apps
test_that("before", {
  expect_equal(1, 1)
  expect_equal(1, 1)
  expect_equal(1, 1)
})
test_that("wrapper", {
  expect_equal(1, 1)
  test_app(app_dir, name = "custom name 1")
  expect_equal(1, 1)
})
test_that("after", {
  expect_equal(1, 1)
  expect_equal(1, 1)
  expect_equal(1, 1)
})

test_that("before", {
  expect_equal(1, 1)
  expect_equal(1, 1)
  expect_equal(1, 1)
})
test_app(app_dir, name = "custom name 2")
test_that("after", {
  expect_equal(1, 1)
  expect_equal(1, 1)
  expect_equal(1, 1)
})


## --------------------------------


# Test all apps work as expected
lapply(
  fs::dir_ls(test_path("apps"), type = "directory"),
  function(shiny_app_dir) {
    test_app(shiny_app_dir)
  }
)

Try the shinytest2 package in your browser

Any scripts or data that you put into this service are public.

shinytest2 documentation built on June 24, 2024, 5:16 p.m.