generator-jhipster-playwright
v1.2.0
Published
JHipster Playwright E2E blueprint - replaces Cypress with Playwright for end-to-end testing
Downloads
340
Maintainers
Readme
generator-jhipster-playwright
A JHipster blueprint that replaces the generated Cypress end-to-end suite with Playwright.
Introduction
This is a JHipster blueprint. It overrides the cypress sub-generator and writes Playwright files instead of Cypress files for generated applications.
Supported Matrix
| Framework | JWT | Session | OAuth2 | |-----------|-----|---------|--------| | React | Yes | Yes | Yes | | Angular | Yes | Yes | Yes | | Vue | Yes | Yes | Yes |
All 9 combinations are verified in CI against freshly generated JHipster applications. OAuth2 tests run against a Keycloak instance.
Installation
npm install -g [email protected]
npm install -g generator-jhipster-playwrightUsage
How to Generate Code
This package exposes a dedicated CLI:
jhipster-playwrightIt can also be used through the standard JHipster CLI:
jhipster --blueprints playwrightFor available options, you can run:
jhipster-playwright app --helpEnable the Cypress Test Framework
This blueprint overrides JHipster's cypress sub-generator. Upstream JHipster only composes that generator when testFrameworks includes cypress, so Playwright generation must be triggered with Cypress selected.
Use one of these approaches:
jhipster --blueprints playwright --test-frameworks cypress
jhipster-playwright --test-frameworks cypress
jhipster jdl app.jdl --blueprints playwright --test-frameworks cypressYou can also express this directly in JDL:
application {
config {
baseName myApp
clientFramework react
authenticationType jwt
testFrameworks [cypress]
}
}How to Run the Generated Tests
jhipster jdl app.jdl --blueprints playwright --test-frameworks cypress --skip-install --forceAfter generation, install dependencies, install the Playwright browser, start the backend, and run the suite:
npm install
npx playwright install chromium
./mvnwIn a second terminal:
npx playwright testThe generated playwright.config.ts starts the frontend dev server automatically. The Spring Boot backend still needs to be running before the tests execute.
For OAuth2 applications, a Keycloak instance must be running before the backend starts:
docker compose -f src/main/docker/keycloak.yml up -dGenerated Output
The blueprint writes:
playwright.config.ts- Playwright support utilities under
src/test/javascript/playwright/support - Account, administration, and entity specs under
src/test/javascript/playwright/e2e @playwright/testand Playwright npm scripts in the generated application'spackage.json
For Angular applications, the blueprint also adds @popperjs/core to the generated app dependencies so the generated frontend has the required Popper peer dependency available.
For Angular session-auth applications, a custom proxy.config.playwright.mjs is generated to avoid proxying lazy-loaded route chunks.
Local Development
To work on the blueprint locally:
npm install
npm test
npm pack --dry-run --cache ./.npm-cacheTo exercise the blueprint locally against a generated app, link it first:
npm linkThen in the target app directory:
npm link generator-jhipster-playwright
jhipster --blueprints playwright --test-frameworks cypress --skip-install --forceUpdated generator-jhipster
This blueprint currently targets generator-jhipster 9.0.0.
If you want to run it through the standard JHipster CLI, install a compatible JHipster version and use:
npm install -g [email protected]
jhipster --blueprints playwright --test-frameworks cypressLicense
Apache 2.0, see LICENSE.
