playwright-performance-regression 0.1.0-next.3 → 1.0.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 (37) hide show
  1. package/CHANGELOG.md +388 -0
  2. package/README.md +53 -41
  3. package/dist/{chunk-MUZFQKGQ.js → chunk-4WX3Z5MJ.js} +321 -30
  4. package/dist/{chunk-AQ2XKYNV.js → chunk-5Y34Q4DR.js} +37 -9
  5. package/dist/chunk-B4XTLSRN.js +1788 -0
  6. package/dist/{chunk-44ASXVQN.cjs → chunk-PWK5XSP2.cjs} +337 -45
  7. package/dist/{chunk-DYLCGMI2.js → chunk-S6UH6QPK.js} +6 -1
  8. package/dist/{chunk-BAOTUUTV.cjs → chunk-VREOANPX.cjs} +75 -28
  9. package/dist/{chunk-2JO5HVPC.cjs → chunk-W7NEFS5V.cjs} +37 -9
  10. package/dist/{chunk-DX36GFOZ.js → chunk-YKBX6SAT.js} +94 -57
  11. package/dist/cli.js +1922 -3307
  12. package/dist/config.cjs +58 -120
  13. package/dist/config.d.cts +2 -3
  14. package/dist/config.d.ts +2 -3
  15. package/dist/config.js +48 -110
  16. package/dist/fixture.cjs +9 -5
  17. package/dist/fixture.d.cts +10 -4
  18. package/dist/fixture.d.ts +10 -4
  19. package/dist/fixture.js +4 -4
  20. package/dist/index.cjs +3 -3
  21. package/dist/index.d.cts +22 -10
  22. package/dist/index.d.ts +22 -10
  23. package/dist/index.js +1 -1
  24. package/dist/perf-api-2DH_keLh.d.cts +17 -0
  25. package/dist/perf-api-2DH_keLh.d.ts +17 -0
  26. package/dist/reporter.cjs +2046 -835
  27. package/dist/reporter.js +6741 -1737
  28. package/dist/test.cjs +4 -4
  29. package/dist/test.js +4 -4
  30. package/package.json +17 -3
  31. package/schemas/config.schema.json +29 -14
  32. package/schemas/outcome.schema.json +1 -1
  33. package/schemas/run-report.schema.json +16 -2
  34. package/schemas/samples.schema.json +48 -2
  35. package/dist/chunk-LTRHMBVY.js +0 -5592
  36. package/dist/perf-api-Rm1h1O_-.d.cts +0 -12
  37. package/dist/perf-api-Rm1h1O_-.d.ts +0 -12
