playwright-performance-regression 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,118 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.1.0] - 2026-11-28
11
+
12
+ ### Added
13
+
14
+ - **Cold and warm samples.** The first timed sample of every key in each pass is cold
15
+ (`measure.coldSamples`, 1 by default, 0 turns it off): a slow first call after the application
16
+ or its container started no longer moves p95 on small sample counts. Each pass is a new
17
+ Playwright process, and a `webServer` starts the application again in every pass, so the counter
18
+ starts again in every pass (and every shard). Cold samples stay out of the evaluated statistics
19
+ only when at least `checks.time.median.minSamples` warm samples remain (5 by default), so a key
20
+ called once per pass is still evaluated by the median of all its samples. The report has a `cold` block per key, the HTML report a "Cold vs
21
+ warm" block and a "Slowest first calls" ranking, and the new warning `STATS_COLD_SLOW` names keys
22
+ whose first call is at least three times slower than their warm median.
23
+ - **Fast failures: the `nonSuccess` rule.** An endpoint that starts answering 401, 403, 404 or 5xx
24
+ fast no longer passes silently because it has no successful samples to time. Thresholds runs
25
+ write `maxNonSuccessRate` (the share of responses outside `measure.successStatuses` in the
26
+ thresholds run, with the margin `checks.nonSuccess.margin`), and the rule compares the lower
27
+ bound of the current share with it. Keys without an entry are not checked unless you set
28
+ `checks.nonSuccess.limit.api`. Keys with an entry whose responses were not successful get the
29
+ warning `THRESHOLDS_ENTRY_NOT_TIMED`. The report counts these responses per key
30
+ (`nonSuccessCount`) and keeps their durations per status (`failedTimings`, shown under
31
+ "Unsuccessful responses"); they never enter the time statistics.
32
+ - **Workload context.** Every new or replaced thresholds entry records the samples of its source
33
+ run (`source`), and the file records `generated.coldSamples` and `generated.sourcePasses`. Each
34
+ evaluated key gets `evaluation.workload` (samples, passes, workers and its share of the traffic,
35
+ then and now); the console shows the samples as `now/base` in the violations table with a
36
+ `Workload:` line, the HTML report a "Compared with the thresholds run" block, `junit.xml` a
37
+ `workload:` line. The new warning `THRESHOLDS_WORKLOAD_SHIFT` names keys whose samples per pass
38
+ changed by `thresholds.workloadShift.factor` (2 by default) or more.
39
+ - **Keys per GraphQL operation and tRPC procedure.** `keys.operations` (empty by default) gives
40
+ endpoints that serve many operations under one URL a key per operation:
41
+ `{ type: 'graphql', match: '/graphql' }` turns `POST /graphql` into `POST /graphql#GetTickets`,
42
+ `POST /graphql#CreateOrder` and, for batches, `POST /graphql#GetTickets+GetUser`;
43
+ `{ type: 'trpc', match: /^\/api\/trpc\// }` gives `GET /api/trpc#post.byId`. The request body is
44
+ read only for `POST` requests matching a `graphql` entry (up to 64 KB, in the test worker) and
45
+ only the operation names are kept. `keys.keyBuilder` gets them as `operation`. A request whose
46
+ operation cannot be read keeps its old key and gives the warning `COLLECTOR_OPERATION_UNKNOWN`.
47
+ The HTML report suggests the option for keys that look like GraphQL or tRPC. See
48
+ [Operations](docs/configuration.md#operations) for migrating the thresholds files.
49
+ - **Sharded runs.** A perf-mode run with Playwright's `--shard=i/n` no longer stops with
50
+ `RUN_SHARDED`: each shard measures its tests in all passes and writes
51
+ `reports/pw-perf/shard-<i>-of-<n>.json` without evaluating, and `PW_PERF_MODE=merge npx pw-perf`
52
+ in a merge job (no browsers needed) evaluates all shards as one run, with one report,
53
+ `junit.xml`, `outcome.json` and, in a thresholds run, one complete set of thresholds files.
54
+ Cold samples are counted per shard and pass. The run report has a `shards` field (`null` without shards),
55
+ the console and the HTML report say `merged from 4 shards` and list the shards. A check with
56
+ `--shard` checks the tests of that shard. New codes: `SHARD_WRITE_FAILED`, `MERGE_NO_SHARD_FILES`,
57
+ `MERGE_SHARD_INVALID`, `MERGE_SHARD_MISMATCH`, `MERGE_SHARD_DUPLICATE`, `MERGE_SHARD_MISSING`,
58
+ `MERGE_WRONG_DIRECTORY`, `MERGE_SHARDS_DIFFERENT_COMMIT`, `MERGE_SHARDS_DIFFERENT_HOSTS`,
59
+ `MERGE_ENV_IGNORED` and `MERGE_INTERNAL_ERROR`. Recipes with a shard matrix and a merge job for
60
+ GitHub Actions, GitLab CI, Jenkins and Azure Pipelines are in `examples/ci/sharded/`; see
61
+ [Sharded runs](docs/ci.md#sharded-runs). The start banner of a run estimated above two hours
62
+ suggests `--shard`.
63
+ - **Fast-failure example and demo.** [Thresholds](docs/thresholds.md#fast-failures-and-workload-changes)
64
+ walks through a real run of `examples/with-setup` in which an endpoint answers 401 in a few
65
+ milliseconds instead of 200 in 120 ms: what the time and error rules do, how the `nonSuccess`
66
+ rule fails it, a workload shift and a cold first call, with console excerpts and screenshots.
67
+ The demo on GitHub Pages has a landing page with two reports, `slow-endpoint.html` (formerly the
68
+ only report, at `index.html`) and `fast-failure.html`; the README links it.
69
+ [Upgrading](docs/upgrading.md#from-10x-to-110) has a section for 1.0.x → 1.1.0.
70
+
71
+ ### Changed
72
+
73
+ - **Run report version 5, thresholds file version 3, sample batch version 4.** Older reports and
74
+ thresholds files are migrated when read (a thresholds file gives `THRESHOLDS_FILE_OUTDATED` until the next thresholds
75
+ run rewrites it). The next thresholds run adds `maxNonSuccessRate` and `source` also to entries
76
+ it keeps by hysteresis, without changing their limits (`+new fields` in the diff).
77
+ - Thresholds derived with another `measure.coldSamples` give `THRESHOLDS_SOURCE_MISMATCH`.
78
+ - The run report gets `shards: null` when a report of version 4 is migrated.
79
+ - The package's own tests run with `@playwright/test` 1.65.1 (development dependency only; the
80
+ supported Playwright range is unchanged).
81
+ - The package's own type checks use `@types/node` 26 (development dependency only; the supported
82
+ Node.js versions are unchanged).
83
+ - README: GraphQL and tRPC are no longer listed as a limitation (`keys.operations`), and "How it
84
+ works" names fast failures.
85
+
86
+ ### Removed
87
+
88
+ - `RUN_SHARDED`: sharded perf-mode runs are supported (see "Sharded runs" above).
89
+
90
+ ### Fixed
91
+
92
+ - `Next:` after a run failed only by the `nonSuccess` or `errors` rule talks about the new response
93
+ statuses instead of a slowdown; after a shard merge it points to the thresholds run of the shard
94
+ jobs instead of `npx playwright test`.
95
+ - `THRESHOLDS_WORKLOAD_SHIFT` says when shifted keys have samples from retries of failed tests;
96
+ `THRESHOLDS_SOURCE_MISMATCH` after a change of normalization suggests `PW_PERF_PRUNE=1`.
97
+ - The HTML ranking of errors becomes "Highest failure rate" when keys have unsuccessful responses
98
+ that are not errors (e.g. fast 401s), instead of "No errors in this run".
99
+ - The wizard imports `./pw-perf.config.ts` with its extension when `tsconfig.json` has
100
+ `allowImportingTsExtensions` (`tsc` with `module: "nodenext"` refused the import without it).
101
+ - `check` shows an empty `baseURL` as `(empty)`; the `CONFIG_BASEURL_EMPTY` hint uses the package
102
+ manager of the project.
103
+ - `THRESHOLDS_KEYS_ON_DEFAULTS` and the "On default thresholds" console table no longer list keys
104
+ without successful samples (e.g. an endpoint a test calls on purpose for a 404): a thresholds
105
+ run never writes an entry for them, so the advice to derive thresholds did not help.
106
+ - A shard without tests (e.g. `--shard=5/5` with a `--grep` that leaves fewer tests than shards)
107
+ no longer reports `CONFIG_NO_MEASURED_PROJECT` and exits with code 0; it writes its empty shard
108
+ file as before.
109
+
110
+ ## [1.0.1] - 2026-11-25
111
+
112
+ A hotfix release.
113
+
114
+ ### Fixed
115
+
116
+ - **Later passes repeat your script when it calls `npx playwright test`.** A script such as
117
+ `"e2e:qa": "npm run prep && npx playwright test --grep …"` ran later passes as the bare
118
+ `npx playwright test …` command, because `npx` hides the name of the outer script. The reporter
119
+ now finds the `npm run e2e:qa` process above Playwright and runs `npm run e2e:qa` again, so the
120
+ steps before Playwright run in every pass too. On Windows the behaviour is unchanged.
121
+
10
122
  ## [1.0.0] - 2026-11-23
11
123
 
12
124
  The first stable release, published under the `latest` dist-tag: install with
package/README.md CHANGED
@@ -4,6 +4,8 @@ Catch backend performance regressions from the Playwright tests you already have
4
4
 
5
5
  ![HTML report of a measurement run](.github/assets/report.png)
6
6
 
7
+ Live demo reports of an example project: [a slow endpoint and a fast failure](https://meser6.github.io/playwright-performance-regression/).
8
+
7
9
  ## How it works
8
10
 
9
11
  1. **Measures** the backend requests your browser makes (and the `request` calls of API tests)
@@ -14,8 +16,9 @@ Catch backend performance regressions from the Playwright tests you already have
14
16
  statistics per key: median, p95, p99, error rate and more.
15
17
  3. **Derives thresholds** from a run and writes them to JSON files that you review and commit like
16
18
  code.
17
- 4. **Fails the run** when an endpoint gets slower or returns more errors than its thresholds
18
- allow, with a console summary and a self-contained HTML report.
19
+ 4. **Fails the run** when an endpoint gets slower, returns more errors or fails fast more often
20
+ (a 401 in 8 ms instead of a 200 in 120 ms) than its thresholds allow, with a console summary
21
+ and a self-contained HTML report.
19
22
 
20
23
  Your normal `npx playwright test` runs are not changed.
21
24
 
@@ -172,7 +175,9 @@ for GitHub Actions, GitLab CI, Jenkins and Azure Pipelines read the exact exit c
172
175
 
173
176
  ## Limitations
174
177
 
175
- - REST only: every GraphQL query goes to the same endpoint key.
178
+ - Keys come from the method and the URL. GraphQL and tRPC endpoints get a key per operation or
179
+ procedure only when you list them in `keys.operations`; otherwise every GraphQL query shares
180
+ one key ([Operations](docs/configuration.md#operations)).
176
181
  - Requests made by the browser and calls of Playwright's `request` fixture, `page.request` and
177
182
  `context.request` are measured (keys such as `request GET /api/orders/:id`, separate from the
178
183
  browser's); other HTTP clients (Node `fetch`, axios) are not. API tests are measured only when
@@ -182,7 +187,9 @@ for GitHub Actions, GitLab CI, Jenkins and Azure Pipelines read the exact exit c
182
187
  teardown projects. Chromium is supported; Firefox and WebKit are best effort, so select one engine
183
188
  with `--project`.
184
189
  - The measurement run is separate from your normal run, uses one worker and runs your test command
185
- several times (passes), so it is slow: measure a subset (`run: { grep: '@perf' }`, `--project`).
190
+ several times (passes), so it is slow: measure a subset (`run: { grep: '@perf' }`, `--project`),
191
+ or split it across machines with `--shard` and merge the shards in one job
192
+ ([Sharded runs](docs/ci.md#sharded-runs)).
186
193
  - The test command, with its setup steps, runs once per pass; tests that create data without such
187
194
  a step can collide in the next pass; make the data unique.
188
195
  - A `--reporter` flag in the test command replaces the package reporter, so nothing is reported