Skip to content

feat: pw_install #7

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: pw
Title: Test your 'golem' Apps with 'Playwright'
Version: 0.0.0.9009
Version: 0.0.0.9010
Authors@R:
person("Colin", "Fay", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-7343-1846"))
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
export(npx_is_available)
export(pw_codegen)
export(pw_init)
export(pw_install)
export(pw_show_report)
export(pw_test)
export(stop_if_npx_not_available)
Expand Down
14 changes: 8 additions & 6 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# pw (development version)

* `with_test_id()` adds a `data-testid` attribute to a shiny tag. This is useful for testing with `getByTestId` in Playwright.
- `pw_install()` run both `npm install` & `npx playwright install` in the test directory. This is mainly to be used when a package has been inited somewhere else.

* `pw_show_report()` can be called to open the test report
- `with_test_id()` adds a `data-testid` attribute to a shiny tag. This is useful for testing with `getByTestId` in Playwright.

* `pw_codegen()` can be called to launch the code generator
- `pw_show_report()` can be called to open the test report

* `pw_test()` stops if the playwright skeleton is missing
- `pw_codegen()` can be called to launch the code generator

* Functions to test if npx is in the PATH
- `pw_test()` stops if the playwright skeleton is missing

* Initial version with `pw_init()` & `pw_test()`
- Functions to test if npx is in the PATH

- Initial version with `pw_init()` & `pw_test()`
50 changes: 50 additions & 0 deletions R/pw_install.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#' Install playwright in an already inited project
#'
#' This function runs playwright init in a project
#' that has been previously initiated with `{pw}`
#'
#' @inheritParams pw_init
#'
#' @export

pw_install <- function(
where = golem::get_golem_wd()
) {
stop_if_npx_not_available()
playwright_test_folder <- file.path(
where,
"tests",
"playwright"
)
if (
Negate(dir.exists)(
playwright_test_folder
)
) {
stop(
"The playwright test folder doesn't exist, please run pw_init() first."
)
}
withr::with_dir(
playwright_test_folder,
{
system2(
"npm",
c(
"install"
)
)
system2(
"npx",
c(
"playwright",
"install"
)
)
}
)
}

list("foo", {
"bar"
})
15 changes: 15 additions & 0 deletions man/pw_install.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading