Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In test mode, send message to client even when no outputs change #1747

Merged
merged 3 commits into from Jun 20, 2017

Conversation

wch
Copy link
Collaborator

@wch wch commented Jun 16, 2017

Normally, if an input is changed but no outputs change, the Shiny process will not send anything to the client in response. With this change, when shiny.testmode is TRUE, then Shiny will send a response to the client in response to an input changing, even if no outputs change.

This makes it possible for shinytest to detect when an input has been received and processed by the server, even if no outputs change. (Shinytest detects this by listening on the client for a message that contains a values field.)

Here is a minimal sample app:

options(shiny.trace=TRUE)
shinyApp(
  fluidPage(sliderInput("test", "Test", 0, 10, 5)),
  function(input, output, session) {}
)

Normally, when running this app, if you move the slider multiple times, the R console prints this:

RECV {"method":"update","data":{"test":6}}
RECV {"method":"update","data":{"test":7}}
RECV {"method":"update","data":{"test":8}}

In test mode (with options(shiny.testmode=TRUE)), it prints this:

RECV {"method":"update","data":{"test":6}}
SEND {"values":[]}
RECV {"method":"update","data":{"test":7}}
SEND {"values":[]}
RECV {"method":"update","data":{"test":8}}
SEND {"values":[]}

This change will make (apparent) issues like rstudio/shinytest#106 much less common, and simplify the procedure of creating tests, because less manual intervention will be needed.

@wch wch added the review label Jun 16, 2017
@wch wch force-pushed the wch-testmode-input-event branch from 81fa9a5 to 39110ca Compare June 16, 2017 02:31
@bborgesr
Copy link
Contributor

LGTM. I think this will be a super elegant solution to those scenarios in shinytest!

@wch wch merged commit 25298a6 into master Jun 20, 2017
@wch wch deleted the wch-testmode-input-event branch June 20, 2017 18:50
@wch wch removed the review label Jun 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants