playwright-e2e-mcp 0.4.2 → 0.5.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.
Files changed (50) hide show
  1. package/README.md +175 -33
  2. package/dist/http.d.ts +1 -1
  3. package/dist/http.js +1 -1
  4. package/dist/server.d.ts +2 -2
  5. package/dist/server.js +31 -4
  6. package/dist/server.js.map +1 -1
  7. package/dist/tools/analyze-history.d.ts +12 -1
  8. package/dist/tools/analyze-history.js +89 -5
  9. package/dist/tools/analyze-history.js.map +1 -1
  10. package/dist/tools/audit-accessibility.d.ts +85 -0
  11. package/dist/tools/audit-accessibility.js +4 -1
  12. package/dist/tools/audit-accessibility.js.map +1 -1
  13. package/dist/tools/audit-performance.d.ts +333 -0
  14. package/dist/tools/audit-performance.js +377 -0
  15. package/dist/tools/audit-performance.js.map +1 -0
  16. package/dist/tools/compare-visual-state.d.ts +84 -0
  17. package/dist/tools/generate-e2e-test.d.ts +90 -0
  18. package/dist/tools/generate-e2e-test.js +223 -34
  19. package/dist/tools/generate-e2e-test.js.map +1 -1
  20. package/dist/tools/get-failure.js +2 -1
  21. package/dist/tools/get-failure.js.map +1 -1
  22. package/dist/tools/inspect-page.d.ts +94 -0
  23. package/dist/tools/inspect-page.js +42 -5
  24. package/dist/tools/inspect-page.js.map +1 -1
  25. package/dist/tools/load-report.d.ts +48 -0
  26. package/dist/tools/load-report.js +167 -0
  27. package/dist/tools/load-report.js.map +1 -0
  28. package/dist/tools/probe-script.d.ts +7 -0
  29. package/dist/tools/probe-script.js +256 -7
  30. package/dist/tools/probe-script.js.map +1 -1
  31. package/dist/tools/shared.d.ts +137 -2
  32. package/dist/tools/shared.js +151 -7
  33. package/dist/tools/shared.js.map +1 -1
  34. package/dist/tools/suggest-fix.d.ts +35 -1
  35. package/dist/tools/suggest-fix.js +197 -17
  36. package/dist/tools/suggest-fix.js.map +1 -1
  37. package/dist/tools/validate-selector.d.ts +84 -0
  38. package/dist/tools/validate-selector.js +7 -1
  39. package/dist/tools/validate-selector.js.map +1 -1
  40. package/dist/types/index.d.ts +28 -0
  41. package/dist/utils/report-parser.d.ts +28 -3
  42. package/dist/utils/report-parser.js +77 -11
  43. package/dist/utils/report-parser.js.map +1 -1
  44. package/dist/utils/run-history.d.ts +66 -3
  45. package/dist/utils/run-history.js +149 -3
  46. package/dist/utils/run-history.js.map +1 -1
  47. package/package.json +2 -2
  48. package/skill/playwright-e2e-mcp/SKILL.md +71 -15
  49. package/skill/playwright-e2e-mcp/references/setup.md +1 -1
  50. package/skill/playwright-e2e-mcp/references/tools.md +67 -6
@@ -38,6 +38,23 @@ Returns the message and code frame, expected vs actual, stack, failure kind and
38
38
  diagnosis, console output, the DOM snapshot at failure with the failed action and
39
39
  its selector, failed network requests, console errors and warnings, and next steps.
40
40
 
41
+ ## load-report
42
+
43
+ Loads a run from CI (0.5.0+) so the other tools work on it.
44
+
45
+ | Argument | Type | Notes |
46
+ | --- | --- | --- |
47
+ | `report` | string | Required: JSON report inside the project, or a folder of blob-report zips from sharded jobs (merged with `playwright merge-reports`) |
48
+ | `traceDirs` | string[] | Where the job's `test-results` artifact was unpacked (default: the report's folder and its parent) |
49
+ | `commit`, `branch` | string | Override the report metadata |
50
+ | `record` | boolean | Add the run to the history (default true) |
51
+ | `timeoutMs` | number | Limit for merging blob reports (default 120000) |
52
+
53
+ CI paths are mapped onto the checkout (the CI root is the folder of the
54
+ report's config file). Returns the usual run result headed "Imported run", the
55
+ source, commit and build link, and how many failures have a trace. The run
56
+ becomes the last run for `get-failure`, `suggest-fix` and `diagnose-flaky`.
57
+
41
58
  ## inspect-page
42
59
 
43
60
  | Argument | Type | Notes |
@@ -48,16 +65,21 @@ its selector, failed network requests, console errors and warnings, and next ste
48
65
  | `waitUntil` | `load` \| `domcontentloaded` \| `networkidle` | Navigation wait |
49
66
  | `includeHtml` | boolean | Include rendered HTML (capped by `maxHtmlChars`, default 20000) |
50
67
  | `timeoutMs` | number | Default 45000 |
51
- | `view` | `elements` \| `locators` | `locators`: compact map of interactive elements with verified locators |
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 |
52
69
  | `storageState` | string | Playwright storageState JSON inside the project (signed-in session); defaults to `PW_MCP_STORAGE_STATE` |
53
70
  | `headers` | object | Extra HTTP headers |
54
71
  | `actions` | array | Up to 20 steps after load: `{ type: click\|dblclick\|fill\|press\|check\|uncheck\|select\|hover\|wait\|goto, locator?, value?, url?, ms? }` |
72
+ | `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
+ | `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
+ | `browser` | `chromium` \| `firefox` \| `webkit` | Engine (0.5.0+, default chromium); must be installed |
55
75
  | `viewport` | object | `{ width, height }` |
56
76
 
57
77
  Returns each element's Playwright locators proven unique on the page (role +
58
78
  name first), unique CSS selector, tag, visibility, box, text and attributes,
59
- plus console messages. `validate-selector` and `compare-visual-state` take the
60
- same `storageState`, `headers`, `actions` and `viewport`.
79
+ plus console messages. `validate-selector`, `compare-visual-state`,
80
+ `audit-accessibility` and `audit-performance` take the same `storageState`,
81
+ `headers`, `actions`, `routes`, `har`, `browser` and `viewport`
82
+ (`audit-performance` is Chromium-only).
61
83
 
62
84
  ## validate-selector
63
85
 
@@ -92,8 +114,17 @@ Falls back to a source scan when Playwright cannot list (broken install or spec)
92
114
  | `write` | boolean | Write to disk (default true) |
93
115
  | `overwrite` | boolean | Replace a spec this tool generated earlier |
94
116
  | `liveInspect` | boolean | Cross-check selectors on the live page |
117
+ | `steps` | array | Walk the flow (0.5.0+): up to 30 steps in the `actions` format, run on the live page first |
118
+ | `assertScope` | string | With `steps`: CSS scope of the end-state aria snapshot (default `body`) |
119
+ | `storageState` | string | With `steps`: session for the walk, also set in the spec with `test.use` |
120
+ | `verify`, `project`, `timeoutMs` | | With `steps`: run the written spec once (default true) |
95
121
  | `config` | string | As above |
96
122
 
123
+ With `steps`, a step that fails on the live page stops the walk and nothing is
124
+ written. Otherwise the spec replays the steps and asserts the URL path and the
125
+ aria snapshot where the flow landed (its headings when it is over 60 lines),
126
+ then runs once; a failing first run keeps the file and shows the error.
127
+
97
128
  ## compare-visual-state
98
129
 
99
130
  | Argument | Type | Notes |
@@ -141,7 +172,7 @@ Runs axe-core (0.4.0+) on a live page and returns WCAG violations, worst first.
141
172
  | `standard` | `wcag2a` \| `wcag2aa` \| `wcag21aa` \| `wcag22aa` \| `best-practice` \| `all` | Default `wcag22aa` (WCAG 2.0 to 2.2, A and AA) |
142
173
  | `minImpact` | `critical` \| `serious` \| `moderate` \| `minor` | Hide violations below this impact |
143
174
  | `selector` | string | Audit only this part of the page |
144
- | `storageState`, `headers`, `actions`, `viewport` | | As `inspect-page` |
175
+ | `storageState`, `headers`, `actions`, `routes`, `viewport` | | As `inspect-page` |
145
176
  | `waitFor`, `waitUntil`, `timeoutMs` | | `waitUntil` default `load`; `timeoutMs` default 60000 |
