playwright-performance-regression 0.1.0-next.3 → 0.1.0-next.4
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/CHANGELOG.md +250 -0
- package/README.md +45 -32
- package/dist/{chunk-AQ2XKYNV.js → chunk-CISGJCFW.js} +35 -7
- package/dist/chunk-CXE5IWZY.js +1648 -0
- package/dist/{chunk-MUZFQKGQ.js → chunk-E2IX265O.js} +321 -30
- package/dist/{chunk-BAOTUUTV.cjs → chunk-IUI4AFE5.cjs} +75 -28
- package/dist/{chunk-44ASXVQN.cjs → chunk-KELMALEG.cjs} +337 -45
- package/dist/{chunk-2JO5HVPC.cjs → chunk-LUA4WRIQ.cjs} +35 -7
- package/dist/{chunk-DX36GFOZ.js → chunk-RL27E3AB.js} +94 -57
- package/dist/{chunk-DYLCGMI2.js → chunk-S6UH6QPK.js} +6 -1
- package/dist/cli.js +1802 -2799
- package/dist/config.cjs +58 -120
- package/dist/config.d.cts +2 -3
- package/dist/config.d.ts +2 -3
- package/dist/config.js +48 -110
- package/dist/fixture.cjs +9 -5
- package/dist/fixture.d.cts +10 -4
- package/dist/fixture.d.ts +10 -4
- package/dist/fixture.js +4 -4
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +17 -9
- package/dist/index.d.ts +17 -9
- package/dist/index.js +1 -1
- package/dist/perf-api-2DH_keLh.d.cts +17 -0
- package/dist/perf-api-2DH_keLh.d.ts +17 -0
- package/dist/reporter.cjs +1131 -632
- package/dist/reporter.js +6153 -1725
- package/dist/test.cjs +4 -4
- package/dist/test.js +4 -4
- package/package.json +17 -1
- package/schemas/config.schema.json +22 -12
- package/schemas/outcome.schema.json +1 -1
- package/schemas/run-report.schema.json +16 -2
- package/schemas/samples.schema.json +48 -2
- package/dist/chunk-LTRHMBVY.js +0 -5592
- package/dist/perf-api-Rm1h1O_-.d.cts +0 -12
- package/dist/perf-api-Rm1h1O_-.d.ts +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,256 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.1.0-next.4] - 2026-11-23
|
|
11
|
+
|
|
12
|
+
Upgrading from `0.1.0-next.3`: see [Upgrading](docs/upgrading.md). In short, run your test
|
|
13
|
+
command with `PW_PERF_*` variables instead of `pw-perf` commands, move `pw-perf-results/` to
|
|
14
|
+
`reports/pw-perf/`, remove `run.projects` and `--reporter` from the measurement command, and
|
|
15
|
+
re-derive the thresholds files (the keys changed).
|
|
16
|
+
|
|
17
|
+
### Breaking
|
|
18
|
+
|
|
19
|
+
- **No commands or options, only variables.** The `pw-perf` commands and options are gone:
|
|
20
|
+
`pw-perf test`, `thresholds`, `check`, `report`, `init`, `thresholds --from`, `--env`,
|
|
21
|
+
`--passes`, `--prune`, `--max-tests`, `--config`, `--input`, `--output`, `--help` and
|
|
22
|
+
`--version`. Run your test command with the variables instead, e.g.
|
|
23
|
+
`PW_PERF_MODE=test PW_PERF_PASSES=3 npx playwright test`. Every run writes the HTML report, so
|
|
24
|
+
there is no command to render it again; thresholds come from a `PW_PERF_MODE=thresholds` run (the
|
|
25
|
+
CI thresholds job and its artifact). The runner codes (`CLI_INVALID_OPTION`,
|
|
26
|
+
`CLI_OUTCOME_MISSING`, `CONFIG_FILE_LOAD_FAILED`, …) are removed. `perf:*` scripts written by an
|
|
27
|
+
early wizard no longer work; remove them. Hints, the help, the `Next:` line, the wizard, the
|
|
28
|
+
README and `docs/` show only `PW_PERF_*=… <your test command>`; `docs/cli.md` is now "Running".
|
|
29
|
+
- **The wizard takes no options.** `npx pw-perf` without arguments starts it in a project with the
|
|
30
|
+
package installed, and `npm init playwright-performance-regression` takes no arguments either
|
|
31
|
+
(any argument is `CLI_UNKNOWN_COMMAND` with the help). Use `PW_PERF_LANG=<code>` instead of
|
|
32
|
+
`--lang`, `PW_PERF_DRY_RUN=1` instead of `--dry-run` and `PW_PERF_NO_TUTORIAL=1` instead of
|
|
33
|
+
`--no-tutorial`. `--yes` has no replacement: the wizard writes changes only in a terminal (press
|
|
34
|
+
Enter for each default); without one it shows the plan.
|
|
35
|
+
- **`run.projects` is gone.** The measured projects are the ones your test command selects
|
|
36
|
+
(`--project`; all projects without it), except setup and teardown projects (named in
|
|
37
|
+
`dependencies` or `teardown` of another project), which run once per pass and are not measured.
|
|
38
|
+
`withPerf()` no longer removes projects from the run and the browser engine no longer decides:
|
|
39
|
+
select one engine with `--project`, e.g. `PW_PERF_MODE=test npx playwright test --project
|
|
40
|
+
chromium` (samples of several engines give `STATS_MULTIPLE_BROWSERS`). `run.projects` in the
|
|
41
|
+
config is `CONFIG_UNKNOWN_OPTION`; `CONFIG_UNKNOWN_PROJECT` and `CONFIG_MULTIPLE_ENGINES` are
|
|
42
|
+
removed, and `CONFIG_NO_MEASURED_PROJECT` now comes from the reporter when the command runs only
|
|
43
|
+
setup or teardown projects. Run reports have `schemaVersion` 4; version 3 reports are migrated
|
|
44
|
+
(their `config.run.projects` is dropped).
|
|
45
|
+
- **Report folder `reports/pw-perf/`.** The default `report.dir` is now `reports/pw-perf/` (was
|
|
46
|
+
`pw-perf-results/`); `report.html`, `report.json`, `outcome.json`, `pass-<k>.json` and
|
|
47
|
+
`thresholds-diff.md` are written directly into it. Every `test` and `thresholds` run empties it
|
|
48
|
+
when its first test starts, so reports of earlier runs never stay next to the new ones; the
|
|
49
|
+
parent `reports/` folder and the reports of other tools in it are never touched. A guard keeps
|
|
50
|
+
the folder when it is the project directory, the `playwright.config` directory, the home
|
|
51
|
+
directory, the filesystem root, `thresholds.dir`, a folder containing one of them, or a folder
|
|
52
|
+
with thresholds files, `package.json`, `playwright.config.*` or `.git`; the run then warns with
|
|
53
|
+
`RUN_REPORT_DIR_NOT_CLEANED`. A check and a run without started tests remove nothing. To
|
|
54
|
+
migrate: replace `pw-perf-results` with `reports/pw-perf` in `.gitignore` and in your CI jobs
|
|
55
|
+
(the artifact path and the `outcome.json` path; the GitHub and Azure artifact is now named
|
|
56
|
+
`pw-perf-report`), and delete the old `pw-perf-results/` folder, or set
|
|
57
|
+
`report: { dir: 'pw-perf-results' }` to keep it.
|
|
58
|
+
- **Endpoint and step keys changed** (F2 findings). Prefixed ids in URLs are replaced with `:id` by
|
|
59
|
+
the new built-in pattern `keys.idPatterns.prefixed`: 2–5 capital letters, `-` and at least 3
|
|
60
|
+
digits (`/orders/ORD-1000` → `/orders/:id`), or 1–8 lowercase letters, `_` and at least 2 digits
|
|
61
|
+
or 8–32 letters and digits with a digit (`/invoices/inv_58` → `/invoices/:id`); short names such
|
|
62
|
+
as `api_v2`, `step_2fa` or `UTF-8` stay. In step titles, bare integers shorter than 9 digits
|
|
63
|
+
become `:num` instead of `:id` (`Transfer 1500 PLN` → `Transfer :num PLN`, the same key as
|
|
64
|
+
`Transfer 120.50 PLN`); number segments of paths in titles stay `:id`. Both fingerprints change,
|
|
65
|
+
so existing thresholds files give `THRESHOLDS_SOURCE_MISMATCH` until re-derived; see
|
|
66
|
+
[Upgrading](docs/upgrading.md#from-010-next3-endpoint-and-step-keys-changed).
|
|
67
|
+
- **`--reporter` stops a measurement run.** A `--reporter` option without the pw-perf reporter in
|
|
68
|
+
the test command (also in an npm script) now stops a `PW_PERF_MODE=test` or `thresholds` run
|
|
69
|
+
before the tests with exit code 1 (`RUN_REPORTER_FLAG`). It used to be a warning on stderr and
|
|
70
|
+
the run ended with exit code 0 although nothing was measured. A check still only warns. Remove
|
|
71
|
+
`--reporter` from the measurement command or add `,playwright-performance-regression/reporter`
|
|
72
|
+
to its value.
|
|
73
|
+
- **`test.step` blocks are measured by default** (`measure.steps` is `true`): they give step keys,
|
|
74
|
+
a `pw-perf-thresholds.steps.json` file and fail the run like endpoints, without any config. Set
|
|
75
|
+
`measure: { steps: false }` to measure only backend requests. A run without any `test.step`
|
|
76
|
+
prints one informational line instead of the `STEPS_NONE_FOUND` warning, which is removed.
|
|
77
|
+
- **No start question.** The `Continue? (Y/n)` question under the start banner is gone, and so is
|
|
78
|
+
`PW_PERF_YES`: the banner only informs and the run starts right away in every mode (press Ctrl+C
|
|
79
|
+
to stop it). A set `PW_PERF_YES` is ignored.
|
|
80
|
+
|
|
81
|
+
### Added
|
|
82
|
+
|
|
83
|
+
- **`request` calls are measured.** Calls of Playwright's `request` fixture, `page.request` and
|
|
84
|
+
`context.request` (API tests and data setup in UI tests) are measured with `measure.api` on (the
|
|
85
|
+
default). They get their own keys with the prefix `request`, e.g.
|
|
86
|
+
`request GET /api/orders/:id`, next to the browser's `GET /api/orders/:id`: the two are timed
|
|
87
|
+
differently (worker clock vs browser timing), so each gets its own entry in
|
|
88
|
+
`pw-perf-thresholds.json` and its own limits. Contexts from `playwright.request.newContext()` are
|
|
89
|
+
measured after `perf.trackRequestContext(context)` or `trackRequestContext(context)` from
|
|
90
|
+
`playwright-performance-regression/fixture`. API tests must import `test` from the wrapped test
|
|
91
|
+
object, otherwise `TESTS_NOT_INSTRUMENTED` names them. The sample batch attachment moves to
|
|
92
|
+
schema version 3 (`apiRequests`); the run report and the thresholds files keep their versions.
|
|
93
|
+
If you excluded API-only projects from the measurement command because of
|
|
94
|
+
`RUN_PROJECT_NO_REQUESTS`, you can add them back.
|
|
95
|
+
- `measure.api` (default `true`): set it to `false` to measure only `test.step` durations. No
|
|
96
|
+
request is recorded, the endpoint thresholds file is neither read nor written, and tests do not
|
|
97
|
+
need to import `test` from a wrapped test object (no `TESTS_NOT_INSTRUMENTED`). Turning off both
|
|
98
|
+
`measure.api` and `measure.steps` is `CONFIG_INVALID_VALUE`.
|
|
99
|
+
- `run.overrideSlowMo` (default `false`): when `true`, perf mode sets `use.launchOptions.slowMo`
|
|
100
|
+
to 0 in every measured project and lists `slowMo` in the "perf mode overrides …" line. With
|
|
101
|
+
`false`, the `CONFIG_SLOW_MO` warning stays and now points to the option.
|
|
102
|
+
- Wizard, new and changed steps (`[n/10]`):
|
|
103
|
+
- right after the language question it checks for `playwright.config`; without one it lists the
|
|
104
|
+
configs it finds in subfolders (up to 3 levels) with `cd <folder> && npx pw-perf` for each;
|
|
105
|
+
- step 1 says what the package does, how to run it (`PW_PERF_MODE=thresholds <your test
|
|
106
|
+
command>`, commit the thresholds files, then `PW_PERF_MODE=test <your test command>` locally
|
|
107
|
+
and in CI, with `--project <name>` to measure one browser), the other `PW_PERF_*` variables
|
|
108
|
+
and which files to commit, instead of listing what it detected; the Playwright version shows
|
|
109
|
+
up only as an error when it is too old;
|
|
110
|
+
- step 4 asks "What to measure? [all/api/steps]" in every project, also without `test.step`
|
|
111
|
+
calls: `all` (the default) keeps both kinds on, `api` writes `measure: { steps: false }` and
|
|
112
|
+
`steps` writes `measure: { api: false }`; the `api` lesson says that it also covers `request`
|
|
113
|
+
calls in API tests;
|
|
114
|
+
- step 6 asks for your usual test command, with the plain Playwright command of your package
|
|
115
|
+
manager as the default (Enter) and `skip` to skip the check; it suggests `npm run <script>`
|
|
116
|
+
(or the pnpm/yarn form) when exactly one `package.json` script runs `playwright test`, and
|
|
117
|
+
warns when the command or its script sets `--reporter` or runs other commands before
|
|
118
|
+
`playwright test`, since they run in every pass. The typed command is used as typed in the
|
|
119
|
+
summary commands, in the CI jobs (quoted for GitLab YAML and Jenkins Groovy) and for the
|
|
120
|
+
check. The wizard no longer asks which test script runs your tests (`INIT_SCRIPT_FLAG` and
|
|
121
|
+
`INIT_SCRIPT_LATER_STEPS` are removed);
|
|
122
|
+
- when the tests take `test` straight from `@playwright/test` and there is no fixtures module,
|
|
123
|
+
the changes step rewrites the imports of the test files: `test` and `expect` come from
|
|
124
|
+
`playwright-performance-regression/test`, other names stay. Each file is a diff you confirm;
|
|
125
|
+
setup files are left alone. The red box appears only when you decline one of them;
|
|
126
|
+
- step 9, the check, runs your test command like the real runs: first with
|
|
127
|
+
`PW_PERF_MODE=thresholds`, then with `PW_PERF_MODE=test`, both with `PW_PERF_PASSES=2`,
|
|
128
|
+
through your shell. Its thresholds go to a temporary folder that is deleted afterwards (your
|
|
129
|
+
thresholds files are not touched), a key needs only 2 successful samples, and the wizard shows
|
|
130
|
+
the exit code of each run and the most likely cause of a failure from `outcome.json`. There is
|
|
131
|
+
no check when the red "Action needed: nothing is measured yet" box is shown (with the answer
|
|
132
|
+
`steps` there is no red box, because steps are measured without the `perf` fixture);
|
|
133
|
+
- the wizard says that `globalSetup` and setup projects run once per pass, warns about
|
|
134
|
+
`request.newContext()` contexts that are not passed to `trackRequestContext()`, warns about
|
|
135
|
+
test files that still import `test` straight from `@playwright/test` after wrapping your
|
|
136
|
+
fixtures module, and reminds you to format the changed files.
|
|
137
|
+
- The wizard writes `pw-perf.config.js` in a JavaScript project (a `playwright.config.js`,
|
|
138
|
+
`.mjs` or `.cjs` without `tsconfig.json`): an ES module or CommonJS like the Playwright config,
|
|
139
|
+
with `// @ts-check`. A CommonJS config requires it without `.default`. TypeScript projects keep
|
|
140
|
+
`pw-perf.config.ts`.
|
|
141
|
+
- Warning `CONFIG_FILE_NOT_PASSED`: a `pw-perf.config.*` file next to the Playwright config is no
|
|
142
|
+
longer ignored silently when `withPerf(config)` gets no second argument; the run still uses the
|
|
143
|
+
defaults, and the hint shows how to pass the file.
|
|
144
|
+
- HTML report: a stopwatch logo in the header and as the page icon (an inline `data:` URI, no
|
|
145
|
+
extra files); a Source column (`browser` / `request`) in the Endpoints table.
|
|
146
|
+
- The report names what it is about: the run report has an optional `suite` (the package name from
|
|
147
|
+
`package.json` next to the Playwright config, else the config path from the repository root),
|
|
148
|
+
shown in the HTML header, the page title and Run & config. A measured project with only
|
|
149
|
+
`request` calls is marked `requestOnly` and reads "no browser" in Run & config and in the
|
|
150
|
+
`PW_PERF_MODE=check` output.
|
|
151
|
+
- Docs: installing in a pnpm monorepo (`pnpm add -Dw` or in every importing package,
|
|
152
|
+
`pnpm --filter <app> exec playwright test`, `--no-bail` for `pnpm -r`), `globalSetup` and setup
|
|
153
|
+
projects running once per pass, `trackRequestContext()` in fixtures, several test objects in one
|
|
154
|
+
chain (wrapping both is safe: an integration test shows every request is recorded once), an
|
|
155
|
+
example of `keys.extraIdPatterns`, and the upgrade steps from `0.1.0-next.3`.
|
|
156
|
+
|
|
157
|
+
### Changed
|
|
158
|
+
|
|
159
|
+
- `pw-perf.config.ts` written by the wizard is short: the 15 most important options (including
|
|
160
|
+
`measure.api`, `measure.steps` and `run.overrideSlowMo`), each with a short comment, and a link
|
|
161
|
+
to the full option list in `docs/configuration.md`. The "Most important settings" block and the
|
|
162
|
+
comments for every other option are gone.
|
|
163
|
+
- The wizard's commands and CI jobs use your test command from step 6, or the plain Playwright
|
|
164
|
+
command of your package manager (`npx playwright test`, `pnpm exec playwright test`,
|
|
165
|
+
`yarn playwright test`); it adds `reports/pw-perf/` to `.gitignore` unless `reports/` is
|
|
166
|
+
ignored already.
|
|
167
|
+
- The wizard's red box lists the files with `.extend()` with the number of test files that import
|
|
168
|
+
each, the most imported first, and names the one to wrap. A fixtures module of a workspace
|
|
169
|
+
package is listed too, with a note to install the package in the workspace root. Nested git
|
|
170
|
+
repositories (submodules) are no longer scanned unless your sources import from them.
|
|
171
|
+
- HTML report: the view switch (Overview, Endpoints, Steps, Tests, …) is a row of tabs. The
|
|
172
|
+
selected tab has an accent underline and background, every tab is at least 44 px high, and on a
|
|
173
|
+
narrow screen the bar scrolls to show the selected tab. The Endpoints and Steps tab counts are
|
|
174
|
+
neutral with a red badge of keys with violations.
|
|
175
|
+
- HTML report details: a key without timed samples shows its other statuses under Samples and in
|
|
176
|
+
its details, e.g. "5 × 404 (not timed)"; the thresholds file source is shortened to the version
|
|
177
|
+
and the date (full text on hover); Top keys in the Tests tab put the time under each key; "Most
|
|
178
|
+
expensive tests" names the project when more than one is measured; the TTFB column is hidden
|
|
179
|
+
when no key has TTFB; a step without a location reads "boxed step (no location)".
|
|
180
|
+
- Violations are counted the same way in the console and the HTML report: failed checks with the
|
|
181
|
+
number of keys (`8 blocking violations in 7 keys`); the Violations tile counts failed checks
|
|
182
|
+
too. Apdex, slow share (wilson) and error rate over the limit read in percentage points
|
|
183
|
+
(`+81 pp`) instead of a relative percent that showed `>999%`.
|
|
184
|
+
- `Next:` after a `test` or `check` run repeats the arguments you added (`PW_PERF_MODE=test npm
|
|
185
|
+
run e2e -- --project=desktop`); the thresholds command stays without them, so thresholds come
|
|
186
|
+
from the whole suite. When the package manager was called from a parent directory (e.g. the
|
|
187
|
+
root of a monorepo), the command starts with `cd <directory> && `.
|
|
188
|
+
- The start banner no longer guesses 30 s per test before the first run: the estimate says
|
|
189
|
+
`unknown (run PW_PERF_MODE=check for an estimate)`. A time under a minute reads `< 1 min`
|
|
190
|
+
without `≈`, and there is no `Tip` when `run.grep` is set.
|
|
191
|
+
- The line of a later pass shows your command (`pass 2/10: npx playwright test`,
|
|
192
|
+
`pass 2/10: npm run e2e -- --grep cart`) instead of the full paths of the process.
|
|
193
|
+
- The `Outcome:` line starts with the exit code of the process: `Outcome: Playwright exit code 1 ·
|
|
194
|
+
details: performance failed (code 2) in …/outcome.json`.
|
|
195
|
+
- The thresholds diff lists the skipped keys with the reason (`no successful samples, 5 needed
|
|
196
|
+
(5 × 404)`): up to 5 in the console, all in `thresholds-diff.md`. The Apdex T limit reads
|
|
197
|
+
`apdex T 500 ms` instead of `t 500`.
|
|
198
|
+
- Samples from a project that is only a dependency or teardown of other projects (a usual `setup`
|
|
199
|
+
project) no longer give the `STATS_SAMPLES_OUTSIDE_MEASURED_PROJECTS` warning.
|
|
200
|
+
- `TESTS_NOT_INSTRUMENTED` counts tests instead of test results and names up to three files, e.g.
|
|
201
|
+
`2 tests in tests/api.spec.ts import test without withPerfFixtures() …`; a crashed worker is
|
|
202
|
+
mentioned only when a worker actually crashed.
|
|
203
|
+
- The examples run with `PW_PERF_MODE=… npm test` instead of `perf:*` scripts.
|
|
204
|
+
|
|
205
|
+
### Fixed
|
|
206
|
+
|
|
207
|
+
- Collector: with Playwright 1.57 (Chromium) a `fetch` answered with `204 No Content` was
|
|
208
|
+
recorded as `ABORTED` with no time, so endpoints such as `DELETE /api/items/:id` were never
|
|
209
|
+
measured. A 204, 205 or 304 response followed by `requestfailed` is now a sample with its status
|
|
210
|
+
and time.
|
|
211
|
+
- Collector: a request whose response arrived but whose body was then aborted (typically a login
|
|
212
|
+
or form `fetch` followed at once by `location.href = …`) was recorded as `ABORTED`, so
|
|
213
|
+
successful logins were never measured and the key kept only the failed attempts. A response
|
|
214
|
+
followed by an abort (`net::ERR_ABORTED`, `NS_BINDING_ABORTED`, …) is now a sample with its
|
|
215
|
+
status and time (up to the end of the body, or to the headers when the body was cut off); other
|
|
216
|
+
failures after a response stay `FAILED`.
|
|
217
|
+
- Types of `playwright-performance-regression/config`, `/fixture`, `/test` and `/reporter`
|
|
218
|
+
resolve in TypeScript projects without `exports` support (`"module": "commonjs"` with no
|
|
219
|
+
`moduleResolution`, i.e. `node10`): `tsc` no longer fails with `Cannot find module`, and a
|
|
220
|
+
wrapped `test` keeps its fixture types instead of `any`.
|
|
221
|
+
- With `PW_PERF_PASSES` above 1, `PW_PERF_MODE=… npx playwright test` no longer starts pass 2 as
|
|
222
|
+
`npm run npx` ("Missing script"): a package script runs again only when `package.json` has it.
|
|
223
|
+
The `Next:` hint no longer suggests `npm run npx` either.
|
|
224
|
+
- `CONFIG_SLOW_MO` warns only about projects measured in the run. A run with `--project=api`
|
|
225
|
+
warned about the `slowMo` of an e2e project that did not run (and of setup projects), in every
|
|
226
|
+
run.
|
|
227
|
+
- A thresholds run that selects a subset of the tests (`--grep`, `--project`, file filters) no
|
|
228
|
+
longer ends with "Run with PW_PERF_PRUNE=1 to remove them": pruning is ignored in such a run
|
|
229
|
+
(`RUN_PRUNE_SKIPPED`). The line now says that the run selects a subset of the tests.
|
|
230
|
+
- A `PW_PERF_MODE=thresholds` run no longer warns with `THRESHOLDS_FILE_MISSING` about the
|
|
231
|
+
thresholds file it is creating.
|
|
232
|
+
- `PW_PERF_MODE=check` uses the singular for one item (`1 sample · 1 test`, `5 requests in 1
|
|
233
|
+
test`, `1 of 1 test run`, `1 api key`) instead of `1 samples · 1 tests`.
|
|
234
|
+
- HTML report: long endpoint and step names no longer run into the next column. In the Endpoints
|
|
235
|
+
and Steps tables the name wraps inside the Key cell; in the Overview cards it is cut with an
|
|
236
|
+
ellipsis and the full name is shown on hover.
|
|
237
|
+
- HTML report: the key labels of a waterfall (Tests tab) are monospace with the method in its
|
|
238
|
+
colour again; in Chromium they were unstyled and a long method such as `DELETE` overlapped the
|
|
239
|
+
path.
|
|
240
|
+
- Setup wizard: project detection reads the whole project, not only `testDir`, so fixtures modules
|
|
241
|
+
and page objects next to the test directory (e.g. `testDir: './tests/specs'` with
|
|
242
|
+
`tests/fixtures/`) are found: a single fixtures module there is wrapped, and the "nothing is
|
|
243
|
+
measured yet" box lists the files with `.extend(`. `.extend(` in application code (e.g. zod
|
|
244
|
+
schemas) no longer counts as a fixtures module, and the box counts only test files that import
|
|
245
|
+
`test` from `@playwright/test`, not page objects or fixtures modules.
|
|
246
|
+
- Setup wizard: the red box no longer says "nothing is measured yet" when you answer `all` and your
|
|
247
|
+
tests use `test.step`: the step durations are measured, so the box says "Endpoints are not
|
|
248
|
+
measured yet" (in all 7 languages), and the wizard offers the check.
|
|
249
|
+
- Setup wizard: the red box (`INIT_TEST_OBJECT_MANUAL`) is full width in a pseudo-terminal that
|
|
250
|
+
reports 0 columns (e.g. `expect`, `docker -t`) instead of being cut to 40 columns, and counts
|
|
251
|
+
the test files as `(files: 1)` instead of `(1 files)` (English, Spanish, French, Italian).
|
|
252
|
+
- Setup wizard: no `.gitignore` entry is added when the file already ignores the report folder
|
|
253
|
+
with a glob such as `/reports/**/*` or `reports/*`.
|
|
254
|
+
- Setup wizard translations reviewed: the no-terminal note has its missing full stop in every
|
|
255
|
+
language; one term per idea in each language (es "tests", it "passaggi" and "verifica", uk/ru
|
|
256
|
+
"воркер" and endpoint keys); French uses a no-break space before `:` `;` `?` `!` and French and
|
|
257
|
+
Italian use typographic apostrophes; the red box title fits 80 columns in every language (it
|
|
258
|
+
was cut in es, fr, pl and it).
|
|
259
|
+
|
|
10
260
|
## [0.1.0-next.3] - 2026-11-21
|
|
11
261
|
|
|
12
262
|
`0.1.0-next.2` was tagged but not published (the release stopped on the performance tests).
|
package/README.md
CHANGED
|
@@ -11,9 +11,10 @@ Catch backend performance regressions from the Playwright tests you already have
|
|
|
11
11
|
|
|
12
12
|
## How it works
|
|
13
13
|
|
|
14
|
-
1. **Measures** the backend requests your browser makes
|
|
15
|
-
|
|
16
|
-
in a row (passes), and
|
|
14
|
+
1. **Measures** the backend requests your browser makes (and the `request` calls of API tests)
|
|
15
|
+
while your existing e2e tests run, in a separate measurement run
|
|
16
|
+
(`PW_PERF_MODE=test npm run e2e`): your test command runs a few times in a row (passes), and
|
|
17
|
+
all passes are evaluated together.
|
|
17
18
|
2. **Groups** the requests into endpoint keys such as `GET /api/orders/:id`, and computes
|
|
18
19
|
statistics per key: median, p95, p99, error rate and more.
|
|
19
20
|
3. **Derives thresholds** from a run and writes them to JSON files that you review and commit like
|
|
@@ -29,15 +30,22 @@ Your normal `npx playwright test` runs are not changed.
|
|
|
29
30
|
npm init playwright-performance-regression@next
|
|
30
31
|
```
|
|
31
32
|
|
|
32
|
-
This installs the package as a dev dependency and starts a short guided setup (`
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
This installs the package as a dev dependency and starts a short guided setup (after `0.1.0`:
|
|
34
|
+
`npm init playwright-performance-regression`; run it again at any time; in a project with the
|
|
35
|
+
package installed, `npx pw-perf` starts it too). It asks which tests to measure, the passes, what
|
|
36
|
+
to measure (endpoints, `test.step` blocks or both), the threshold headroom and your usual test
|
|
37
|
+
command, then shows a diff of every change before writing it: it creates `pw-perf.config.ts`
|
|
38
|
+
(`pw-perf.config.js` in a JavaScript project) with the most important options, wraps your
|
|
39
|
+
Playwright config and your fixtures module, ignores `reports/pw-perf/` and can add the CI jobs.
|
|
40
|
+
Without a fixtures module, it switches the `@playwright/test` imports of your test files to
|
|
41
|
+
`playwright-performance-regression/test`, one confirmed diff per file; when it cannot change the
|
|
42
|
+
test object, it shows the code to paste. `package.json` is never changed. At the end it offers a
|
|
43
|
+
check: your test command runs with `PW_PERF_MODE=thresholds`, then `PW_PERF_MODE=test`, both with
|
|
44
|
+
2 passes, and the check's thresholds files are deleted afterwards. `pnpm create` and `yarn create`
|
|
45
|
+
work too (Yarn 2 or later; Yarn 1 cannot install a specific version such as `@next` with
|
|
46
|
+
`yarn create`). The guided setup speaks English, Spanish, French, Polish, Italian, Ukrainian and
|
|
47
|
+
Russian (it asks at the start). It takes no arguments; `PW_PERF_LANG`, `PW_PERF_DRY_RUN` and
|
|
48
|
+
`PW_PERF_NO_TUTORIAL` change it ([Guided setup](docs/cli.md#guided-setup)).
|
|
41
49
|
|
|
42
50
|
<details>
|
|
43
51
|
<summary>Manual setup</summary>
|
|
@@ -74,7 +82,8 @@ import { test, expect } from 'playwright-performance-regression/test';
|
|
|
74
82
|
```
|
|
75
83
|
|
|
76
84
|
Optionally add `pw-perf.config.ts` and pass it as the second argument of `withPerf()`; see
|
|
77
|
-
[Configuration](docs/configuration.md).
|
|
85
|
+
[Configuration](docs/configuration.md). Remove `--reporter` from the command you measure with:
|
|
86
|
+
it replaces the package reporter, so a measurement run stops with `RUN_REPORTER_FLAG`.
|
|
78
87
|
|
|
79
88
|
</details>
|
|
80
89
|
|
|
@@ -97,9 +106,10 @@ On Windows: `npx cross-env PW_PERF_MODE=test npm run e2e` (PowerShell and cmd fo
|
|
|
97
106
|
[docs/cli.md](docs/cli.md)). Without the variable the tests run as before, with no measuring.
|
|
98
107
|
|
|
99
108
|
The exit code is Playwright's own; the cause of a failure (a regression, failed tests, a config
|
|
100
|
-
error) is in `pw-perf
|
|
101
|
-
to `pw-perf
|
|
102
|
-
|
|
109
|
+
error) is in `reports/pw-perf/outcome.json`. The result is also printed in the terminal and written
|
|
110
|
+
to `reports/pw-perf/report.json` and `reports/pw-perf/report.html` (tabs Overview, Endpoints,
|
|
111
|
+
Steps, Tests and Run & config). Every `test` and `thresholds` run empties `reports/pw-perf/` first,
|
|
112
|
+
so it holds only the last run. All variables are described in [Running](docs/cli.md).
|
|
103
113
|
|
|
104
114
|
Derive thresholds on the same machines that run the check, usually your CI runners (see
|
|
105
115
|
[CI](#ci) below); thresholds measured on a laptop do not fit CI. How much headroom they get is one
|
|
@@ -108,17 +118,14 @@ setting, `thresholds: { preset: 'strict' | 'normal' | 'loose' }`. See
|
|
|
108
118
|
|
|
109
119
|
## Step timings
|
|
110
120
|
|
|
111
|
-
Your existing `test.step` blocks
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
// pw-perf.config.ts
|
|
115
|
-
export default definePerfConfig({ measure: { steps: true } });
|
|
116
|
-
```
|
|
121
|
+
Your existing `test.step` blocks are measured too, without changing the tests (on by default;
|
|
122
|
+
`measure: { steps: false }` in `pw-perf.config.ts` turns it off, `measure: { api: false }` measures
|
|
123
|
+
only the steps).
|
|
117
124
|
|
|
118
125
|
A step `submit` inside a step `login` becomes the key `login › submit`, with its own statistics,
|
|
119
126
|
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
|
|
121
|
-
[Step timings](docs/steps.md).
|
|
127
|
+
e-mails, URLs and secrets never reach the keys or the reports, also inside quotes; numbers in
|
|
128
|
+
words become `:num` (`Transfer 1500 PLN` → `Transfer :num PLN`). See [Step timings](docs/steps.md).
|
|
122
129
|
|
|
123
130
|
## CI
|
|
124
131
|
|
|
@@ -156,26 +163,32 @@ jobs:
|
|
|
156
163
|
- run: npm run e2e
|
|
157
164
|
- uses: actions/upload-artifact@v7
|
|
158
165
|
if: always() # the report matters most when the run fails
|
|
159
|
-
with: { name: pw-perf-
|
|
166
|
+
with: { name: pw-perf-report, path: reports/pw-perf/ }
|
|
160
167
|
```
|
|
161
168
|
|
|
162
169
|
Not ready to block builds yet? Set `continue-on-error: true` on the measure job. The full recipes
|
|
163
170
|
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
|
|
171
|
+
**2** performance regression, **3** tool or config error) from `reports/pw-perf/outcome.json`:
|
|
165
172
|
[CI](docs/ci.md).
|
|
166
173
|
|
|
167
174
|
## Limitations
|
|
168
175
|
|
|
169
176
|
- REST only: every GraphQL query goes to the same endpoint key.
|
|
170
|
-
-
|
|
171
|
-
|
|
172
|
-
|
|
177
|
+
- Requests made by the browser and calls of Playwright's `request` fixture, `page.request` and
|
|
178
|
+
`context.request` are measured (keys such as `request GET /api/orders/:id`, separate from the
|
|
179
|
+
browser's); other HTTP clients (Node `fetch`, axios) are not. API tests are measured only when
|
|
180
|
+
they import `test` from the wrapped test object, and contexts from `request.newContext()` only
|
|
181
|
+
after `trackRequestContext(context)` ([Adoption](docs/adoption.md)).
|
|
182
|
+
- The projects your test command selects are measured (all without `--project`), except setup and
|
|
183
|
+
teardown projects. Chromium is supported; Firefox and WebKit are best effort, so select one engine
|
|
184
|
+
with `--project`.
|
|
173
185
|
- The measurement run is separate from your normal run, uses one worker and runs your test command
|
|
174
186
|
several times (passes), so it is slow: measure a subset (`run: { grep: '@perf' }`, `--project`).
|
|
175
187
|
- The test command, with its setup steps, runs once per pass; tests that create data without such
|
|
176
188
|
a step can collide in the next pass; make the data unique.
|
|
177
189
|
- A `--reporter` flag in the test command replaces the package reporter, so nothing is reported
|
|
178
|
-
(
|
|
190
|
+
(a test or thresholds run stops with `RUN_REPORTER_FLAG`); keep reporters in
|
|
191
|
+
`playwright.config` instead.
|
|
179
192
|
|
|
180
193
|
## Privacy
|
|
181
194
|
|
|
@@ -184,7 +197,7 @@ No telemetry. The package never makes network requests.
|
|
|
184
197
|
What ends up where:
|
|
185
198
|
|
|
186
199
|
- **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
|
|
200
|
+
UUIDs, long hex strings, tokens, mixed-case ids, prefixed ids (`ORD-1000`, `inv_58`) and e-mail addresses in the path are replaced
|
|
188
201
|
with `:id` or `:email`, and query values are dropped (only parameter names stay). Path segments
|
|
189
202
|
that match none of these patterns, such as user names, stay in the key; add patterns with
|
|
190
203
|
`keys.extraIdPatterns`. The report also contains test titles, file names, the operating system, CPU model
|
|
@@ -209,7 +222,7 @@ that Playwright's HTML report and traces contain the full URLs.
|
|
|
209
222
|
## Documentation
|
|
210
223
|
|
|
211
224
|
- [Configuration](docs/configuration.md): every option with its default
|
|
212
|
-
- [
|
|
225
|
+
- [Running](docs/cli.md): variables, the guided setup and exit codes
|
|
213
226
|
- [Adoption](docs/adoption.md): existing projects, choosing tests, sample counts
|
|
214
227
|
- [Thresholds](docs/thresholds.md): deriving, reviewing, locking and muting
|
|
215
228
|
- [Step timings](docs/steps.md): measuring `test.step` blocks, keys and title sanitization
|
|
@@ -273,11 +273,12 @@ var DEFAULT_CONFIG = {
|
|
|
273
273
|
run: {
|
|
274
274
|
env: null,
|
|
275
275
|
passes: { test: 5, thresholds: 10 },
|
|
276
|
-
projects: "auto",
|
|
277
276
|
grep: null,
|
|
278
|
-
keepReporters: []
|
|
277
|
+
keepReporters: [],
|
|
278
|
+
overrideSlowMo: false
|
|
279
279
|
},
|
|
280
280
|
measure: {
|
|
281
|
+
api: true,
|
|
281
282
|
resourceTypes: ["document", "xhr", "fetch"],
|
|
282
283
|
ignoreExtensions: [
|
|
283
284
|
".js",
|
|
@@ -303,12 +304,20 @@ var DEFAULT_CONFIG = {
|
|
|
303
304
|
exclude: ["/socket.io/"],
|
|
304
305
|
excludeKnownThirdParty: true,
|
|
305
306
|
successStatuses: ["2xx", "3xx"],
|
|
306
|
-
steps:
|
|
307
|
+
steps: true,
|
|
307
308
|
pendingTimeoutMs: 2e3
|
|
308
309
|
},
|
|
309
310
|
keys: {
|
|
310
311
|
origins: {},
|
|
311
|
-
idPatterns: {
|
|
312
|
+
idPatterns: {
|
|
313
|
+
number: true,
|
|
314
|
+
uuid: true,
|
|
315
|
+
hex: true,
|
|
316
|
+
token: true,
|
|
317
|
+
mixed: true,
|
|
318
|
+
prefixed: true,
|
|
319
|
+
email: true
|
|
320
|
+
},
|
|
312
321
|
extraIdPatterns: [],
|
|
313
322
|
query: "names",
|
|
314
323
|
keepQueryValues: [],
|
|
@@ -372,7 +381,7 @@ var DEFAULT_CONFIG = {
|
|
|
372
381
|
hysteresis: { relative: 0.1, ratio: 0.01 },
|
|
373
382
|
loosenWarnRelative: 0.5
|
|
374
383
|
},
|
|
375
|
-
report: { dir: "pw-perf
|
|
384
|
+
report: { dir: "reports/pw-perf", html: true, rawUrls: false },
|
|
376
385
|
advanced: { maxSamplesPerKey: 5e3, seed: 1 }
|
|
377
386
|
};
|
|
378
387
|
|
|
@@ -628,11 +637,12 @@ var packageConfig = obj({
|
|
|
628
637
|
test: int({ minimum: 1, maximum: 1e3 }),
|
|
629
638
|
thresholds: int({ minimum: 1, maximum: 1e3 })
|
|
630
639
|
}),
|
|
631
|
-
projects: oneOf(constant("auto"), arr(str(), { minItems: 1, uniqueItems: true })),
|
|
632
640
|
grep: nullable(str({ minLength: 1 })),
|
|
633
|
-
keepReporters: uniqueStrings(1)
|
|
641
|
+
keepReporters: uniqueStrings(1),
|
|
642
|
+
overrideSlowMo: bool
|
|
634
643
|
}),
|
|
635
644
|
measure: obj({
|
|
645
|
+
api: bool,
|
|
636
646
|
resourceTypes: arr(
|
|
637
647
|
enumOf([
|
|
638
648
|
"document",
|
|
@@ -704,6 +714,7 @@ var packageConfig = obj({
|
|
|
704
714
|
hex: bool,
|
|
705
715
|
token: bool,
|
|
706
716
|
mixed: bool,
|
|
717
|
+
prefixed: bool,
|
|
707
718
|
email: bool
|
|
708
719
|
}),
|
|
709
720
|
extraIdPatterns: arr(urlPattern),
|
|
@@ -1106,6 +1117,18 @@ function relationalIssues(config, isSet) {
|
|
|
1106
1117
|
)
|
|
1107
1118
|
);
|
|
1108
1119
|
}
|
|
1120
|
+
const steps = valueAt(config, ["measure", "steps"]);
|
|
1121
|
+
const stepsOff = steps === false || isRecord(steps) && steps["enabled"] === false;
|
|
1122
|
+
if (valueAt(config, ["measure", "api"]) === false && stepsOff) {
|
|
1123
|
+
errors.push(
|
|
1124
|
+
issue2(
|
|
1125
|
+
"CONFIG_INVALID_VALUE",
|
|
1126
|
+
["measure"],
|
|
1127
|
+
"measure.api and measure.steps are both off, so nothing would be measured",
|
|
1128
|
+
"Turn on at least one of them: measure.api (backend requests) or measure.steps (test.step durations)."
|
|
1129
|
+
)
|
|
1130
|
+
);
|
|
1131
|
+
}
|
|
1109
1132
|
const env = valueAt(config, ["run", "env"]);
|
|
1110
1133
|
if (typeof env === "string" && RESERVED_ENV_LABELS.includes(env)) {
|
|
1111
1134
|
errors.push(reservedEnvIssue(["run", "env"], env));
|
|
@@ -1312,6 +1335,11 @@ function overrideIssues(overrides) {
|
|
|
1312
1335
|
}
|
|
1313
1336
|
function applyOverrides(config, overrides) {
|
|
1314
1337
|
if (overrides.env !== void 0) config.run.env = overrides.env;
|
|
1338
|
+
if (overrides.thresholdsDir !== void 0) config.thresholds.dir = overrides.thresholdsDir;
|
|
1339
|
+
if (overrides.minSamples !== void 0) {
|
|
1340
|
+
const median = config.checks.time.median;
|
|
1341
|
+
median.minSamples = Math.min(median.minSamples, overrides.minSamples);
|
|
1342
|
+
}
|
|
1315
1343
|
if (overrides.passes !== void 0) {
|
|
1316
1344
|
config.run.passes[overrides.mode === "thresholds" ? "thresholds" : "test"] = overrides.passes;
|
|
1317
1345
|
}
|