I have a package with shiny code to which I try to add tests by using the shinytest::recordTest()
function. Basically, I just downloaded the shinytestPackageExample repo but added @importFrom roperator chr
and a call to chr
in the server method.
If I try devtools::load_all()
followed by shinytest::recordTest('inst/sampleapp/')
I get the error Error in chr: could not find function "chr"
. See screen shot.
My modified version of the repo is available here. I also list the changed files below.
helloworld.R
:
#' A Hello World Shiny app
#'
#' @import shiny
#' @importFrom graphics plot
#' @importFrom utils head
#' @importFrom roperators chr
#' @export
helloWorldApp <- function() {
utils::data(cars)
shinyApp(
ui = fluidPage(
sliderInput("n", "n", 1, nrow(cars), 10),
plotOutput("plot")
),
server = function(input, output) {
output$plot <- renderPlot({
a <- chr(9)
plot(head(cars, input$n), xlim = range(cars[[1]]), ylim = range(cars[[2]]))
})
}
)
}
# This is needed to make R CMD check happy
globalVariables("cars")
DESCRIPTION:
Package: shinytestPackageExample
Version: 1.0
Title: Example package that uses shinytest
Description: Example package that uses shinytest.
Authors@R: person("Chang", "Winston", , "winston@rstudio.com", c("aut", "cre"))
License: Unlimited
Encoding: UTF-8
LazyData: true
ByteCompile: true
RoxygenNote: 7.1.1
Suggests:
testthat,
shinytest
Imports:
shiny,
roperators
Remotes:
rstudio/shinytest
And NAMESPACE
(generated through the use of devtools::document()
):
# Generated by roxygen2: do not edit by hand
export(helloWorldApp)
import(shiny)
importFrom(graphics,plot)
importFrom(roperators,chr)
importFrom(utils,head)
I hope that this is enough info, if not, please let me know. I would be grateful if someone has a solution to the problem.