Skip to content

Commit a63e708

Browse files
committed
feat: pw_show_report
1 parent ab82719 commit a63e708

File tree

7 files changed

+88
-3
lines changed

7 files changed

+88
-3
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: pw
22
Title: Test your 'golem' Apps with 'Playwright'
3-
Version: 0.0.0.9006
3+
Version: 0.0.0.9007
44
Authors@R:
55
person("Colin", "Fay", , "[email protected]", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0001-7343-1846"))

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
export(npx_is_available)
44
export(pw_codegen)
55
export(pw_init)
6+
export(pw_show_report)
67
export(pw_test)
78
export(stop_if_npx_not_available)
89
importFrom(cli,cat_line)

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# pw (development version)
22

3+
* `pw_show_report()` can be called to open the test report
4+
35
* `pw_codegen()` can be called to launch the code generator
46

57
* `pw_test()` stops if the playwright skeleton is missing

R/pw_show_report.R

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#' Show the Playwright report
2+
#'
3+
#' @param where The path to the package
4+
#' @param ... Additional arguments to pass to `npx playwright show-report`
5+
#' @importFrom withr with_dir
6+
#' @export
7+
pw_show_report <- function(
8+
where = golem::get_golem_wd(),
9+
...
10+
){
11+
stop_if_npx_not_available()
12+
stop_if_playwright_skeleton_not_present(
13+
where = where
14+
)
15+
with_dir(
16+
where,
17+
{
18+
with_dir(
19+
"tests",
20+
{
21+
with_dir(
22+
"playwright",
23+
{
24+
system2(
25+
"npx",
26+
c(
27+
"playwright",
28+
"show-report",
29+
...
30+
)
31+
)
32+
}
33+
)
34+
}
35+
)
36+
}
37+
)
38+
}

man/pw_codegen.Rd

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/pw_show_report.Rd

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-pw-init-test.R renamed to tests/testthat/test-pw-init-test-show-report.R

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ test_that("multiplication works", {
77
unlink(temp_golem, recursive = TRUE)
88
})
99
options("usethis.quiet" = TRUE)
10-
res <- golem::create_golem(
10+
ftr_report <- golem::create_golem(
1111
path = temp_golem,
1212
package_name = "pwtest",
1313
open = FALSE,
@@ -72,4 +72,28 @@ test_that("multiplication works", {
7272
)
7373
}
7474
)
75+
withr::with_dir(
76+
temp_golem,
77+
{
78+
future::plan(future::multisession)
79+
pw_show_report_ <- force(pw_show_report)
80+
ftr_report <- future::future({
81+
pw_show_report_(where = ".", "--port=8787")
82+
})
83+
on.exit({
84+
tools::pskill(
85+
ftr_report$workers[[ftr_report$node]]$session_info$process$pid
86+
)
87+
})
88+
Sys.sleep(1)
89+
expect_true(
90+
attr(
91+
curlGetHeaders(
92+
"http://localhost:8787"
93+
),
94+
"status"
95+
) == 200
96+
)
97+
}
98+
)
7599
})

0 commit comments

Comments
 (0)