Skip to content

Commit 0051d1c

Browse files
committed
tests can now handle differencing with different plotlyjs versions
1 parent 81f46c1 commit 0051d1c

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

tests/testthat.R

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ if (report_diffs || build_table) {
1212
message("Spinning up an independent R session with plotly's master branch installed")
1313
Rserve::Rserve(args = "--vanilla --RS-enable-remote")
1414
conn <- RSconnect()
15-
# master version should _always_ depend on the CRAN version of ggplot2
15+
# we don't make assumptions about ggplot2 versioning,
16+
# but it is _strongly_ recommended to use the CRAN version (of ggplot2)
1617
RSeval(conn, "devtools::install_github('ropensci/plotly')")
1718
RSeval(conn, "library(plotly)")
1819
if (report_diffs) {
@@ -23,6 +24,18 @@ if (report_diffs || build_table) {
2324
master_hash <- substr(master_hash, 1, 7)
2425
# plotly-test-table repo hosts the diff pages & keeps track of previous versions
2526
table_dir <- normalizePath("../../plotly-test-table", mustWork = T)
27+
# Make sure we have appropriate versions of plotlyjs
28+
# (see plotly-test-table/template/template/index.html)
29+
file.copy(
30+
file.path("..", "inst", "htmlwidgets", "lib", "plotlyjs", "plotly-latest.min.js"),
31+
file.path(table_dir, "template", "New.min.js"),
32+
overwrite = TRUE
33+
)
34+
download.file(
35+
"https://raw.githubusercontent.com/ropensci/plotly/master/inst/htmlwidgets/lib/plotlyjs/plotly-latest.min.js",
36+
file.path(table_dir, "template", "Old.min.js")
37+
)
38+
# directory for placing test differences
2639
this_dir <- file.path(table_dir, this_hash)
2740
if (dir.exists(this_dir)) {
2841
message("Tests were already run on this commit. Nuking the old results...")
@@ -102,7 +115,7 @@ save_outputs <- function(gg, name) {
102115
dir.create(test_dir, recursive = T)
103116
# copy over diffing template
104117
file.copy(
105-
file.path(table_dir, "template", "template", "index.html"),
118+
file.path(table_dir, "template", "index.html"),
106119
test_dir,
107120
recursive = T
108121
)

0 commit comments

Comments
 (0)