146
177
 
147
178
  Each violation has its rule id, impact, WCAG criteria, a help link, up to three
@@ -149,6 +180,27 @@ offending elements as verified locators with what to change, and the count of
149
180
  the rest. The result ends with an `@axe-core/playwright` check to paste into
150
181
  the spec.
151
182
 
183
+ ## audit-performance
184
+
185
+ Measures lab Web Vitals (0.5.0+) in headless Chromium.
186
+
187
+ | Argument | Type | Notes |
188
+ | --- | --- | --- |
189
+ | `url` | string | Required |
190
+ | `throttle` | `none` \| `mobile` | `mobile`: 412×823 touch viewport, 4x CPU slowdown, slow 4G (Lighthouse's mobile preset) |
191
+ | `cpuSlowdown` | number | Override the CPU factor, 1 to 20 |
192
+ | `runs` | number | 1 to 5 loads, median reported (default 1) |
193
+ | `budgets` | object | `{ lcpMs, cls, inpMs, tbtMs, fcpMs, ttfbMs, transferKb, requests }`; turns the verdict into pass/fail |
194
+ | `settleMs` | number | Observe this long after load (default 1500) |
195
+ | `storageState`, `headers`, `actions`, `routes`, `viewport` | | As `inspect-page`; clicks and key presses in `actions` are measured as INP |
196
+ | `waitFor`, `waitUntil`, `timeoutMs` | | `waitUntil` default `load`; `timeoutMs` per run, default 60000 |
197
+
198
+ Returns a table of LCP, CLS, INP (only when `actions` ran), TBT, FCP and TTFB
199
+ rated good / needs improvement / poor (or against the budgets), what to fix
200
+ (the LCP element and the shifted elements as verified locators, long tasks,
201
+ render-blocking requests), transfer size by type, the heaviest requests and
202
+ third-party weight, and a Playwright test asserting LCP and CLS budgets.
203
+
152
204
  ## suggest-fix
153
205
 
154
206
  | Argument | Type | Notes |
@@ -157,9 +209,15 @@ the spec.
157
209
  | `apply` | boolean | Write the fix (default false: diff only) |
158
210
  | `verify` | boolean | After applying, re-run and revert if still failing (default true) |
159
211
  | `allowExpectationUpdate` | boolean | Allow applying a changed expected text (default false) |
212
+ | `candidate` | number | Strict mode violation: which listed match the test meant (0.5.0+) |
160
213
  | `url`, `storageState`, `headers` | | Heal against a live page instead of the trace snapshot |
161
214
  | `config`, `timeoutMs` | | As `run-test` |
162
215
 
216
+ For a strict mode violation (0.5.0+) it uses the unique locator Playwright
217
+ printed for the intended match: the exact-name match with `high` confidence, or
218
+ the `candidate` you pass with `medium`; with equal matches and no `candidate`
219
+ it lists them and changes nothing.
220
+
163
221
  Returns a unified diff: a locator fix rated `high` or `medium` confidence, or an
164
222
  expectation update rated `low` that is applied only with
165
223
  `allowExpectationUpdate: true`. Otherwise it refuses and says the element is most
@@ -177,10 +235,13 @@ likely missing.
177
235
 
178
236
  | Argument | Type | Notes |
179
237
  | --- | --- | --- |
180
- | `view` | `flaky` \| `patterns` \| `test` | Default `flaky` |
238
+ | `view` | `flaky` \| `patterns` \| `slow` \| `trend` \| `commits` \| `test` | Default `flaky`. `slow`, `trend` and `commits` are 0.5.0+ |
181
239
  | `test` | string | Substring of a test's file or title |
182
240
  | `lastRuns` | number | Default 30 |
183
241
  | `limit` | number | Default 15 |
184
242
 
185
243
  Reads `.playwright-e2e-mcp/history.jsonl`, written by every run
186
- (`PW_MCP_HISTORY=0` disables it).
244
+ (`PW_MCP_HISTORY=0` disables it). `slow` lists tests by median duration in
245
+ passing runs and flags ones that got slower; `trend` shows failed and flaky
246
+ executions per day; `commits` names, per failing or flaky test, the first bad
247
+ commit after its last passing streak and the last good one.