The purpose of {pw}
is to streamline the use of Playwright for testing your {golem}
applications.
You can install the development version of {pw}
like so:
pak::pak("thinkr-open/pw")
- Ensure that npm (with npx) is installed on your computer.
- You must be working within a
{golem}
project. - The default test structure should be present (if not, run
usethis::use_testthat()
to set it up).
To set up Playwright testing in your {golem}
project, execute the following command:
pw::pw_init()
This function will:
- Run
npx create-playwright@latest
in thetests/playwright
folder. - Add the following files to your project:
tests/playwright/playwright.config.ts
(updated)tests/playwright/tests/default.test.ts
(created)tests/testthat/test-playwright.R
(created)
After setup, run devtools::test()
to confirm that everything is functioning correctly
To execute the Playwright tests, use the following command in R:
pw::pw_test()
To create or modify tests, edit the file tests/playwright/tests/default.test.ts
or add new test files in the same directory to extend your Playwright test suite.
For manual execution of Playwright commands, navigate to the tests/playwright
directory:
cd tests/playwright
npx playwright test
- Enable viewing of test reports directly.
Note: The full Playwright Node.js API will not be wrapped in R. For advanced use cases, you may need to run commands directly from the terminal.