Package 'pw'

Title: Test your 'golem' Apps with 'Playwright'
Description: Test your 'golem' Apps with 'Playwright'.
Authors: Colin Fay [aut, cre] (ORCID: <https://orcid.org/0000-0001-7343-1846>)
Maintainer: Colin Fay <[email protected]>
License: MIT + file LICENSE
Version: 0.0.0.9019
Built: 2026-09-30 19:37:06 UTC
Source: https://github.com/ThinkR-open/pw

Help Index


Check if 'npx' is available in the system PATH

Description

Check if 'npx' is available in the system PATH

Usage

npx_is_available()

stop_if_npx_not_available()

Value

TRUE if 'npx' is available, FALSE otherwise

Examples

npx_is_available()

Run the code generator

Description

This function runs the Playwright code generator.

Usage

pw_codegen(where = golem::get_golem_wd(), R_path = NULL, ...)

Arguments

where

The root directory of your golem project

R_path

The path to the R executable

...

args passed to npx playwright codegen


Initialize Playwright

Description

This function initializes a Playwright project in the tests folder.

Usage

pw_init(
  where = golem::get_golem_wd(),
  create_playwright_version = "1.17.138",
  create_playwright_args = c("--no-examples", "--quiet")
)

Arguments

where

The path to the package

create_playwright_version

Version of create-playwright to use

create_playwright_args

Additional arguments to pass to npx create-playwright

Examples

## Not run: 
pw_init()

## End(Not run)

Install playwright in an already inited project

Description

This function runs playwright init in a project that has been previously initiated with {pw}

Usage

pw_install(where = golem::get_golem_wd())

Arguments

where

The path to the package


Show the Playwright report

Description

Show the Playwright report

Usage

pw_show_report(where = golem::get_golem_wd(), ...)

Arguments

where

The path to the package

...

Additional arguments to pass to ⁠npx playwright show-report⁠


Run Playwright tests

Description

Run Playwright tests

Usage

pw_test(where = golem::get_golem_wd(), ...)

Arguments

where

The path to the package

...

Additional arguments to pass to ⁠npx playwright test⁠


Add the Gihub Action YAML for Playwright

Description

Add the Gihub Action YAML for Playwright

Usage

pw_use_github_action()

Value

Used for side effect

Examples

if (FALSE){
  pw_use_github_action()
}

Add a new Playwright test

Description

This function adds a new Playwright test file to the tests/playwright/tests directory.

Usage

pw_use_test(name, where = golem::get_golem_wd())

Arguments

name

The name of the test to add (without .test.ts extension)

where

The path to the package


Add a data-testid attribute to a tag

Description

This function adds a data-testid attribute to a shiny tag. This is useful for testing with getByTestId in Playwright.

Usage

with_test_id(tag, test_id)

Arguments

tag

A shiny tag

test_id

A string to use as the value of the data-testid attribute

Value

A shiny tag with the data-testid attribute added