-
-
Notifications
You must be signed in to change notification settings - Fork 81
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
[Suggestion] Add tests for the package check #56
Comments
Yes, I haven't found the time to just yet; hopefully sometime this year. |
I have some time to do something like that but I'm not sure of the things there are to test. We could check that the basic functions create objects that have both
What do you think? Would it be useful? I don't know what packages use |
Yes, I meant to add tests but never found the time. This would be more than welcome! Indeed, you would use testthat as you do, you cannot test the graphical fidelity only test on the object returned by |
Okay I will add some tests. As you said, there will be many things to add, so I was thinking to make several PR so that people don't have to start from scratch if they want to contribute to this (since it is not very technical once you see the first tests). Is it okay for you or do you prefer a single big PR? |
Sure, you can it a few context/files at a time if you feel like it. |
In addition to the tests of class, I wonder if it would be possible to check if the JS (or json? I don't know) code produced by Suppose you want to test if your implementation of Is it possible? Relevant? Just throwing the idea here. |
I have do some research about how to test when develop a
Also, there is an article that introduce other way to test |
|
When there is a callback function as options (for example, the p <- mtcars %>%
tibble::rownames_to_column("model") %>%
e_charts(wt) %>%
e_scatter(mpg, qsec, bind = model) %>%
e_tooltip(
formatter = htmlwidgets::JS(
"function(params){
return('<strong>' + params.name +
'</strong><br />wt: ' + params.value[0] +
'<br />mpg: ' + params.value[1])
}
"
)
)
p # plot
# extract the JSON
json <- p %>%
e_inspect(json = TRUE,
pretty = TRUE)
# print json
json the result is a JavaScript function in string format with lots of "tooltip": {
"trigger": "item",
"formatter": "function(params){\n return('<strong>' + params.name +\n '<\/strong><br />wt: ' + params.value[0] +\n '<br />mpg: ' + params.value[1])\n }\n "
}
I have try it before, but I can not enable the 3rd edition and use the snapshot testing, so I gave up and just waiting for the official release of 3.0 😢 |
I think a key thing to test is the data structure produced by echarts4r for each "geom," Tests should be rather strict, the p <- head(cars, 2) %>% e_charts(speed) %>% e_scatter(dist)
testthat::expect_equal(p$x$opts$series[[1]]$data, list(list(value = c(4, 2)), list(value = c(4, 10)))) |
Agreed, it could also be useful to add similar test for |
I suggest to add some tests to improve stability.
There are test in the other packages base on the
htmlwidgets
. The main iea to check structure of the result object.The text was updated successfully, but these errors were encountered: