Example test validating phpinfo(), slowed down for the demo.
This repository contains an addon for integrating Playwright tests into your ddev project.
Highlights include:
- Support for pnpm.
- Support for running headless tests.
- Support for running headed tests with remote access to the UI through your web browser.
- Only installs the heavy Playwright dependencies if a given local opts in to them.
- Does not require running Playwright in ddev, in case developers prefer to run on the host on locals.
- Optimizations to reduce build time, especially on locals when ddev versions are upgraded.
ddev add-on get envsa/ddev-playwright
git add .
git add -f .ddev/config.playwright.yaml
ddev exec pnpm init playwright
# Now, install playwright dependencies and cache them for later.
ddev install-playwright
# To run playwright's test command.
ddev pnpm exec playwright test
# To run with the UI.
ddev playwright-ui (requires an npm script)
# To generate playwright code by browsing.
ddev pnpm exec playwright codegenThe following services are exposed with this addon:
| Service | URL | Notes |
|---|---|---|
| KasmVNC | https://<PROJECT>.<PROJECT_TLD>:8444 | Username is your local username. Password is secret. |
| Playwright Test Reports | https://<PROJECT>.<PROJECT_TLD>:9324 | This port is changed from the default to not conflict with running Playwright on the host. |
julienloizelet/ddev-playwright was a great inspiration for this work. It uses Playwright containers built by Microsoft for tests. A few questions on the implementation has some notes on the differences in the implementations. The main differences are:
- This addon stacks Playwright and KasmVNC into the web container. This makes accessing the system being tested (like Drupal) much easier. For example, with a Drupal site Playwright can easily call
drushor other CLI tools to set up tests. - The official containers do not ship with any sort of remote access to the Playwright UI. This repository includes KasmVNC to run tests in headed mode or to generate code.
- By stacking Playwright into the web container, it simplifies permissions for writing Playwright's test reports back out.
- We hope to be able to integrate chanzuckerberg/axe-storybook-testing in the future, which should be simplier with having Playwright's dependencies combined into the current project.