| name | playwright-e2e |
|---|---|
| description | Hybrid E2E UI testing workflow for AI coding agents (Qwen Code, Claude Code, Cursor). Use Browser MCP / Playwright MCP to EXPLORE the live app, write a Markdown test plan, and GENERATE or DEBUG Playwright Test specs — then EXECUTE the suite through the Playwright Test runner as a queue (sequential, with retries) producing HTML + JUnit artifacts and a Markdown summary. Includes a CI/CD template for GitHub Actions with a self-hosted macOS runner. Use when the user wants to create, run, or maintain interface/UI automated tests, needs queue execution with rerun-of-failed, wants Markdown artifacts per run, or wants to wire E2E into CI/CD. Do NOT use MCP as the test executor — MCP is the authoring/debugging layer only. |
Browser MCP (Playwright MCP) and Playwright Test are two different layers, not interchangeable:
| Layer | Role | Traits |
|---|---|---|
| Playwright MCP | Authoring & debugging | Interactive, explores live app, writes plan + specs, investigates failures. Token-heavy, non-deterministic. |
| Playwright Test | Execution | Queue, retries, JUnit/HTML artifacts, CI gate. Deterministic, cheap, headless. |
NEVER run the suite "through MCP" as the executor. Generate/repair specs with
MCP, then execute with npx playwright test. MCP cannot give CI a pass/fail gate,
a reproducible suite, or detached runs.
- User wants to create UI/E2E automated tests for a web app.
- User wants tests run as a queue (sequential, with retries), leaving Markdown artifacts.
- User wants a CI/CD setup (GitHub Actions, self-hosted Mac).
- User is driving the work with an AI agent + Playwright MCP.
- Connect Playwright MCP (
npx @playwright/mcp). - Explore the target flow live; write a human-readable plan to
specs/<flow>.md(steps as a numbered list — this is the "artifact" the user asked for). - Generate
tests/<flow>.spec.tsfollowingreferences/best-practices.md. - If a spec already exists but is flaky/broken, use MCP to open the app and inspect the real DOM/locators before editing.
Run the queue via the bundled script:
bash scripts/run_queue.sh --rerun-failed
# or a subset:
bash scripts/run_queue.sh --grep "checkout"The script runs npx playwright test with list + html + junit reporters,
optionally reruns only failed specs once, and converts JUnit → Markdown.
scripts/junit_to_md.py turns test-results/junit.xml into
reports/run-<timestamp>.md with a pass/fail table, durations, and failure
details + a verdict line (✅ ALL GREEN / ❌ HAS FAILURES). This is the
per-run Markdown artifact.
Drop templates/github-actions-mac.yml into .github/workflows/. It uses a
self-hosted macos runner (for Safari/WebKit fidelity), installs deps, runs the
queue with --rerun-failed, and uploads both playwright-report/ (HTML+trace)
and reports/ (Markdown) as artifacts.
scripts/run_queue.sh— queue execution + rerun-failed + artifact conversion.scripts/junit_to_md.py— JUnit XML → Markdown report.
templates/playwright.config.ts— reporters (list/html/junit),retries,trace: 'on-first-retry', screenshot/video on failure, single worker in CI.templates/github-actions-mac.yml— GitHub Actions self-hosted Mac workflow.
- No hard sleeps (
waitForTimeout(2000)) — use web-first assertions / auto-wait. - No
document.querySelectorinsideevaluate()— use locators. - No chained tests (test 2 depends on test 1) — each test self-contained.
- Prefer
getByRole/getByTestIdover CSS/XPath. - Auth via fixtures /
storageState, not re-login in every test. - Assert on behavior, not implementation; use
expect(...).toBeVisible().
- MCP-as-executor: no suite, no gate, token blow-up. Keep MCP for authoring.
- Flaky by design: fixed sleeps and chained tests produce false reds.
- Missing junit output: configure the junit reporter to a file in
playwright.config.ts, not just--reporter=junit(which prints to stdout). - Self-hosted Mac runner not registered: the workflow waits forever — verify
gh runneris online before relying on CI.
- Local:
bash scripts/run_queue.sh --rerun-failed→ expectreports/run-*.mdwith a verdict line. - CI: push a branch, open the Actions run, confirm both artifacts uploaded.
- Quality gate: fail the pipeline when
junit_to_md.pyverdict is❌ HAS FAILURES(exit code fromnpx playwright testalready does this).
This skill uses the Agent Skills standard. To use it in Qwen Code:
# from the skill directory
cp -r . ~/.qwen/skills/playwright-e2e/ # or your Qwen skills pathSKILL.md format, scripts, and templates are tool-agnostic (bash + python3 +
node). No Hermes-specific APIs are used.