package/CHANGELOG.md CHANGED
@@ -7,6 +7,394 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.0.0] - 2026-11-23
11
+
12
+ The first stable release, published under the `latest` dist-tag: install with
13
+ `npm init playwright-performance-regression`. From now on the project follows semantic versioning
14
+ strictly (breaking changes only in a new major version). Upgrading from `0.1.0-next.4`: see
15
+ [Upgrading](docs/upgrading.md#from-010-nextx-to-100); in short, prune the thresholds entries of
16
+ the newly skipped realtime transports and keep or copy your CI jobs yourself.
17
+
18
+ ### Breaking
19
+
20
+ - **More realtime transports skipped by default.** The default `measure.exclude` is now
21
+ `['/socket.io/', '/sockjs/', '/sockjs-node/', '/signalr/', '/_blazor/']`: besides socket.io it
22
+ skips the HTTP requests of SockJS (also Meteor and the webpack-dev-server 3 reload client),
23
+ classic ASP.NET SignalR and Blazor Server. These are handshakes, long polling and streams, not
24
+ backend endpoints, and gave long or `PENDING` samples. Keys under these paths no longer appear
25
+ in the report; their entries in a thresholds file stay and are reported as not seen
26
+ (`THRESHOLDS_UNSEEN_ENTRIES`). Other keys and the normalization fingerprint do not change, so
27
+ thresholds files stay valid. Migration: run a thresholds run of the full suite with
28
+ `PW_PERF_PRUNE=1` to remove the old entries. A config file that sets `measure.exclude` (an
29
+ earlier guided setup wrote it) keeps its own list: add the new patterns there or use
30
+ `[...perfDefaults.measure.exclude, ...]`. The guided setup now writes the longer default list.
31
+ - **The guided setup adds no CI jobs.** The CI step is gone (steps are now `[n/9]`) and the wizard
32
+ no longer writes `.github/workflows/perf.yml`, `.gitlab/perf.gitlab-ci.yml`, `Jenkinsfile.perf`
33
+ or `azure-pipelines.perf.yml`; it still adds no scripts. Your test command is only used in the
34
+ commands printed at the end and for the check, and the step says so. Migration: CI files written
35
+ by an earlier wizard are left as they are and keep working; copy the recipes from
36
+ `examples/ci/` and [CI](docs/ci.md) for new projects or to pick up the changes below (thresholds
37
+ artifact of `reports/pw-perf/` only, `junit.xml`).
38
+
39
+ ### Added
40
+
41
+ - **Warning and table for keys on default thresholds.** When a thresholds file has entries but
42
+ some endpoints or steps of a measurement run (`PW_PERF_MODE=test`) have none, the run warns
43
+ with the new `THRESHOLDS_KEYS_ON_DEFAULTS` (one per kind, with the number of keys and up to
44
+ three of them) and the console prints a table of those keys under the counters: samples,
45
+ median, the evaluated percentile, the default limits applied and the result, keys with a
46
+ violation first, at most 10 rows and a "… and N more" line. The warning also appears in
47
+ `report.json`, the HTML report and `junit.xml`; its hint suggests a thresholds run to add the
48
+ entries. Not in thresholds mode, and not for a missing or empty file (`THRESHOLDS_FILE_MISSING`
49
+ and `THRESHOLDS_FILE_EMPTY` cover those). It does not change the evaluation or the exit code.
50
+ - **Thresholds files in the report folder.** A thresholds run (`PW_PERF_MODE=thresholds`) writes
51
+ the thresholds files as before and also copies them, byte for byte and under the same names
52
+ (with the environment label), into `report.dir` (`reports/pw-perf/pw-perf-thresholds.json`,
53
+ `reports/pw-perf/pw-perf-thresholds.steps.json`): every file of the measured kinds, also when
54
+ this run left it unchanged, so one CI artifact of `reports/pw-perf/` holds everything to commit
55
+ next to `thresholds-diff.md`. No copies when writing a thresholds file failed or in the check of
56
+ the guided setup. A failed copy is the warning `THRESHOLDS_COPY_FAILED` and does not change the
57
+ exit code. The copies directly in `report.dir` no longer stop it from being emptied at the start
58
+ of the next run. The CI recipes in `examples/ci/` now upload only `reports/pw-perf/` in the
59
+ thresholds job (Azure: the `pw-perf-report` artifact in both modes).
60
+ - **JUnit XML report.** A measurement run (`PW_PERF_MODE=test`) writes `reports/pw-perf/junit.xml`
61
+ next to `report.json`, so GitLab, Jenkins and Azure DevOps show the result in their test views:
62
+ one test case per endpoint and step key, a failure only for a blocking violation (exit code 2),
63
+ muted and not evaluated keys as skipped, tool errors as an error of the `measurement run` test
64
+ case. Not written in thresholds mode or by a check. Turn it off with `report.junit: false`; a
65
+ failed write is the tool error `REPORT_JUNIT_WRITE_FAILED` (exit code 3).
66
+ - **JUnit in the CI recipes.** The recipes in `examples/ci/` publish `junit.xml` without changing
67
+ the job status: GitLab `artifacts: reports: junit`, Jenkins `junit` (empty results allowed,
68
+ build not marked unstable by it), Azure `PublishTestResults@2` in mode `test` only, and an
69
+ optional, commented-out test report step for GitHub Actions. `docs/ci.md` explains where the
70
+ result shows up and how to read it.
71
+
72
+ ### Changed
73
+
74
+ - **Tables in the thresholds diff and the start box.** The changes of a thresholds run are
75
+ listed in a table with lines (marker, key, change), like the tables of the run summary, and the
76
+ skipped keys in a second table with their reason; the start box of a perf-mode run is a table
77
+ with the mode in its top edge, labels on the left and values on the right (long values are
78
+ shortened in the middle). `NO_COLOR` only drops the colors; `TERM=dumb` draws the tables with
79
+ `+`, `-` and `|`.
80
+ - **Clearer labels in the HTML report.** The checks table of a key shows Raw (the value measured
81
+ in the run) and Bound (the 95% confidence bound that Apdex, slow share and error rate compare
82
+ with the limit) instead of Actual and Observed, with a one-line legend; `report.json` keeps the
83
+ field names `actual` and `observed`. The column Headroom is now Limit used (it shows how much of
84
+ the limit is used). A line under the checks table gives T of Apdex and slow share and says when
85
+ T is the lowest the thresholds allow, so a key can pass them while its percentiles fail. The
86
+ Steps tile says how many steps are over their limit ("1 over limit · 0 near limit"). The Tests
87
+ result and the tile without steps count test runs ("passed 50 test runs"), not tests. Hints of
88
+ steps say "samples" instead of "responses". The key header in the details dialog shows the
89
+ origin label as a token before the path (`api` and `/api/prices`, not `GET api/api/prices`),
90
+ with the origin address in its tooltip. The note that the medians of the TTFB split can differ
91
+ from p50 only appears when they differ.
92
+ - **Rounded multiples and percentages.** The hard-limit hint shows the multiple of the limit with
93
+ two decimals, rounded ("2.67×", was "2.6×"), and never one that is not above the hard limit
94
+ factor ("2.05×", was "2.0× … above the hard limit of 2×"). The excess of a failed check in the
95
+ HTML report is the text of the console and `junit.xml` (rounded: "+105%", was "+106%" from
96
+ rounding up), and every output shows at least "+1%" (the console could show "+0%"). The share of
97
+ the limit used by a passing check is rounded ("56% of limit", was "55%"), but never shown as 90%
98
+ or more below 0.9, where the near-limit hint and colour start.
99
+ - **Wording of the guided setup in es, fr, it, pl, uk and ru.** A review of every translated
100
+ text: the question about passes now asks how many passes per measurement (es, fr, it); one word
101
+ for a pass in Italian ("passata", no longer "passaggio", which also means a step) and for a
102
+ measurement ("misurazione"); the wizard is the "procedura guidata" in Italian; the summary is
103
+ "Récapitulatif" in French and "Сводка" in Russian; Ukrainian and Russian no longer say that a
104
+ run "falls" on a regression but that it ends with an error, call step titles "names" and write
105
+ "endpoint" in Cyrillic everywhere; plainer words for the cleaning of step titles (es, pl).
106
+ Meaning and placeholders are unchanged.
107
+ - **The guided setup ends with an IMPORTANT box.** After it writes the setup, the wizard ends
108
+ with a framed box (in the chosen language, at most 80 columns, ASCII with `TERM=dumb`) of the
109
+ next steps with your exact commands: derive the thresholds on CI, on the environment where the
110
+ tests will run (`PW_PERF_MODE=thresholds <your command>`; it can take several hours), download
111
+ the thresholds files from the CI artifacts (the report folder `reports/pw-perf`), commit them,
112
+ and from then on run `PW_PERF_MODE=test <your command>`. It replaces the `Run:` line and the
113
+ "Next steps" list; when the check did not run, one line suggests `PW_PERF_MODE=check` first.
114
+ Without a terminal or with `PW_PERF_DRY_RUN=1` the summary is as before.
115
+ - **The guided setup creates empty thresholds files.** It always adds `pw-perf-thresholds.json`
116
+ and `pw-perf-thresholds.steps.json` next to the Playwright config, without entries and whatever
117
+ you chose to measure, each with its own diff and confirmation; an existing thresholds file is
118
+ never changed. A measurement run with an empty file warns with the new `THRESHOLDS_FILE_EMPTY`
119
+ and suggests a thresholds run (as for a missing file), a check shows `0 entries` and the same
120
+ next step, and the thresholds run fills the files without `THRESHOLDS_MANUAL_FILE`.
121
+ - **The config file of the guided setup lists every option as code.** `pw-perf.config.ts` (or
122
+ `.js`) now sets all 15 listed options: your answers and the default value of every other
123
+ option, so you edit a value instead of uncommenting lines and objects. Each section has a
124
+ short comment above it, and the `report.dir` comment says the folder (with `junit.xml`) is not
125
+ committed. Config files written by an earlier wizard keep working unchanged.
126
+
127
+ ### Fixed
128
+
129
+ - **Violation cards show the rule that failed the run.** A card in the Overview of the HTML report
130
+ showed the failed check with the highest share of its limit, e.g. slow share "+5 pp", while its
131
+ hint explained a p95 above the hard limit. It now shows the deciding check: a blocking check
132
+ above the hard limit first, then other blocking checks. The Limit used column of the key tables
133
+ shows the same check for a failed key.
134
+ - **Step thresholds file no longer "differs".** Run & config compared the normalization
135
+ fingerprint of the step thresholds file with the fingerprint of URL keys, so it always showed
136
+ "differs: keys may not match". It now compares it with the step fingerprint of the run; a real
137
+ difference also links to the `THRESHOLDS_SOURCE_MISMATCH` warning.
138
+ - **No limit for rules that were not evaluated.** A key with too few samples for p95 or p99 showed
139
+ their limits (in red when above), although those rules decided nothing. The key table now shows
140
+ "/ —" with a footnote, and the details say "p95 · not evaluated".
141
+ - **Start box closes on every line.** The title line of the start box used ⏱️ (a character with
142
+ the emoji variation selector U+FE0F), whose width terminals count differently, so its right
143
+ edge stood one column off in VS Code and Terminal.app. The title now uses ⏳, which every modern
144
+ terminal shows in two columns, and no frame or table uses U+FE0F sequences. Text widths of
145
+ frames and tables now follow the wcwidth conventions (variation selectors, joiners and combining
146
+ marks take no column; an emoji sequence is never cut apart).
147
+
148
+ ## [0.1.0-next.4] - 2026-11-23
149
+
150
+ Upgrading from `0.1.0-next.3`: see [Upgrading](docs/upgrading.md). In short, run your test
151
+ command with `PW_PERF_*` variables instead of `pw-perf` commands, move `pw-perf-results/` to
152
+ `reports/pw-perf/`, remove `run.projects` and `--reporter` from the measurement command, and
153
+ re-derive the thresholds files (the keys changed).
154
+
155
+ ### Breaking
156
+
157
+ - **No commands or options, only variables.** The `pw-perf` commands and options are gone:
158
+ `pw-perf test`, `thresholds`, `check`, `report`, `init`, `thresholds --from`, `--env`,
159
+ `--passes`, `--prune`, `--max-tests`, `--config`, `--input`, `--output`, `--help` and
160
+ `--version`. Run your test command with the variables instead, e.g.
161
+ `PW_PERF_MODE=test PW_PERF_PASSES=3 npx playwright test`. Every run writes the HTML report, so
162
+ there is no command to render it again; thresholds come from a `PW_PERF_MODE=thresholds` run (the
163
+ CI thresholds job and its artifact). The runner codes (`CLI_INVALID_OPTION`,
164
+ `CLI_OUTCOME_MISSING`, `CONFIG_FILE_LOAD_FAILED`, …) are removed. `perf:*` scripts written by an
165
+ early wizard no longer work; remove them. Hints, the help, the `Next:` line, the wizard, the
166
+ README and `docs/` show only `PW_PERF_*=… <your test command>`; `docs/cli.md` is now "Running".
167
+ - **The wizard takes no options.** `npx pw-perf` without arguments starts it in a project with the
168
+ package installed, and `npm init playwright-performance-regression` takes no arguments either
169
+ (any argument is `CLI_UNKNOWN_COMMAND` with the help). Use `PW_PERF_LANG=<code>` instead of
170
+ `--lang`, `PW_PERF_DRY_RUN=1` instead of `--dry-run` and `PW_PERF_NO_TUTORIAL=1` instead of
171
+ `--no-tutorial`. `--yes` has no replacement: the wizard writes changes only in a terminal (press
172
+ Enter for each default); without one it shows the plan.
173
+ - **`run.projects` is gone.** The measured projects are the ones your test command selects
174
+ (`--project`; all projects without it), except setup and teardown projects (named in
175
+ `dependencies` or `teardown` of another project), which run once per pass and are not measured.
176
+ `withPerf()` no longer removes projects from the run and the browser engine no longer decides:
177
+ select one engine with `--project`, e.g. `PW_PERF_MODE=test npx playwright test --project
178
+ chromium` (samples of several engines give `STATS_MULTIPLE_BROWSERS`). `run.projects` in the
179
+ config is `CONFIG_UNKNOWN_OPTION`; `CONFIG_UNKNOWN_PROJECT` and `CONFIG_MULTIPLE_ENGINES` are
180
+ removed, and `CONFIG_NO_MEASURED_PROJECT` now comes from the reporter when the command runs only
181
+ setup or teardown projects. Run reports have `schemaVersion` 4; version 3 reports are migrated
182
+ (their `config.run.projects` is dropped).
183
+ - **Report folder `reports/pw-perf/`.** The default `report.dir` is now `reports/pw-perf/` (was
184
+ `pw-perf-results/`); `report.html`, `report.json`, `outcome.json`, `pass-<k>.json` and
185
+ `thresholds-diff.md` are written directly into it. Every `test` and `thresholds` run empties it
186
+ when its first test starts, so reports of earlier runs never stay next to the new ones; the
187
+ parent `reports/` folder and the reports of other tools in it are never touched. A guard keeps
188
+ the folder when it is the project directory, the `playwright.config` directory, the home
189
+ directory, the filesystem root, `thresholds.dir`, a folder containing one of them, or a folder
190
+ with thresholds files, `package.json`, `playwright.config.*` or `.git`; the run then warns with
191
+ `RUN_REPORT_DIR_NOT_CLEANED`. A check and a run without started tests remove nothing. To
192
+ migrate: replace `pw-perf-results` with `reports/pw-perf` in `.gitignore` and in your CI jobs
193
+ (the artifact path and the `outcome.json` path; the GitHub and Azure artifact is now named
194
+ `pw-perf-report`), and delete the old `pw-perf-results/` folder, or set
195
+ `report: { dir: 'pw-perf-results' }` to keep it.
196
+ - **Endpoint and step keys changed** (F2 findings). Prefixed ids in URLs are replaced with `:id` by
197
+ the new built-in pattern `keys.idPatterns.prefixed`: 2–5 capital letters, `-` and at least 3
198
+ digits (`/orders/ORD-1000` → `/orders/:id`), or 1–8 lowercase letters, `_` and at least 2 digits
199
+ or 8–32 letters and digits with a digit (`/invoices/inv_58` → `/invoices/:id`); short names such
200
+ as `api_v2`, `step_2fa` or `UTF-8` stay. In step titles, bare integers shorter than 9 digits
201
+ become `:num` instead of `:id` (`Transfer 1500 PLN` → `Transfer :num PLN`, the same key as
202
+ `Transfer 120.50 PLN`); number segments of paths in titles stay `:id`. Both fingerprints change,
203
+ so existing thresholds files give `THRESHOLDS_SOURCE_MISMATCH` until re-derived; see
204
+ [Upgrading](docs/upgrading.md#from-010-next3-endpoint-and-step-keys-changed).
205
+ - **`--reporter` stops a measurement run.** A `--reporter` option without the pw-perf reporter in
206
+ the test command (also in an npm script) now stops a `PW_PERF_MODE=test` or `thresholds` run
207
+ before the tests with exit code 1 (`RUN_REPORTER_FLAG`). It used to be a warning on stderr and
208
+ the run ended with exit code 0 although nothing was measured. A check still only warns. Remove
209
+ `--reporter` from the measurement command or add `,playwright-performance-regression/reporter`
210
+ to its value.
211
+ - **`test.step` blocks are measured by default** (`measure.steps` is `true`): they give step keys,
212
+ a `pw-perf-thresholds.steps.json` file and fail the run like endpoints, without any config. Set
213
+ `measure: { steps: false }` to measure only backend requests. A run without any `test.step`
214
+ prints one informational line instead of the `STEPS_NONE_FOUND` warning, which is removed.
215
+ - **No start question.** The `Continue? (Y/n)` question under the start banner is gone, and so is
216
+ `PW_PERF_YES`: the banner only informs and the run starts right away in every mode (press Ctrl+C
217
+ to stop it). A set `PW_PERF_YES` is ignored.
218
+
219
+ ### Added
220
+
221
+ - **`request` calls are measured.** Calls of Playwright's `request` fixture, `page.request` and
222
+ `context.request` (API tests and data setup in UI tests) are measured with `measure.api` on (the
223
+ default). They get their own keys with the prefix `request`, e.g.
224
+ `request GET /api/orders/:id`, next to the browser's `GET /api/orders/:id`: the two are timed
225
+ differently (worker clock vs browser timing), so each gets its own entry in
226
+ `pw-perf-thresholds.json` and its own limits. Contexts from `playwright.request.newContext()` are
227
+ measured after `perf.trackRequestContext(context)` or `trackRequestContext(context)` from
228
+ `playwright-performance-regression/fixture`. API tests must import `test` from the wrapped test
229
+ object, otherwise `TESTS_NOT_INSTRUMENTED` names them. The sample batch attachment moves to
230
+ schema version 3 (`apiRequests`); the run report and the thresholds files keep their versions.
231
+ If you excluded API-only projects from the measurement command because of
232
+ `RUN_PROJECT_NO_REQUESTS`, you can add them back.
233
+ - `measure.api` (default `true`): set it to `false` to measure only `test.step` durations. No
234
+ request is recorded, the endpoint thresholds file is neither read nor written, and tests do not
235
+ need to import `test` from a wrapped test object (no `TESTS_NOT_INSTRUMENTED`). Turning off both
236
+ `measure.api` and `measure.steps` is `CONFIG_INVALID_VALUE`.
237
+ - `run.overrideSlowMo` (default `false`): when `true`, perf mode sets `use.launchOptions.slowMo`
238
+ to 0 in every measured project and lists `slowMo` in the "perf mode overrides …" line. With
239
+ `false`, the `CONFIG_SLOW_MO` warning stays and now points to the option.
240
+ - Wizard, new and changed steps (`[n/10]`):
241
+ - right after the language question it checks for `playwright.config`; without one it lists the
242
+ configs it finds in subfolders (up to 3 levels) with `cd <folder> && npx pw-perf` for each;
243
+ - step 1 says what the package does, how to run it (`PW_PERF_MODE=thresholds <your test
244
+ command>`, commit the thresholds files, then `PW_PERF_MODE=test <your test command>` locally
245
+ and in CI, with `--project <name>` to measure one browser), the other `PW_PERF_*` variables
246
+ and which files to commit, instead of listing what it detected; the Playwright version shows
247
+ up only as an error when it is too old;
248
+ - step 4 asks "What to measure? [all/api/steps]" in every project, also without `test.step`
249
+ calls: `all` (the default) keeps both kinds on, `api` writes `measure: { steps: false }` and
250
+ `steps` writes `measure: { api: false }`; the `api` lesson says that it also covers `request`
251
+ calls in API tests;
252
+ - step 6 asks for your usual test command, with the plain Playwright command of your package
253
+ manager as the default (Enter) and `skip` to skip the check; it suggests `npm run <script>`
254
+ (or the pnpm/yarn form) when exactly one `package.json` script runs `playwright test`, and
255
+ warns when the command or its script sets `--reporter` or runs other commands before
256
+ `playwright test`, since they run in every pass. The typed command is used as typed in the
257
+ summary commands, in the CI jobs (quoted for GitLab YAML and Jenkins Groovy) and for the
258
+ check. The wizard no longer asks which test script runs your tests (`INIT_SCRIPT_FLAG` and
259
+ `INIT_SCRIPT_LATER_STEPS` are removed);
260
+ - when the tests take `test` straight from `@playwright/test` and there is no fixtures module,
261
+ the changes step rewrites the imports of the test files: `test` and `expect` come from
262
+ `playwright-performance-regression/test`, other names stay. Each file is a diff you confirm;
263
+ setup files are left alone. The red box appears only when you decline one of them;
264
+ - step 9, the check, runs your test command like the real runs: first with
265
+ `PW_PERF_MODE=thresholds`, then with `PW_PERF_MODE=test`, both with `PW_PERF_PASSES=2`,
266
+ through your shell. Its thresholds go to a temporary folder that is deleted afterwards (your
267
+ thresholds files are not touched), a key needs only 2 successful samples, and the wizard shows
268
+ the exit code of each run and the most likely cause of a failure from `outcome.json`. There is
269
+ no check when the red "Action needed: nothing is measured yet" box is shown (with the answer
270
+ `steps` there is no red box, because steps are measured without the `perf` fixture);
271
+ - the wizard says that `globalSetup` and setup projects run once per pass, warns about
272
+ `request.newContext()` contexts that are not passed to `trackRequestContext()`, warns about
273
+ test files that still import `test` straight from `@playwright/test` after wrapping your
274
+ fixtures module, and reminds you to format the changed files.
275
+ - The wizard writes `pw-perf.config.js` in a JavaScript project (a `playwright.config.js`,
276
+ `.mjs` or `.cjs` without `tsconfig.json`): an ES module or CommonJS like the Playwright config,
277
+ with `// @ts-check`. A CommonJS config requires it without `.default`. TypeScript projects keep
278
+ `pw-perf.config.ts`.
279
+ - Warning `CONFIG_FILE_NOT_PASSED`: a `pw-perf.config.*` file next to the Playwright config is no
280
+ longer ignored silently when `withPerf(config)` gets no second argument; the run still uses the
281
+ defaults, and the hint shows how to pass the file.
282
+ - HTML report: a stopwatch logo in the header and as the page icon (an inline `data:` URI, no
283
+ extra files); a Source column (`browser` / `request`) in the Endpoints table.
284
+ - The report names what it is about: the run report has an optional `suite` (the package name from
285
+ `package.json` next to the Playwright config, else the config path from the repository root),
286
+ shown in the HTML header, the page title and Run & config. A measured project with only
287
+ `request` calls is marked `requestOnly` and reads "no browser" in Run & config and in the
288
+ `PW_PERF_MODE=check` output.
289
+ - Docs: installing in a pnpm monorepo (`pnpm add -Dw` or in every importing package,
290
+ `pnpm --filter <app> exec playwright test`, `--no-bail` for `pnpm -r`), `globalSetup` and setup
291
+ projects running once per pass, `trackRequestContext()` in fixtures, several test objects in one
292
+ chain (wrapping both is safe: an integration test shows every request is recorded once), an
293
+ example of `keys.extraIdPatterns`, and the upgrade steps from `0.1.0-next.3`.
294
+
295
+ ### Changed
296
+
297
+ - `pw-perf.config.ts` written by the wizard is short: the 15 most important options (including
298
+ `measure.api`, `measure.steps` and `run.overrideSlowMo`), each with a short comment, and a link
299
+ to the full option list in `docs/configuration.md`. The "Most important settings" block and the
300
+ comments for every other option are gone.
301
+ - The wizard's commands and CI jobs use your test command from step 6, or the plain Playwright
302
+ command of your package manager (`npx playwright test`, `pnpm exec playwright test`,
303
+ `yarn playwright test`); it adds `reports/pw-perf/` to `.gitignore` unless `reports/` is
304
+ ignored already.
305
+ - The wizard's red box lists the files with `.extend()` with the number of test files that import
306
+ each, the most imported first, and names the one to wrap. A fixtures module of a workspace
307
+ package is listed too, with a note to install the package in the workspace root. Nested git
308
+ repositories (submodules) are no longer scanned unless your sources import from them.
309
+ - HTML report: the view switch (Overview, Endpoints, Steps, Tests, …) is a row of tabs. The
310
+ selected tab has an accent underline and background, every tab is at least 44 px high, and on a
311
+ narrow screen the bar scrolls to show the selected tab. The Endpoints and Steps tab counts are
312
+ neutral with a red badge of keys with violations.
313
+ - HTML report details: a key without timed samples shows its other statuses under Samples and in
314
+ its details, e.g. "5 × 404 (not timed)"; the thresholds file source is shortened to the version
315
+ and the date (full text on hover); Top keys in the Tests tab put the time under each key; "Most
316
+ expensive tests" names the project when more than one is measured; the TTFB column is hidden
317
+ when no key has TTFB; a step without a location reads "boxed step (no location)".
318
+ - Violations are counted the same way in the console and the HTML report: failed checks with the
319
+ number of keys (`8 blocking violations in 7 keys`); the Violations tile counts failed checks
320
+ too. Apdex, slow share (wilson) and error rate over the limit read in percentage points
321
+ (`+81 pp`) instead of a relative percent that showed `>999%`.
322
+ - `Next:` after a `test` or `check` run repeats the arguments you added (`PW_PERF_MODE=test npm
323
+ run e2e -- --project=desktop`); the thresholds command stays without them, so thresholds come
324
+ from the whole suite. When the package manager was called from a parent directory (e.g. the
325
+ root of a monorepo), the command starts with `cd <directory> && `.
326
+ - The start banner no longer guesses 30 s per test before the first run: the estimate says
327
+ `unknown (run PW_PERF_MODE=check for an estimate)`. A time under a minute reads `< 1 min`
328
+ without `≈`, and there is no `Tip` when `run.grep` is set.
329
+ - The line of a later pass shows your command (`pass 2/10: npx playwright test`,
330
+ `pass 2/10: npm run e2e -- --grep cart`) instead of the full paths of the process.
331
+ - The `Outcome:` line starts with the exit code of the process: `Outcome: Playwright exit code 1 ·
332
+ details: performance failed (code 2) in …/outcome.json`.
333
+ - The thresholds diff lists the skipped keys with the reason (`no successful samples, 5 needed
334
+ (5 × 404)`): up to 5 in the console, all in `thresholds-diff.md`. The Apdex T limit reads
335
+ `apdex T 500 ms` instead of `t 500`.
336
+ - Samples from a project that is only a dependency or teardown of other projects (a usual `setup`
337
+ project) no longer give the `STATS_SAMPLES_OUTSIDE_MEASURED_PROJECTS` warning.
338
+ - `TESTS_NOT_INSTRUMENTED` counts tests instead of test results and names up to three files, e.g.
339
+ `2 tests in tests/api.spec.ts import test without withPerfFixtures() …`; a crashed worker is
340
+ mentioned only when a worker actually crashed.
341
+ - The examples run with `PW_PERF_MODE=… npm test` instead of `perf:*` scripts.
342
+
343
+ ### Fixed
344
+
345
+ - Collector: with Playwright 1.57 (Chromium) a `fetch` answered with `204 No Content` was
346
+ recorded as `ABORTED` with no time, so endpoints such as `DELETE /api/items/:id` were never
347
+ measured. A 204, 205 or 304 response followed by `requestfailed` is now a sample with its status
348
+ and time.
349
+ - Collector: a request whose response arrived but whose body was then aborted (typically a login
350
+ or form `fetch` followed at once by `location.href = …`) was recorded as `ABORTED`, so
351
+ successful logins were never measured and the key kept only the failed attempts. A response
352
+ followed by an abort (`net::ERR_ABORTED`, `NS_BINDING_ABORTED`, …) is now a sample with its
353
+ status and time (up to the end of the body, or to the headers when the body was cut off); other
354
+ failures after a response stay `FAILED`.
355
+ - Types of `playwright-performance-regression/config`, `/fixture`, `/test` and `/reporter`
356
+ resolve in TypeScript projects without `exports` support (`"module": "commonjs"` with no
357
+ `moduleResolution`, i.e. `node10`): `tsc` no longer fails with `Cannot find module`, and a
358
+ wrapped `test` keeps its fixture types instead of `any`.
359
+ - With `PW_PERF_PASSES` above 1, `PW_PERF_MODE=… npx playwright test` no longer starts pass 2 as
360
+ `npm run npx` ("Missing script"): a package script runs again only when `package.json` has it.
361
+ The `Next:` hint no longer suggests `npm run npx` either.
362
+ - `CONFIG_SLOW_MO` warns only about projects measured in the run. A run with `--project=api`
363
+ warned about the `slowMo` of an e2e project that did not run (and of setup projects), in every
364
+ run.
365
+ - A thresholds run that selects a subset of the tests (`--grep`, `--project`, file filters) no
366
+ longer ends with "Run with PW_PERF_PRUNE=1 to remove them": pruning is ignored in such a run
367
+ (`RUN_PRUNE_SKIPPED`). The line now says that the run selects a subset of the tests.
368
+ - A `PW_PERF_MODE=thresholds` run no longer warns with `THRESHOLDS_FILE_MISSING` about the
369
+ thresholds file it is creating.
370
+ - `PW_PERF_MODE=check` uses the singular for one item (`1 sample · 1 test`, `5 requests in 1
371
+ test`, `1 of 1 test run`, `1 api key`) instead of `1 samples · 1 tests`.
372
+ - HTML report: long endpoint and step names no longer run into the next column. In the Endpoints
373
+ and Steps tables the name wraps inside the Key cell; in the Overview cards it is cut with an
374
+ ellipsis and the full name is shown on hover.
375
+ - HTML report: the key labels of a waterfall (Tests tab) are monospace with the method in its
376
+ colour again; in Chromium they were unstyled and a long method such as `DELETE` overlapped the
377
+ path.
378
+ - Setup wizard: project detection reads the whole project, not only `testDir`, so fixtures modules
379
+ and page objects next to the test directory (e.g. `testDir: './tests/specs'` with
380
+ `tests/fixtures/`) are found: a single fixtures module there is wrapped, and the "nothing is
381
+ measured yet" box lists the files with `.extend(`. `.extend(` in application code (e.g. zod
382
+ schemas) no longer counts as a fixtures module, and the box counts only test files that import
383
+ `test` from `@playwright/test`, not page objects or fixtures modules.
384
+ - Setup wizard: the red box no longer says "nothing is measured yet" when you answer `all` and your
385
+ tests use `test.step`: the step durations are measured, so the box says "Endpoints are not
386
+ measured yet" (in all 7 languages), and the wizard offers the check.
387
+ - Setup wizard: the red box (`INIT_TEST_OBJECT_MANUAL`) is full width in a pseudo-terminal that
388
+ reports 0 columns (e.g. `expect`, `docker -t`) instead of being cut to 40 columns, and counts
389
+ the test files as `(files: 1)` instead of `(1 files)` (English, Spanish, French, Italian).
390
+ - Setup wizard: no `.gitignore` entry is added when the file already ignores the report folder
391
+ with a glob such as `/reports/**/*` or `reports/*`.
392
+ - Setup wizard translations reviewed: the no-terminal note has its missing full stop in every
393
+ language; one term per idea in each language (es "tests", it "passaggi" and "verifica", uk/ru
394
+ "воркер" and endpoint keys); French uses a no-break space before `:` `;` `?` `!` and French and
395
+ Italian use typographic apostrophes; the red box title fits 80 columns in every language (it
396
+ was cut in es, fr, pl and it).
397
+
10
398
  ## [0.1.0-next.3] - 2026-11-21
11
399
 
12
400
  `0.1.0-next.2` was tagged but not published (the release stopped on the performance tests).
package/README.md CHANGED
@@ -2,18 +2,14 @@
2
2
 
3
3
  Catch backend performance regressions from the Playwright tests you already have.
4
4
 
5
- > **Pre-release.** `0.1.0-next.N` versions are published under the `next` tag: install with
6
- > `npm init playwright-performance-regression@next` or
7
- > `npm install --save-dev playwright-performance-regression@next`. Until `0.1.0`, the API, file
8
- > formats and CLI may still change.
9
-
10
5
  ![HTML report of a measurement run](.github/assets/report.png)
11
6
 
12
7
  ## How it works
13
8
 
14
- 1. **Measures** the backend requests your browser makes while your existing e2e tests run, in a
15
- separate measurement run (`PW_PERF_MODE=test npm run e2e`): your test command runs a few times
16
- in a row (passes), and all passes are evaluated together.
9
+ 1. **Measures** the backend requests your browser makes (and the `request` calls of API tests)
10
+ while your existing e2e tests run, in a separate measurement run
11
+ (`PW_PERF_MODE=test npm run e2e`): your test command runs a few times in a row (passes), and
12
+ all passes are evaluated together.
17
13
  2. **Groups** the requests into endpoint keys such as `GET /api/orders/:id`, and computes
18
14
  statistics per key: median, p95, p99, error rate and more.
19
15
  3. **Derives thresholds** from a run and writes them to JSON files that you review and commit like
@@ -26,18 +22,27 @@ Your normal `npx playwright test` runs are not changed.
26
22
  ## Install
27
23
 
28
24
  ```sh
29
- npm init playwright-performance-regression@next
25
+ npm init playwright-performance-regression
30
26
  ```
31
27
 
32
- This installs the package as a dev dependency and starts a short guided setup (`pw-perf init`;
33
- after `0.1.0`: `npm init playwright-performance-regression`). It shows a diff of every change
34
- before writing anything: it wraps your Playwright config and your fixtures module, creates
35
- `pw-perf.config.ts`, ignores `pw-perf-results/` and can add the CI jobs. It never changes your test
36
- files or `package.json`: when it cannot wrap your `test` object, it shows the code to paste. At the
37
- end it runs a short check of what will be measured. `pnpm create` and
38
- `yarn create` work too (Yarn 2 or later; Yarn 1 cannot install a specific version such as
39
- `@next` with `yarn create`); `-- --yes` accepts the defaults without questions. The guided
40
- setup speaks English, Spanish, French, Polish, Italian, Ukrainian and Russian (`--lang <code>`).
28
+ This installs the package as a dev dependency and starts a short guided setup (run it again at
29
+ any time; in a project with the package installed, `npx pw-perf` starts it too). It asks which tests to measure, the passes, what
30
+ to measure (endpoints, `test.step` blocks or both), the threshold headroom and your usual test
31
+ command, then shows a diff of every change before writing it: it creates `pw-perf.config.ts`
32
+ (`pw-perf.config.js` in a JavaScript project) with the most important options, wraps your
33
+ Playwright config and your fixtures module, ignores `reports/pw-perf/`. It adds no CI jobs and no scripts: your
34
+ test command is only used in the commands it prints at the end and for the check; the
35
+ [CI recipes](docs/ci.md) are yours to copy.
36
+ Without a fixtures module, it switches the `@playwright/test` imports of your test files to
37
+ `playwright-performance-regression/test`, one confirmed diff per file; when it cannot change the
38
+ test object, it shows the code to paste. `package.json` is never changed. At the end it offers a
39
+ check: your test command runs with `PW_PERF_MODE=thresholds`, then `PW_PERF_MODE=test`, both with
40
+ 2 passes, and the check's thresholds files are deleted afterwards. It ends with an IMPORTANT box
41
+ of the next steps: thresholds on CI (can take several hours), download, commit, then
42
+ `PW_PERF_MODE=test`. `pnpm create` and `yarn create`
43
+ work too. The guided setup speaks English, Spanish, French, Polish, Italian, Ukrainian and
44
+ Russian (it asks at the start). It takes no arguments; `PW_PERF_LANG`, `PW_PERF_DRY_RUN` and
45
+ `PW_PERF_NO_TUTORIAL` change it ([Guided setup](docs/cli.md#guided-setup)).
41
46
 
42
47
  <details>
43
48
  <summary>Manual setup</summary>
@@ -74,7 +79,8 @@ import { test, expect } from 'playwright-performance-regression/test';
74
79
  ```
75
80
 
76
81
  Optionally add `pw-perf.config.ts` and pass it as the second argument of `withPerf()`; see
77
- [Configuration](docs/configuration.md).
82
+ [Configuration](docs/configuration.md). Remove `--reporter` from the command you measure with:
83
+ it replaces the package reporter, so a measurement run stops with `RUN_REPORTER_FLAG`.
78
84
 
79
85
  </details>
80
86
 
@@ -97,9 +103,11 @@ On Windows: `npx cross-env PW_PERF_MODE=test npm run e2e` (PowerShell and cmd fo
97
103
  [docs/cli.md](docs/cli.md)). Without the variable the tests run as before, with no measuring.
98
104
 
99
105
  The exit code is Playwright's own; the cause of a failure (a regression, failed tests, a config
100
- error) is in `pw-perf-results/outcome.json`. The result is also printed in the terminal and written
101
- to `pw-perf-results/report.json` and `pw-perf-results/report.html`. A runner with its own exit
102
- codes is described in [Advanced: the pw-perf runner](docs/cli.md#advanced-the-pw-perf-runner).
106
+ error) is in `reports/pw-perf/outcome.json`. The result is also printed in the terminal and written
107
+ to `reports/pw-perf/report.json` and `reports/pw-perf/report.html` (tabs Overview, Endpoints,
108
+ Steps, Tests and Run & config); a `test` run also writes `reports/pw-perf/junit.xml` for the test
109
+ views of CI systems. Every `test` and `thresholds` run empties `reports/pw-perf/` first,
110
+ so it holds only the last run. All variables are described in [Running](docs/cli.md).
103
111
 
104
112
  Derive thresholds on the same machines that run the check, usually your CI runners (see
105
113
  [CI](#ci) below); thresholds measured on a laptop do not fit CI. How much headroom they get is one
@@ -108,23 +116,21 @@ setting, `thresholds: { preset: 'strict' | 'normal' | 'loose' }`. See
108
116
 
109
117
  ## Step timings
110
118
 
111
- Your existing `test.step` blocks can be measured too, without changing the tests:
112
-
113
- ```ts
114
- // pw-perf.config.ts
115
- export default definePerfConfig({ measure: { steps: true } });
116
- ```
119
+ Your existing `test.step` blocks are measured too, without changing the tests (on by default;
120
+ `measure: { steps: false }` in `pw-perf.config.ts` turns it off, `measure: { api: false }` measures
121
+ only the steps).
117
122
 
118
123
  A step `submit` inside a step `login` becomes the key `login › submit`, with its own statistics,
119
124
  checks and thresholds file `pw-perf-thresholds.steps.json`. Step titles are sanitized: ids,
120
- e-mails, URLs and secrets never reach the keys or the reports, also inside quotes. See
121
- [Step timings](docs/steps.md).
125
+ e-mails, URLs and secrets never reach the keys or the reports, also inside quotes; numbers in
126
+ words become `:num` (`Transfer 1500 PLN` → `Transfer :num PLN`). See [Step timings](docs/steps.md).
122
127
 
123
128
  ## CI
124
129
 
125
130
  The recommended path: (1) a CI job you start by hand runs with `PW_PERF_MODE=thresholds` and keeps
126
- the thresholds files as an artifact, (2) you commit them, (3) a weekly job runs with
127
- `PW_PERF_MODE=test` and fails on a regression. In GitHub Actions, shortened:
131
+ `reports/pw-perf/` as an artifact (the run copies the thresholds files there), (2) you commit the
132
+ thresholds files, (3) a weekly job runs with `PW_PERF_MODE=test` and fails on a regression. In
133
+ GitHub Actions, shortened:
128
134
 
129
135
  ```yaml
130
136
  name: Performance
@@ -145,7 +151,7 @@ jobs:
145
151
  - run: npm run e2e
146
152
  - uses: actions/upload-artifact@v7
147
153
  if: always()
148
- with: { name: pw-perf-thresholds, path: pw-perf-thresholds*.json }
154
+ with: { name: pw-perf-thresholds, path: reports/pw-perf/ }
149
155
  measure:
150
156
  if: github.event_name == 'schedule' || inputs.mode == 'test'
151
157
  runs-on: ubuntu-latest
@@ -156,26 +162,32 @@ jobs:
156
162
  - run: npm run e2e
157
163
  - uses: actions/upload-artifact@v7
158
164
  if: always() # the report matters most when the run fails
159
- with: { name: pw-perf-results, path: pw-perf-results/ }
165
+ with: { name: pw-perf-report, path: reports/pw-perf/ }
160
166
  ```
161
167
 
162
168
  Not ready to block builds yet? Set `continue-on-error: true` on the measure job. The full recipes
163
169
  for GitHub Actions, GitLab CI, Jenkins and Azure Pipelines read the exact exit code (**0** ok,
164
- **2** performance regression, **3** tool or config error) from `pw-perf-results/outcome.json`:
170
+ **2** performance regression, **3** tool or config error) from `reports/pw-perf/outcome.json`:
165
171
  [CI](docs/ci.md).
166
172
 
167
173
  ## Limitations
168
174
 
169
175
  - REST only: every GraphQL query goes to the same endpoint key.
170
- - Only requests made by the browser are measured. Tests that use only the `request` fixture, and
171
- calls through `page.request` or `context.request`, record nothing.
172
- - Only Chromium projects are measured by default. Firefox and WebKit are best effort.
176
+ - Requests made by the browser and calls of Playwright's `request` fixture, `page.request` and
177
+ `context.request` are measured (keys such as `request GET /api/orders/:id`, separate from the
178
+ browser's); other HTTP clients (Node `fetch`, axios) are not. API tests are measured only when
179
+ they import `test` from the wrapped test object, and contexts from `request.newContext()` only
180
+ after `trackRequestContext(context)` ([Adoption](docs/adoption.md)).
181
+ - The projects your test command selects are measured (all without `--project`), except setup and
182
+ teardown projects. Chromium is supported; Firefox and WebKit are best effort, so select one engine
183
+ with `--project`.
173
184
  - The measurement run is separate from your normal run, uses one worker and runs your test command
174
185
  several times (passes), so it is slow: measure a subset (`run: { grep: '@perf' }`, `--project`).
175
186
  - The test command, with its setup steps, runs once per pass; tests that create data without such
176
187
  a step can collide in the next pass; make the data unique.
177
188
  - A `--reporter` flag in the test command replaces the package reporter, so nothing is reported
178
- (the run warns with `RUN_REPORTER_FLAG`); keep reporters in `playwright.config` instead.
189
+ (a test or thresholds run stops with `RUN_REPORTER_FLAG`); keep reporters in
190
+ `playwright.config` instead.
179
191
 
180
192
  ## Privacy
181
193
 
@@ -184,7 +196,7 @@ No telemetry. The package never makes network requests.
184
196
  What ends up where:
185
197
 
186
198
  - **Thresholds files and `report.json` / `report.html`** contain normalized endpoint keys: numbers,
187
- UUIDs, long hex strings, tokens, mixed-case ids and e-mail addresses in the path are replaced
199
+ UUIDs, long hex strings, tokens, mixed-case ids, prefixed ids (`ORD-1000`, `inv_58`) and e-mail addresses in the path are replaced
188
200
  with `:id` or `:email`, and query values are dropped (only parameter names stay). Path segments
189
201
  that match none of these patterns, such as user names, stay in the key; add patterns with
190
202
  `keys.extraIdPatterns`. The report also contains test titles, file names, the operating system, CPU model
@@ -209,7 +221,7 @@ that Playwright's HTML report and traces contain the full URLs.
209
221
  ## Documentation
210
222
 
211
223
  - [Configuration](docs/configuration.md): every option with its default
212
- - [CLI](docs/cli.md): commands, options and exit codes
224
+ - [Running](docs/cli.md): variables, the guided setup and exit codes
213
225
  - [Adoption](docs/adoption.md): existing projects, choosing tests, sample counts
214
226
  - [Thresholds](docs/thresholds.md): deriving, reviewing, locking and muting
215
227
  - [Step timings](docs/steps.md): measuring `test.step` blocks, keys and title sanitization