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

difference between expected and current when using plotly (elementId) #174

Closed
emrichter opened this issue Feb 23, 2018 · 7 comments
Closed

Comments

@emrichter
Copy link

emrichter commented Feb 23, 2018

Hi
I'm testing a simpe shiny app with a plotly-figure. Since plotly always generates a new elementId for its plots, shinytest shows this as a difference between expected and current results. In my case (and I guess also in general) this should not count as a real difference though, since nothing has changed.
Is there a way to ignore this?

grafik

@floswald
Copy link

same issue

@Jax89
Copy link

Jax89 commented Jun 21, 2018

Just started testing my app, really like the test tool but facing the same issue

@floswald
Copy link

floswald commented Jun 21, 2018 via email

@clabornd
Copy link

clabornd commented Jul 4, 2018

I am currently running a janky solution which involves exporting parts of the plotly object that don't depend on the element ID.

in server.R:
p <- plot_ly(...)
exportTestValues(plot_attrs = p$x$attrs[[p$x$cur_data]])

in test_script.R: app$snapshot(items = list(export = "plot_attrs"))

Not sure how much this is really testing anything.

@krlmlr
Copy link
Contributor

krlmlr commented Oct 10, 2018

Could you please try the PR to plotly via

#install.packages("remotes")
remotes::install_github("ropenci/plotly#1365")

? You also need to fix the random seed with ShinyDriver$new(..., seed = <some number>) .

@wch
Copy link
Collaborator

wch commented Oct 29, 2018

FYI: it's possible to call snapshotPreprocessOutput() to add an output preprocessing function to clean up the raw output value to something that's more deterministic for testing. See:
https://github.com/rstudio/shiny/blob/6ede019/R/snapshot.R#L10-L19

For an example of usage, see: https://github.com/rstudio/DT/blob/80981d3/R/shiny.R#L116-L124

Also, this is something that needs to be documented in the shinytest web site.

@hadley
Copy link
Member

hadley commented Aug 8, 2020

Fixed in plotly.

@hadley hadley closed this as completed Aug 8, 2020
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 a pull request may close this issue.

7 participants