3

I need to test my shiny application so I have downloaded shinytest and followed this tutorial - https://www.rstudio.com/resources/webinars/testing-shiny-applications-with-shinytest/ .

When I run recordTest() on a small application, it works fine. But I have a big application that I need to create tests for and I can not run recordTest() above this application. It outputs the following lines:

Error in sd_startShiny(self, private, path, seed) : 
  Cannot find shiny port number. Error:
Running application in test mode.
Loading required package: shiny

Attaching package: 'dplyr'

The following objects are masked from 'package:stats':

    filter, lag

The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union

Loading required package: Hmisc
Loading required package: lattice
Loading required package: Formula

Attaching package: 'Hmisc'

The following objects are masked from 'package:dplyr':

    src, summarize

The following objects are masked from 'package:base':

    format.pval, units

Loading required package: SparseM

Attaching package: 'SparseM'

The following object is masked from 'package:base':

    backsolve


Attaching package: 'rms'

The following object is masked from 'package:shiny':

    validate

Loading required package: ggpubr
Loading required package: magrittr
Warning: package 'compareGroups' was built under R version 3.4.4
Loading required package: gdata
gdata: Unab

My application needs to be tested is quite big. It connects to database, retrieves data from database, sources many files. In lines printed above you can clearly see from the last line that it probably timeouts. gdata: Unab - probably it was meant Unable ....

I saw people dealing with this here - https://github.com/rstudio/shinytest/issues/111 - but there is no clear answer how to fix that.

The solution may be: to rewrite shinytest's code that is placed on github and install the rewritten one. But I do not know if this is possible.

scarface
  • 574
  • 6
  • 20

2 Answers2

4

I am not sure if this is the right attitude how to fix problems like this but let's say. I followed this answer and changed the loadTimeout = 10000 parameter to loadTimeout = 100000.

It was the following line of code:

app <- ShinyDriver$new(app, seed = seed, loadTimeout = 10000)
scarface
  • 574
  • 6
  • 20
2

I was able to get past this problem simply by including a loadTimeout parameter when I called recordTest:

> recordTest("myApp", loadTimeout = 100000)

However, as scarface mentioned, you can also change the first line of the test script that is created by recordTest() by adding the loadTimeout parameter to the first line.

James
  • 226
  • 4
  • 14