-
Notifications
You must be signed in to change notification settings - Fork 31
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
Suggestions from a user #16
Comments
I haven't personally used vdiffr but based on what I saw, I aggree that #2
and #3 would be useful. And if Chris is offering to help, you should
consider taking him up on the offer, he did a great job improving my package
…On May 23, 2017 9:02 PM, "Chris Baker" ***@***.***> wrote:
Greetings -
I was recently working with @daattali <https://github.com/daattali> on
integrating visual tests into ggExtra using the vdiffr framework. I
wanted to get your thoughts on a few small changes that I thought may
benefit vidffr. If you like one of them, I'd be happy to work on a PR to
implement it.
1.
Export write_svg. I initially struggled to get my visual tests to
pass, mostly because the way I was saving my baseline figures (i.e., the
figures in tests/figs) was different from how vdiffr was saving the
figures during the tests (via write_svg). Although the behavior of
write_svg is indirectly documented in the README, it took me awhile to
realize that I had to mimic that behavior when creating the baseline plots.
I think the easiest way to address this would be to just export
write_svg, and suggest that the user use this function when saving
their baseline figures.
2.
Make a suggestion as to how the user can re-use the code that creates
their baseline figures when writing their unit tests. The solution that we
ended up using was to save the plot-rendering functions in a list, which is
created in a "helper" file in tests/testthat
<https://github.com/daattali/ggExtra/blob/master/tests/testthat/helper-funs.R>.
That way we could source the helper file when creating the baseline
figures, and rely on this code when running the unit tests as well. I
couldn't figure out exactly when you did in tidyverse/ggplot2#1874
<tidyverse/ggplot2#1874>, but if you have
another suggestion for how users can reuse their plot-generating functions,
I think it would be a nice addition to the documentation.
3.
This may be too formal, but I was thinking it would be useful for the
package to suggest where users should save their script that renders their
baseline figures. We saved ours within in the test/testthat directory.
I that that creating a minimal example of a package that uses the vdiffr
framework inside vdiffr would address numbers 2 and 3, and number 1 is
straightforward.
Chris
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://github.com/lionel-/vdiffr/issues/16>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA6IFP0X3LnZlxNwlsUG6_zKohel2TbEks5r84GVgaJpZM4NkeSe>
.
|
Yes a testthat helper file seems like the right place. It's automatically sourced when
Why in a list instead of normally defined functions? I think for ggplot2 I was just defining a baseline plot (rather than a function generating a baseline plot) in each file then modify it from there, but I don't remember. If the baseline plots are used all over the test files it definitely makes sense to define them in a helper file. I think an introductory vignette would be a good place to help users getting up to speed. We'd love a PR! |
Putting the plot-rendering functions is a list just allowed us to call them in a loop without having to list out their names first (e.g., using
Just to clarify, I assume you are referring to where to store the plot-render functions, not the script that calls those functions. In number 3 I was actually suggesting that I'll get working on a vignette! Can I assume that |
Ah yes, makes sense.
I would just organise the code within
I guess it doesn't hurt to export it. But I'm not sure I understand your workflow. Why not develop the test within an |
Annnnnd I just realized that I totally misunderstood the intended
The reason why I thought we needed step 2 was that
Which I interpreted as meaning that we needed to create the figure. But I can see now that the expectation was that the user would use the app the first time around to create these figures...Correct? That makes a lot more sense (and would resolve all of my issues). It may make sense to explicetly suggest in the testthat warning that the user use the app to create a figure if doesn't already exist (e.g., change to "Figure not generated yet: awesomefile.svg. Use the web app to create it."), and/or adding a note about this in the README. |
Greetings -
I was recently working with @daattali on integrating visual tests into
ggExtra
using thevdiffr
framework. I wanted to get your thoughts on a few small changes that I thought may benefitvidffr
. If you like one of them, I'd be happy to work on a PR to implement it.Export
write_svg
. I initially struggled to get my visual tests to pass, mostly because the way I was saving my baseline figures (i.e., the figures in tests/figs) was different from howvdiffr
was saving the figures during the tests (viawrite_svg
). Although the behavior ofwrite_svg
is indirectly documented in the README, it took me awhile to realize that I had to mimic that behavior when creating the baseline plots. I think the easiest way to address this would be to just exportwrite_svg
, and suggest that the user use this function when saving their baseline figures.Make a suggestion as to how the user can re-use the code that creates their baseline figures when writing their unit tests. The solution that we ended up using was to save the plot-rendering functions in a list, which is created in a "helper" file in tests/testthat. That way we could
source
the helper file when creating the baseline figures, and rely on this code when running the unit tests as well. I couldn't figure out exactly when you did in Use vdiffr for visual unit tests tidyverse/ggplot2#1874, but if you have another suggestion for how users can reuse their plot-generating functions, I think it would be a nice addition to the documentation.This may be too formal, but I was thinking it would be useful for the package to suggest where users should save their script that renders their baseline figures. We saved ours within in the test/testthat directory.
I that that creating a minimal example of a package that uses the
vdiffr
framework insidevdiffr
would address numbers 2 and 3, and number 1 is straightforward.Chris
The text was updated successfully, but these errors were encountered: