playwright-e2e-mcp 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -8
- package/dist/cli/ci.js +3 -0
- package/dist/cli/ci.js.map +1 -1
- package/dist/cli/guard.d.ts +11 -0
- package/dist/cli/guard.js +80 -0
- package/dist/cli/guard.js.map +1 -0
- package/dist/cli/upload.d.ts +14 -0
- package/dist/cli/upload.js +81 -0
- package/dist/cli/upload.js.map +1 -0
- package/dist/http.d.ts +1 -1
- package/dist/http.js +1 -1
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +74 -8
- package/dist/server.js.map +1 -1
- package/dist/tools/analyze-history.d.ts +15 -0
- package/dist/tools/analyze-history.js +44 -9
- package/dist/tools/analyze-history.js.map +1 -1
- package/dist/tools/audit-accessibility.d.ts +3 -0
- package/dist/tools/audit-performance.d.ts +3 -0
- package/dist/tools/audit-performance.js +1 -1
- package/dist/tools/audit-performance.js.map +1 -1
- package/dist/tools/check-test-change.d.ts +44 -0
- package/dist/tools/check-test-change.js +132 -0
- package/dist/tools/check-test-change.js.map +1 -0
- package/dist/tools/compare-visual-state.d.ts +3 -0
- package/dist/tools/generate-e2e-test.js +1 -1
- package/dist/tools/generate-e2e-test.js.map +1 -1
- package/dist/tools/get-run-status.js +8 -2
- package/dist/tools/get-run-status.js.map +1 -1
- package/dist/tools/inspect-page.d.ts +3 -0
- package/dist/tools/inspect-page.js +9 -5
- package/dist/tools/inspect-page.js.map +1 -1
- package/dist/tools/probe-script.js +158 -10
- package/dist/tools/probe-script.js.map +1 -1
- package/dist/tools/quarantine.d.ts +61 -0
- package/dist/tools/quarantine.js +133 -0
- package/dist/tools/quarantine.js.map +1 -0
- package/dist/tools/run-test.d.ts +10 -1
- package/dist/tools/run-test.js +36 -5
- package/dist/tools/run-test.js.map +1 -1
- package/dist/tools/save-login.d.ts +142 -0
- package/dist/tools/save-login.js +264 -0
- package/dist/tools/save-login.js.map +1 -0
- package/dist/tools/shared.d.ts +30 -1
- package/dist/tools/shared.js +51 -27
- package/dist/tools/shared.js.map +1 -1
- package/dist/tools/structured.d.ts +16 -1
- package/dist/tools/structured.js +14 -1
- package/dist/tools/structured.js.map +1 -1
- package/dist/tools/suggest-fix.js +1 -1
- package/dist/tools/suggest-fix.js.map +1 -1
- package/dist/tools/validate-selector.d.ts +6 -0
- package/dist/tools/validate-selector.js +28 -5
- package/dist/tools/validate-selector.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utils/locator-expr.d.ts +3 -1
- package/dist/utils/locator-expr.js +25 -7
- package/dist/utils/locator-expr.js.map +1 -1
- package/dist/utils/pro-client.d.ts +29 -0
- package/dist/utils/pro-client.js +114 -0
- package/dist/utils/pro-client.js.map +1 -0
- package/dist/utils/quarantine.d.ts +64 -0
- package/dist/utils/quarantine.js +106 -0
- package/dist/utils/quarantine.js.map +1 -0
- package/dist/utils/test-change-guard.d.ts +69 -0
- package/dist/utils/test-change-guard.js +391 -0
- package/dist/utils/test-change-guard.js.map +1 -0
- package/dist/utils/totp.d.ts +26 -0
- package/dist/utils/totp.js +84 -0
- package/dist/utils/totp.js.map +1 -0
- package/package.json +1 -1
- package/skill/playwright-e2e-mcp/SKILL.md +46 -7
- package/skill/playwright-e2e-mcp/references/setup.md +7 -1
- package/skill/playwright-e2e-mcp/references/tools.md +43 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: playwright-e2e-mcp
|
|
3
|
-
description: Runs, debugs and fixes Playwright end-to-end tests through the playwright-e2e-mcp server
|
|
3
|
+
description: Runs, debugs and fixes Playwright end-to-end tests through the playwright-e2e-mcp server: run results grouped by root cause, trace-based failure diagnostics, verified locators, self-healing fixes that re-run and revert if still red, a heal guard that blocks fixes which pass by checking less, per-test flaky verdicts (parallelism, test order, timing), an owned, expiring flaky-test quarantine, saved logins with 2FA codes, signed-in page inspection with network mocks, tests written by walking the flow, CI report diagnosis, accessibility and Web Vitals audits and run history with the commit that broke each test. Use when the user asks to run Playwright tests, fix a failing or broken e2e test, find out why CI failed, find flaky, unstable or slow tests, repair a selector, write or review a Playwright test, log in for tests, or check a page for accessibility, performance or visual regressions.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Playwright E2E with playwright-e2e-mcp
|
|
@@ -13,7 +13,7 @@ and concrete next steps. It can also propose and apply a verified fix for a brok
|
|
|
13
13
|
locator, inspect pages behind a login, run long suites in the background and keep
|
|
14
14
|
a local history of every run.
|
|
15
15
|
|
|
16
|
-
This skill is written for playwright-e2e-mcp 0.
|
|
16
|
+
This skill is written for playwright-e2e-mcp 0.7.0 and works with 0.2.0 or
|
|
17
17
|
newer. If `suggest-fix`, `get-run-status` or `analyze-history` is missing, the
|
|
18
18
|
server is older than 0.2.0: use the steps that do not need those tools and tell
|
|
19
19
|
the user to update it. `diagnose-flaky`'s per-test table and `isolate` option
|
|
@@ -21,7 +21,8 @@ arrived in 0.3.0; `audit-accessibility`, `diagnose-flaky`'s `order` option and
|
|
|
21
21
|
root-cause grouping in `run-test` arrived in 0.4.0; `audit-performance`,
|
|
22
22
|
`load-report`, network mocks (`routes`), `har`, `browser`, `inspect-page`'s
|
|
23
23
|
`view: "aria"`, `generate-e2e-test`'s `steps`, the `slow`, `trend` and `commits`
|
|
24
|
-
history views and strict-mode fixes in `suggest-fix` arrived in 0.5.0
|
|
24
|
+
history views and strict-mode fixes in `suggest-fix` arrived in 0.5.0;
|
|
25
|
+
`save-login`, `check-test-change` and `quarantine` arrived in 0.7.0.
|
|
25
26
|
|
|
26
27
|
## Before you start
|
|
27
28
|
|
|
@@ -29,8 +30,8 @@ history views and strict-mode fixes in `suggest-fix` arrived in 0.5.0.
|
|
|
29
30
|
`get-run-status`, `get-failure`, `load-report`, `suggest-fix`, `inspect-page`,
|
|
30
31
|
`validate-selector`, `list-tests`, `generate-e2e-test`,
|
|
31
32
|
`compare-visual-state`, `audit-accessibility`, `audit-performance`,
|
|
32
|
-
`diagnose-flaky`
|
|
33
|
-
`
|
|
33
|
+
`diagnose-flaky`, `analyze-history`, `audit-tests`, `bisect-failure`,
|
|
34
|
+
`save-login`, `check-test-change` and `quarantine` (your client
|
|
34
35
|
may prefix them, e.g. `mcp__playwright-e2e__run-test`).
|
|
35
36
|
2. If they are all missing, stop and tell the user the MCP server is not
|
|
36
37
|
connected. Point them to `references/setup.md` for the one-line install for
|
|
@@ -39,7 +40,7 @@ history views and strict-mode fixes in `suggest-fix` arrived in 0.5.0.
|
|
|
39
40
|
`references/writing-tests.md`. Do not fall back to shelling out to `npx playwright test` unless
|
|
40
41
|
the user asks. If only some are missing, the server may run a smaller tool
|
|
41
42
|
profile (`--tools=core` exposes `run-test`, `get-run-status`, `get-failure`,
|
|
42
|
-
`suggest-fix`, `diagnose-flaky` and `list-tests`); work with what is there and
|
|
43
|
+
`suggest-fix`, `diagnose-flaky`, `check-test-change` and `list-tests`); work with what is there and
|
|
43
44
|
mention the profile when a task needs a page tool.
|
|
44
45
|
3. Every tool except `get-run-status` takes an optional `projectRoot`. Leave it
|
|
45
46
|
out unless the user works in a sub-project; the server defaults to `PW_MCP_PROJECT_ROOT` or its working
|
|
@@ -88,6 +89,10 @@ Follow these steps in order. Do not edit code before step 3.
|
|
|
88
89
|
- Failed network request (4xx/5xx/no response) right before the failure: the
|
|
89
90
|
backend is the likely cause; report it.
|
|
90
91
|
4. **Fix** the spec or the app code, the smallest change that addresses the cause.
|
|
92
|
+
Then call `check-test-change` (0.7.0+; no arguments checks the uncommitted
|
|
93
|
+
changes). If it says **BLOCK**, the fix made the test pass by checking less
|
|
94
|
+
(a deleted assertion, a skip, `.only`): undo that part and fix the cause. Treat
|
|
95
|
+
**WARN** findings as things to justify to the user, not to wave through.
|
|
91
96
|
5. **Re-run only what failed:** `run-test` with `{ "lastFailed": true }`. Repeat
|
|
92
97
|
from step 2 until green.
|
|
93
98
|
|
|
@@ -119,6 +124,11 @@ fresh browser, so a signed-in page shows the login screen unless you pass state:
|
|
|
119
124
|
or log credentials.
|
|
120
125
|
- `actions`: up to 20 steps after load (`click`, `fill`, `press`, `check`,
|
|
121
126
|
`select`, `hover`, `wait`, `goto`, ...) to open a modal or reach a later step.
|
|
127
|
+
Each call opens a fresh browser, so put the login steps in the same list and
|
|
128
|
+
end with a `wait` on what the state shows. Reach into an iframe with
|
|
129
|
+
`frameLocator('#frame').getByLabel('Card number')` (0.6.1+). Each step waits
|
|
130
|
+
`actionTimeoutMs` (default 10000, 0.6.1+); a failed step reports Playwright's
|
|
131
|
+
call log and the page URL, which usually name the cause (an overlay, a redirect).
|
|
122
132
|
- `routes`: up to 20 network mocks applied before load, first match wins:
|
|
123
133
|
`{ "url": "**/api/cart", "json": { "items": [] } }` for an empty state,
|
|
124
134
|
`"status": 500` for an error state, `"abort": true` to drop a third party,
|
|
@@ -131,6 +141,26 @@ fresh browser, so a signed-in page shows the login screen unless you pass state:
|
|
|
131
141
|
(it must be installed; `audit-performance` stays Chromium-only).
|
|
132
142
|
- `viewport`: `{ "width": 390, "height": 844 }` for mobile layouts.
|
|
133
143
|
|
|
144
|
+
When there is no saved session yet, or it expired, call `save-login` (0.7.0+)
|
|
145
|
+
instead of typing credentials into `actions` every time:
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{ "url": "http://localhost:3000/login",
|
|
149
|
+
"actions": [
|
|
150
|
+
{ "type": "fill", "locator": "getByLabel('Email')", "value": "qa@example.com" },
|
|
151
|
+
{ "type": "fill", "locator": "getByLabel('Password')", "value": "{{env:E2E_PASSWORD}}" },
|
|
152
|
+
{ "type": "fill", "locator": "getByLabel('Code')", "value": "{{totp}}" },
|
|
153
|
+
{ "type": "click", "locator": "getByRole('button', { name: 'Sign in' })" }],
|
|
154
|
+
"verify": { "url": "/account", "visible": "getByRole('button', { name: 'Sign out' })", "notUrl": "/login" },
|
|
155
|
+
"totpSecretEnv": "E2E_TOTP_SECRET" }
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
It saves `playwright/.auth/user.json` and reuses it while `verify` passes. Never
|
|
159
|
+
put a password in a tool argument or in chat: ask the user to set it as an
|
|
160
|
+
environment variable for the server (`E2E_*`, `TEST_*`, `LOGIN_*`, or a name
|
|
161
|
+
listed in `PW_MCP_LOGIN_ENV`) and refer to it as `{{env:NAME}}`. `{{totp}}`
|
|
162
|
+
types the current authenticator code from the secret in `totpSecretEnv`.
|
|
163
|
+
|
|
134
164
|
When a response says the page landed on a login screen, retry with
|
|
135
165
|
`storageState`. `suggest-fix` takes `storageState` and `headers` too when you heal
|
|
136
166
|
against a live `url`.
|
|
@@ -178,6 +208,14 @@ one verdict **per test** (passes, failures, duration spread, first error):
|
|
|
178
208
|
tests that flaked; `fix: true` applies the mechanical rewrites and re-runs them.
|
|
179
209
|
- **NOT REPRODUCING**: passed every run. Report that the failure was one-off.
|
|
180
210
|
|
|
211
|
+
If a FLAKY test cannot be fixed right away and is blocking other work, offer
|
|
212
|
+
`quarantine` (0.7.0+) with `action: "add"`, the test (`index` of the last run's
|
|
213
|
+
failure, or `"file › title"`), an `owner` and a `reason` (an issue link is best).
|
|
214
|
+
It keeps running and being reported, but stops failing the run until the entry
|
|
215
|
+
expires (default 14 days). Ask the user before adding one; never quarantine a
|
|
216
|
+
CONSISTENTLY FAILING test, which is a real failure. `quarantine` with no
|
|
217
|
+
arguments lists the entries and the expired ones.
|
|
218
|
+
|
|
181
219
|
When a test is FLAKY and the suite runs in parallel, call `diagnose-flaky` again
|
|
182
220
|
with `isolate: true`. It repeats the tests fully parallel, then repeats the
|
|
183
221
|
failing ones with one worker, and reads each one:
|
|
@@ -239,7 +277,7 @@ with the commit it tested. `analyze-history` views:
|
|
|
239
277
|
`selector` for one region) returns the accessibility snapshot and a
|
|
240
278
|
`toMatchAriaSnapshot` assertion to paste into a spec.
|
|
241
279
|
- **Set up CI:** when the user wants the same diagnosis on every pull request,
|
|
242
|
-
point them to the GitHub Action (`uses: xsignon-secure/E2E@v0.
|
|
280
|
+
point them to the GitHub Action (`uses: xsignon-secure/E2E@v0.7.0`) or the
|
|
243
281
|
`npx -y playwright-e2e-mcp ci` command in `references/setup.md`. It writes the
|
|
244
282
|
run, flaky verdicts and fix diffs to the job summary and one PR comment.
|
|
245
283
|
- **Accessibility:** `audit-accessibility` with `url` runs axe-core against
|
|
@@ -279,6 +317,7 @@ When you finish, tell the user, in this order:
|
|
|
279
317
|
|
|
280
318
|
- Do not raise timeouts, add retries, add `waitForTimeout`, or delete or
|
|
281
319
|
`test.skip` a test to make a run green, unless the user explicitly asks.
|
|
320
|
+
`check-test-change` catches these; run it after every test edit.
|
|
282
321
|
- Do not accept a new visual baseline without the user's confirmation.
|
|
283
322
|
- Do not pass `allowExpectationUpdate: true` to `suggest-fix` unless the user
|
|
284
323
|
confirms the new text is intended; a changed expected value can be a real bug.
|
|
@@ -82,6 +82,8 @@ Set these in the server's `env` block. None of them are secrets except
|
|
|
82
82
|
| `PW_MCP_BLOCK_PRIVATE_URLS` | off for stdio | `1` makes the URL tools refuse loopback, private-network and cloud-metadata addresses |
|
|
83
83
|
| `PW_MCP_STORAGE_STATE` | none | Default Playwright storageState JSON (inside the project) for the page tools, so signed-in pages open logged in |
|
|
84
84
|
| `PW_MCP_SHUFFLE_SEEDS` | random | Seeds for `diagnose-flaky`'s `order` pass (comma separated), to replay reported orders |
|
|
85
|
+
| `PW_MCP_LOGIN_ENV` | — | Extra variables `save-login` may type through `{{env:NAME}}`, comma separated (default: only `E2E_*`, `TEST_*`, `PW_*`, `PLAYWRIGHT_*`, `LOGIN_*`) |
|
|
86
|
+
| `PW_MCP_PRO_KEY` / `PW_MCP_PRO_URL` | — | Optional paid Pro: CI runs uploaded with `upload` show up in `analyze-history` (`source: both`). Unset = no network calls |
|
|
85
87
|
| `PW_MCP_HISTORY` | on | `0` stops recording runs to `<project>/.playwright-e2e-mcp/history.jsonl` (this turns off `analyze-history`) |
|
|
86
88
|
| `LOG_LEVEL` | `info` | `debug`, `info`, `warn`, `error` or `silent` |
|
|
87
89
|
| `PW_MCP_HTTP_TOKEN` | none | HTTP bridge only: bearer token that unlocks all tools |
|
|
@@ -112,7 +114,7 @@ Exit code 0 means passed, 1 tests failed, 2 the run itself failed. On GitHub
|
|
|
112
114
|
Actions it also writes to the job summary. As an Action:
|
|
113
115
|
|
|
114
116
|
```yaml
|
|
115
|
-
- uses: xsignon-secure/E2E@v0.
|
|
117
|
+
- uses: xsignon-secure/E2E@v0.7.0
|
|
116
118
|
with:
|
|
117
119
|
flaky-runs: 3
|
|
118
120
|
suggest: 2
|
|
@@ -120,3 +122,7 @@ Actions it also writes to the job summary. As an Action:
|
|
|
120
122
|
|
|
121
123
|
It keeps one PR comment up to date when the run fails (needs
|
|
122
124
|
`pull-requests: write`).
|
|
125
|
+
|
|
126
|
+
From 0.7.0, `npx -y playwright-e2e-mcp guard --base origin/main` (or the
|
|
127
|
+
Action's `guard: true` input) fails the job when a changed test was made to
|
|
128
|
+
pass by checking less, and `ci` honours `playwright-quarantine.json`.
|
|
@@ -68,7 +68,8 @@ becomes the last run for `get-failure`, `suggest-fix` and `diagnose-flaky`.
|
|
|
68
68
|
| `view` | `elements` \| `locators` \| `aria` | `locators`: compact map of interactive elements with verified locators; `aria` (0.5.0+): accessibility snapshot of the page or of `selector`, with a `toMatchAriaSnapshot` assertion |
|
|
69
69
|
| `storageState` | string | Playwright storageState JSON inside the project (signed-in session); defaults to `PW_MCP_STORAGE_STATE` |
|
|
70
70
|
| `headers` | object | Extra HTTP headers |
|
|
71
|
-
| `actions` | array | Up to 20 steps after load: `{ type: click\|dblclick\|fill\|press\|check\|uncheck\|select\|hover\|wait\|goto, locator?, value?, url?, ms? }` |
|
|
71
|
+
| `actions` | array | Up to 20 steps after load: `{ type: click\|dblclick\|fill\|press\|check\|uncheck\|select\|hover\|wait\|goto, locator?, value?, url?, ms? }`. Locators may start with `frameLocator('#frame')` or use `.contentFrame()` for iframes (0.6.1+) |
|
|
72
|
+
| `actionTimeoutMs` | number | How long each action waits for its element (0.6.1+, default 10000) |
|
|
72
73
|
| `routes` | array | Up to 20 network mocks before load, first match wins: `{ url (glob), method?, status?, json? \| body?, contentType?, headers?, abort?, delayMs? }` (0.5.0+). The result reports hits per mock |
|
|
73
74
|
| `har` | object | `{ path, mode?: replay\|record, url?, notFound?: abort\|fallback }` (0.5.0+): replay requests from a HAR inside the project, or record the traffic to one. `routes` still win |
|
|
74
75
|
| `browser` | `chromium` \| `firefox` \| `webkit` | Engine (0.5.0+, default chromium); must be installed |
|
|
@@ -277,3 +278,44 @@ mechanically. Files rank by findings weighted by their flaky rate in the history
|
|
|
277
278
|
Runs in a temporary git worktree with the current `node_modules` linked in;
|
|
278
279
|
untestable commits are skipped. `status` is `found`, `ambiguous`, `max-steps`,
|
|
279
280
|
`not-failing` (passes at bad) or `good-fails`.
|
|
281
|
+
|
|
282
|
+
## save-login (0.7.0+)
|
|
283
|
+
|
|
284
|
+
| Argument | Type | Notes |
|
|
285
|
+
| --- | --- | --- |
|
|
286
|
+
| `url` | string | Login page (required) |
|
|
287
|
+
| `actions` | array | Login steps as in `inspect-page`; fill values may use `{{env:NAME}}` and `{{totp}}` |
|
|
288
|
+
| `verify` | object | `url` (page to check, e.g. `/account`), `visible` (locator only a signed-in user sees), `notUrl` (bad if the URL contains it, e.g. `/login`) |
|
|
289
|
+
| `name` / `path` | string | Saved to `playwright/.auth/<name>.json` (default `user`) or `path` |
|
|
290
|
+
| `totpSecretEnv` | string | Variable holding the authenticator secret (base32 or `otpauth://`) |
|
|
291
|
+
| `reuse` | boolean | Keep a saved session that still passes `verify` (default true) |
|
|
292
|
+
|
|
293
|
+
`status` is `saved`, `valid` (reused, nothing typed) or `failed` (no file written).
|
|
294
|
+
Only `E2E_*`, `TEST_*`, `PW_*`, `PLAYWRIGHT_*`, `LOGIN_*` and names in
|
|
295
|
+
`PW_MCP_LOGIN_ENV` can be read through `{{env:…}}`.
|
|
296
|
+
|
|
297
|
+
## check-test-change (0.7.0+)
|
|
298
|
+
|
|
299
|
+
| Argument | Type | Notes |
|
|
300
|
+
| --- | --- | --- |
|
|
301
|
+
| `base` | string | Git ref (default `HEAD`: the uncommitted changes; `origin/main` for the branch) |
|
|
302
|
+
| `files` | string[] | Only these files |
|
|
303
|
+
| `file` + `after` | string | Check a proposed full file content before writing it |
|
|
304
|
+
|
|
305
|
+
`status` is `OK`, `WARN` or `BLOCK`; `ok` is false only on BLOCK. BLOCK: fewer
|
|
306
|
+
assertions in a test, a removed or skipped test, `.only`, a deleted spec. WARN:
|
|
307
|
+
`expect.soft`, a weaker matcher, `waitForTimeout`, `force: true`, a swallowed
|
|
308
|
+
error, a raised timeout, retries or screenshot tolerance.
|
|
309
|
+
|
|
310
|
+
## quarantine (0.7.0+)
|
|
311
|
+
|
|
312
|
+
| Argument | Type | Notes |
|
|
313
|
+
| --- | --- | --- |
|
|
314
|
+
| `action` | string | `list` (default), `add`, `remove` |
|
|
315
|
+
| `test` | string | `'file › title'`; or `file` + `title`; or `index` (last run's failure) |
|
|
316
|
+
| `owner` / `reason` | string | Required for `add` |
|
|
317
|
+
| `days` | number | 1–90, default 14 |
|
|
318
|
+
|
|
319
|
+
Stored in `playwright-quarantine.json` (commit it). A quarantined, unexpired
|
|
320
|
+
failure is listed under 🧊 and does not fail `run-test` or `ci`; `run.quarantined`
|
|
321
|
+
counts them. Expired entries block again.
|