tests/testthat/test-UseSearchParams.R

test_that("useSearchParams() renders query parameters", {
  skip_on_cran()

  app <- shinytest2::AppDriver$new(
    app_dir = testthat::test_path("test-apps", "UseSearchParams")
  )
  app$wait_for_idle()

  app$get_js("window.location.hash = '#/?color=red'")
  app$wait_for_idle()

  color_text <- app$get_text("#colorParam")
  expect_equal(color_text, "red")

  all_text <- app$get_text("#allParams")
  expect_true(grepl('"color"', all_text))
  expect_true(grepl('"red"', all_text))
})

Try the reactRouter package in your browser

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

reactRouter documentation built on May 10, 2026, 5:07 p.m.