pwtgen
v2.3.13
Published
AI-Powered Playwright Test Generator CLI - Modernized
Downloads
214
Readme
pwtgen: Playwright MCP-Powered Test Generator CLI (with RAG)
pwtgen is a CLI tool for generating Playwright tests directly from Jira tickets using the Playwright MCP server, now enhanced with RAG (Retrieval-Augmented Generation).
Jira card → RAG (KB context) → Playwright MCP server → Playwright test file
- Only the Playwright MCP server is used for test generation.
- RAG retrieves relevant selectors, workflows, and patterns from your knowledge base and includes them in the prompt sent to the MCP server.
- The CLI sends Jira card contents and KB context to the Playwright MCP server, which generates a ready-to-run Playwright test file.
Onboarding Checklist (Playwright MCP + RAG)
- Install dependencies:
npm install - Set up your
.envfile with required credentials (seedocs/environment.md).- Ensure your OpenAI API key is set for RAG embedding.
- Configure your Playwright MCP server in
mcp.json:{ "mcpServers": { "playwright": { "command": "npm", "args": ["run", "mcp:playwright"] } } }- The CLI will validate your MCP config and provide clear error messages if missing or invalid.
- Run the MCP server (the CLI will start it automatically during test generation).
- New: During onboarding (
pwtgen wizard), you can now capture a snapshot of any page for context embeddings:- You will be prompted for a URL.
- Playwright will navigate to the URL, capture the full HTML, and save it as
snapshot.html. - The snapshot is automatically added to your knowledge base for future embeddings.
- Use
pwtgen gen --mcpto generate tests from Jira tickets:pwtgen gen --mcp --ticket <JIRA_KEY>- The CLI will send the Jira card contents and KB context to the Playwright MCP server and save the generated test to
tests/e2e/<JIRA_KEY>.spec.ts.
- The CLI will send the Jira card contents and KB context to the Playwright MCP server and save the generated test to
- Review and edit generated tests as needed.
- Refer to CLI usage and environment setup guides for troubleshooting.
Quickstart (Playwright MCP + RAG)
Install globally:
npm install -g pwtgenOr run directly with npx:
npx pwtgen gen --mcp --ticket <JIRA_KEY>CLI Commands & Example Usage
pwtgen gen --mcp --ticket <JIRA_KEY>- Uses RAG to retrieve KB context, sends Jira card and KB context to the Playwright MCP server, and generates a Playwright test file.
- Example:
pwtgen gen --mcp --ticket QA-123 # Output: tests/e2e/QA-123.spec.ts
pwtgen wizard- Interactive onboarding wizard for first-time setup and configuration.
- New: Includes a step to capture a page snapshot for context embeddings.
Troubleshooting
- Missing MCP config: The CLI will show a clear error and copy-paste instructions for setup.
- MCP server not running: The CLI will attempt to start the server automatically and report any issues.
- Test not generated: Ensure your Jira card has sufficient details, KB is populated, and the MCP server is configured correctly.
Advanced Usage
- Only the Playwright MCP server is supported for test generation. RAG is used to enhance prompts with KB context.
- Knowledge base and RAG features are for embedding and reference, and now directly inform test generation.
- Page snapshot onboarding: Use the wizard to capture and embed page context for richer test generation.
For more details, see:
docs/CLI-USAGE-GUIDE.mddocs/architecture.mddocs/environment.md
