playwright-performance-regression 0.0.0-stage → 0.1.0-next.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 +268 -0
- package/LICENSE +21 -0
- package/README.md +214 -2
- package/dist/chunk-6AB42SPF.js +254 -0
- package/dist/chunk-DYLCGMI2.js +63 -0
- package/dist/chunk-GCA73FFP.cjs +1139 -0
- package/dist/chunk-HES6BVZT.js +1097 -0
- package/dist/chunk-JEHUFIY3.js +3390 -0
- package/dist/chunk-LV3O2BAT.cjs +319 -0
- package/dist/chunk-R2NPYGB7.cjs +758 -0
- package/dist/chunk-UTTU4FUC.js +756 -0
- package/dist/cli.js +2909 -0
- package/dist/config.cjs +256 -0
- package/dist/config.d.cts +15 -0
- package/dist/config.d.ts +15 -0
- package/dist/config.js +252 -0
- package/dist/fixture.cjs +16 -0
- package/dist/fixture.d.cts +22 -0
- package/dist/fixture.d.ts +22 -0
- package/dist/fixture.js +4 -0
- package/dist/index.cjs +14 -0
- package/dist/index.d.cts +637 -0
- package/dist/index.d.ts +637 -0
- package/dist/index.js +1 -0
- package/dist/perf-api-V4PeHVE0.d.cts +22 -0
- package/dist/perf-api-V4PeHVE0.d.ts +22 -0
- package/dist/reporter.cjs +4769 -0
- package/dist/reporter.d.cts +18 -0
- package/dist/reporter.d.ts +18 -0
- package/dist/reporter.js +1409 -0
- package/dist/test.cjs +14 -0
- package/dist/test.d.cts +7 -0
- package/dist/test.d.ts +7 -0
- package/dist/test.js +10 -0
- package/package.json +146 -4
- package/schemas/common.schema.json +81 -0
- package/schemas/config.schema.json +875 -0
- package/schemas/outcome.schema.json +44 -0
- package/schemas/run-report.schema.json +505 -0
- package/schemas/samples.schema.json +169 -0
- package/schemas/thresholds.schema.json +138 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
|
|
6
|
+
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0-next.0] - 2026-11-19
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Package manifest with the entry points `playwright-performance-regression`, `/config`,
|
|
15
|
+
`/fixture`, `/test`, `/reporter` and the `playwright-performance-regression` and `pw-perf`
|
|
16
|
+
commands.
|
|
17
|
+
- JSON Schemas for the configuration and all file formats, published under `schemas/`.
|
|
18
|
+
- Reading of the sample batch, run report, thresholds and outcome files with `schemaVersion`
|
|
19
|
+
checks, migrations and error codes `SCHEMA_INVALID_JSON`, `SCHEMA_VERSION_MISSING`,
|
|
20
|
+
`SCHEMA_VERSION_TOO_NEW`, `SCHEMA_VERSION_MISMATCH`, `SCHEMA_VALIDATION_FAILED` and
|
|
21
|
+
`THRESHOLDS_KIND_MISMATCH`; a muting `until` date must exist in the calendar.
|
|
22
|
+
- Stable JSON output for every file the package writes: sorted keys, 2-space indent, final
|
|
23
|
+
newline, atomic write.
|
|
24
|
+
- Run report assembly with rounding, fixed array order and raw URLs only with `report.rawUrls`;
|
|
25
|
+
CI metadata for GitHub Actions, GitLab CI, Jenkins and Azure Pipelines.
|
|
26
|
+
- `definePerfConfig()` and `perfDefaults` in the package entry point. `perfDefaults` holds the
|
|
27
|
+
resolved default config (frozen), for extending a default list such as
|
|
28
|
+
`measure.exclude: [...perfDefaults.measure.exclude, 'intercom.io']`.
|
|
29
|
+
- Package config resolution: defaults from the `default` keywords of
|
|
30
|
+
`schemas/config.schema.json`, objects merged and arrays replaced, `RegExp` or
|
|
31
|
+
`{ regex, flags }` URL patterns (compiled without the `g` and `y` flags, so a pattern matches
|
|
32
|
+
the same way on every call), environment overrides of `run.env` and `run.repeat`, and a
|
|
33
|
+
JSON snapshot of the effective config for the run report.
|
|
34
|
+
- Config validation that reports all problems at once, with the option path, the value received,
|
|
35
|
+
the expected format and, for a mistyped option, the closest known name: error codes
|
|
36
|
+
`CONFIG_UNKNOWN_OPTION`, `CONFIG_INVALID_TYPE`, `CONFIG_INVALID_VALUE` and
|
|
37
|
+
`CONFIG_INVALID_REGEX`; warnings `CONFIG_DUPLICATE_ORIGIN_LABEL`,
|
|
38
|
+
`CONFIG_RESOURCE_TYPE_LONG_LIVED` and `CONFIG_PERCENTILE_IS_P99`.
|
|
39
|
+
- Endpoint keys from request URLs: origin labels, id patterns for numbers, UUIDs, hex strings,
|
|
40
|
+
tokens, mixed-case ids and e-mail addresses (`:id`, `:email`), sorted query parameter names
|
|
41
|
+
with optional kept values, deterministic truncation of long keys and a custom `keyBuilder`
|
|
42
|
+
with fallback warnings `NORMALIZE_KEY_BUILDER_INVALID` and `NORMALIZE_KEY_BUILDER_THREW`.
|
|
43
|
+
- Normalization fingerprint of the key rules and warnings `NORMALIZE_HIGH_CARDINALITY` and
|
|
44
|
+
`NORMALIZE_TOO_MANY_KEYS` for key explosion.
|
|
45
|
+
- Statistics per endpoint key and custom measurement: sample, success, error and per-status
|
|
46
|
+
counts (cancelled requests are labeled `ABORTED` and are not errors by default), time sources,
|
|
47
|
+
test counts, samples from failed tests, exact minimum, maximum and average, percentiles p50,
|
|
48
|
+
p90, p95, p99 and the evaluated percentile (linear interpolation, as in spreadsheets and
|
|
49
|
+
NumPy), TTFB, the 3 slowest samples with their start time and the 5 tests with the most
|
|
50
|
+
samples. Above `advanced.maxSamplesPerKey` successful samples a seeded uniform sample is kept;
|
|
51
|
+
the result does not depend on the order of the samples.
|
|
52
|
+
- Only samples of measured projects are aggregated; warnings
|
|
53
|
+
`STATS_SAMPLES_OUTSIDE_MEASURED_PROJECTS`, `STATS_SAMPLES_WITHOUT_BROWSER_TIMING` and
|
|
54
|
+
`STATS_MULTIPLE_BROWSERS`.
|
|
55
|
+
- Apdex and Wilson score interval functions used by the evaluation and thresholds.
|
|
56
|
+
- Evaluation of every endpoint key and custom measurement against the thresholds files: limits
|
|
57
|
+
from the file entry, completed from the config for hand-written entries, or default
|
|
58
|
+
thresholds; rules `median`, `percentile`, `p99`, `apdex` (upper bound of the 95% interval),
|
|
59
|
+
`wilson` and `errors` (lower bound), each with its own minimum sample count; hard limit,
|
|
60
|
+
tolerance in keys or percent, `gate.warnOnly` and `gate.defaultThresholds`; evaluation status
|
|
61
|
+
`passed`, `warned`, `failed` or `error` and per-kind counters. An invalid thresholds file
|
|
62
|
+
stops the evaluation of its kind only and never falls back to default thresholds.
|
|
63
|
+
- Muting of a key in the thresholds file (`gate: "warn"` with `note` and `until`): its
|
|
64
|
+
violations never block until the end date; warnings `THRESHOLDS_MUTED`,
|
|
65
|
+
`THRESHOLDS_MUTE_EXPIRING` (7 days before) and `THRESHOLDS_MUTE_EXPIRED`.
|
|
66
|
+
- Thresholds file warnings `THRESHOLDS_FILE_MISSING` (also naming a file without the
|
|
67
|
+
environment label), `THRESHOLDS_FILE_OUTDATED`, `THRESHOLDS_UNSEEN_ENTRIES`,
|
|
68
|
+
`THRESHOLDS_ENTRIES_NOT_EVALUATED`, `EVAL_PERCENTILE_MISMATCH`, `THRESHOLDS_ENV_MISMATCH`,
|
|
69
|
+
`THRESHOLDS_SOURCE_MISMATCH` (other browser, Playwright minor version, machine or
|
|
70
|
+
normalization) and `EVAL_NO_SAMPLES`.
|
|
71
|
+
- Exit code of a perf-mode run in the outcome file: 3 for tool errors, 2 for blocking
|
|
72
|
+
violations in `test` mode, otherwise 0 (also with warnings and in `thresholds` mode). Failed
|
|
73
|
+
tests are a warning `TESTS_FAILED` up to `gate.maxFailedTestShare` and a tool error
|
|
74
|
+
`TESTS_FAILED_TOO_MANY` above it; a timed-out, interrupted or `maxFailures`-stopped run is
|
|
75
|
+
`RUN_INCOMPLETE`, a sharded run `RUN_SHARDED`.
|
|
76
|
+
- Console summary of a run report: header with mode, environment, tests and CI commit; tool
|
|
77
|
+
errors and up to 10 warnings with hints; counters per kind and muted keys; a table of
|
|
78
|
+
violations (blocking first, by relative exceedance, at most 20 rows, keys shortened in the
|
|
79
|
+
middle to fit the terminal width) with the `over` percentage and `HARD` and `MUTED` flags;
|
|
80
|
+
the slowest sample of the first blocking keys; the result line and the report paths.
|
|
81
|
+
- Derivation of thresholds files from a run report: per key `t`, `median`, the evaluated
|
|
82
|
+
percentile, `p99`, `minApdex`, `maxWilson` and `maxErrorRate` from the margins in
|
|
83
|
+
`checks.*.margin`, `checks.slowShare.t.<kind>` and `thresholds.smallSampleN`, rounded towards
|
|
84
|
+
the looser limit. A derived entry always passes the run it was derived from, and its limits
|
|
85
|
+
keep `median ≤ percentile < p99`. Keys whose median is above `checks.slowShare.t.<kind>.max`
|
|
86
|
+
get no `apdex` and `wilson` limits; keys with fewer successful samples than
|
|
87
|
+
`checks.time.median.minSamples` get no entry.
|
|
88
|
+
- Existing thresholds files are updated, not replaced: `locked` and hand-written partial entries
|
|
89
|
+
stay byte for byte, `note`, `gate` and `until` are kept on every recomputed entry, entries of
|
|
90
|
+
keys not seen in the run stay unless `--prune` is given, and `thresholds.update: "new-only"`
|
|
91
|
+
only adds new keys. An entry whose new limits are within `thresholds.hysteresis` and that
|
|
92
|
+
still passes the source run stays as it is, so a repeated derivation does not rewrite the
|
|
93
|
+
file. A file is written only when its entries, the derivation settings, the environment, the
|
|
94
|
+
evaluated percentile or the run conditions (browsers, machine, normalization, Playwright
|
|
95
|
+
major.minor) changed; its `generated` block describes the source run.
|
|
96
|
+
- Derivation refusals `THRESHOLDS_SOURCE_INCOMPLETE` (interrupted or timed-out run, tool
|
|
97
|
+
errors), `THRESHOLDS_EMPTY_REPORT`, `THRESHOLDS_NOTHING_TO_DERIVE` and an invalid existing
|
|
98
|
+
thresholds file; warnings `THRESHOLDS_KIND_SKIPPED`, `THRESHOLDS_MANUAL_FILE`,
|
|
99
|
+
`THRESHOLDS_SOURCE_TESTS_FAILED`, `THRESHOLDS_SOURCE_TEST_MODE`, `THRESHOLDS_ENV_MISMATCH`,
|
|
100
|
+
`THRESHOLDS_SOURCE_MISMATCH` and `THRESHOLDS_LOOSENED_MUCH` (a time limit grew by more than
|
|
101
|
+
`thresholds.loosenWarnRelative`).
|
|
102
|
+
- Thresholds diff per file: every key as added, removed, loosened, tightened, mixed, unchanged
|
|
103
|
+
(also within hysteresis), locked, unseen or skipped, with the limit values before and after;
|
|
104
|
+
large loosenings are marked `!` and expired mutings are listed on their own line. Console
|
|
105
|
+
output (at most 30 rows per file, keys shortened to the terminal width) and Markdown for
|
|
106
|
+
`thresholds-diff.md` (every change, for a PR description).
|
|
107
|
+
- `withPerf()` and `definePerfConfig()` in `playwright-performance-regression/config`. Outside
|
|
108
|
+
perf mode `withPerf()` returns the Playwright config object as it is and does nothing else. In
|
|
109
|
+
perf mode (`PW_PERF_MODE=test` or `thresholds`, with `PW_PERF_REPEAT`, `PW_PERF_ENV`,
|
|
110
|
+
`PW_PERF_RUN_ID`, `PW_PERF_OUTCOME_FILE` and `PW_PERF_PRUNE`) it resolves the package config
|
|
111
|
+
and returns a copy of the Playwright config with one worker, no retries, `maxFailures` and
|
|
112
|
+
`globalTimeout` 0, trace, video and screenshots off, and `repeatEach` set to the number of
|
|
113
|
+
repetitions for measured projects only (their dependencies and teardowns run once). Measured
|
|
114
|
+
projects follow `run.projects` (`"auto"`: Chromium projects that are not a dependency or
|
|
115
|
+
teardown of another project); other projects are removed from the run. Only the console
|
|
116
|
+
reporters (`list`, `line`, `dot`, `github`), `run.keepReporters` (a kept `html` reporter never
|
|
117
|
+
opens) and the package reporter stay; a console reporter is added when none is left.
|
|
118
|
+
- Errors that stop a perf-mode run before any test: `MODE_INVALID_VALUE` (an invalid `PW_PERF_*`
|
|
119
|
+
value never turns perf mode off silently), `CONFIG_UNKNOWN_PROJECT` and
|
|
120
|
+
`CONFIG_NO_MEASURED_PROJECT`; warnings `CONFIG_MULTIPLE_ENGINES`, `CONFIG_SLOW_MO`,
|
|
121
|
+
`CONFIG_CHANGED_IN_PROCESS` and `NOT_WRAPPED_WITH_PERF`, kept for the reporter.
|
|
122
|
+
- `withPerfFixtures()` and `trackContext()` in `playwright-performance-regression/fixture`, and a
|
|
123
|
+
ready `test` and `expect` in `playwright-performance-regression/test`. Outside perf mode
|
|
124
|
+
`withPerfFixtures()` only adds the `perf` fixture; Playwright's `context` and `page` are not
|
|
125
|
+
overridden. Wrapping a test object again changes nothing.
|
|
126
|
+
- Request measurement in perf mode for the tests of measured projects: every request of the
|
|
127
|
+
`context` fixture, of the `page` fixture's context (also a page built on its own context,
|
|
128
|
+
with the informational diagnostic `COLLECTOR_CONTEXT_AUTO_TRACKED`), of contexts passed to
|
|
129
|
+
`perf.track()` and of worker-scoped contexts registered with `trackContext()`, including
|
|
130
|
+
popups, new tabs, frames and workers. Filters from `measure.*` (scheme, resource type, file
|
|
131
|
+
extension at the end of the path, `include`, `exclude`) and a built-in list of 30 analytics,
|
|
132
|
+
tag manager, monitoring and chat hosts (`measure.excludeKnownThirdParty`). Requests started by
|
|
133
|
+
a service worker are skipped; responses generated by one are flagged `fromServiceWorker`.
|
|
134
|
+
Each redirect step is its own sample.
|
|
135
|
+
- Sample timing from the browser: `duration` from request start to the last byte (including
|
|
136
|
+
queueing, connection setup and a CORS preflight), `requestStart` and `ttfb`, rounded to
|
|
137
|
+
0.1 ms; the worker clock (`timeSource: "node"`) when the browser gives no end time.
|
|
138
|
+
- End of test: requests in flight are awaited once per test, before Playwright closes the
|
|
139
|
+
context, for at most `measure.pendingTimeoutMs` and never past the teardown time limit (the
|
|
140
|
+
test timeout minus 1 s for other teardowns). Requests still running after that become
|
|
141
|
+
`PENDING` samples; a response whose body was never read keeps its HTTP status without a
|
|
142
|
+
duration. Requests of a page or context closed by the test fail at once with the text
|
|
143
|
+
`pw-perf: context closed`, without waiting.
|
|
144
|
+
- Every test of a measured project gets the attachment `playwright-performance-regression-samples`
|
|
145
|
+
(also an empty one); projects that are not measured, such as a login setup project, are not
|
|
146
|
+
measured. At most 20 000 request samples per test (`COLLECTOR_SAMPLE_LIMIT_REACHED`).
|
|
147
|
+
Collector errors never change a test result: they become the diagnostics
|
|
148
|
+
`COLLECTOR_LISTENER_ERROR` and `COLLECTOR_TIMING_FAILED`, or `COLLECTOR_ATTACH_FAILED` on
|
|
149
|
+
stderr.
|
|
150
|
+
- Custom measurements with the `perf` fixture: `perf.measure(name, fn)`, `perf.start(name)` and
|
|
151
|
+
`perf.end(name)` (returns the duration in ms, also outside perf mode), the aliases
|
|
152
|
+
`sampleStart`/`sampleEnd`, outcomes `ok`, `error` and `unfinished`, name validation
|
|
153
|
+
(`TypeError` with `CUSTOM_INVALID_NAME`) and the diagnostics `CUSTOM_ALREADY_STARTED`,
|
|
154
|
+
`CUSTOM_END_WITHOUT_START` and `CUSTOM_UNFINISHED`.
|
|
155
|
+
- The package reporter (`playwright-performance-regression/reporter`), added by `withPerf()` in
|
|
156
|
+
perf mode. It aggregates the sample attachments of the measured projects, evaluates them
|
|
157
|
+
against the thresholds files of the run's environment label
|
|
158
|
+
(`<thresholds.dir>/<thresholds.filePrefix>.<kind>[.<env>].json`, never the file without the
|
|
159
|
+
label), writes
|
|
160
|
+
`<report.dir>/report.json`, prints the summary (colors only in a terminal without
|
|
161
|
+
`NO_COLOR`, tables fitted to the terminal width) and writes the outcome file to
|
|
162
|
+
`PW_PERF_OUTCOME_FILE`. In `thresholds` mode it also writes the changed thresholds files and
|
|
163
|
+
`<report.dir>/thresholds-diff.md` and prints the diff after the summary; nothing is written
|
|
164
|
+
for an incomplete or untrustworthy run, and `PW_PERF_PRUNE=1` removes entries not seen in the
|
|
165
|
+
run. Playwright's status becomes `failed` when the exit code of the run is not 0. At the start
|
|
166
|
+
of the run it prints the settings perf mode changed and the number of test executions. A run
|
|
167
|
+
that starts no test (`--list`, a filter that selects nothing) writes and prints nothing.
|
|
168
|
+
- HTML report `<report.dir>/report.html` next to `report.json` (unless `report.html` is
|
|
169
|
+
`false`): one self-contained file without network requests, readable without JavaScript, with
|
|
170
|
+
the verdict, counters, muted keys, warnings, endpoint and custom measurement tables (violations
|
|
171
|
+
first, details per key with checks, a percentile bar, statuses, slowest samples and top tests),
|
|
172
|
+
thresholds files, run conditions and the config snapshot. JavaScript adds sorting, filters and
|
|
173
|
+
a download of the embedded data (aggregates without raw samples). Light and dark theme, print
|
|
174
|
+
styles and a Content-Security-Policy without inline exceptions. Tool errors
|
|
175
|
+
`HTML_RENDER_FAILED` and `HTML_WRITE_FAILED` keep `report.json` and end with exit code 3.
|
|
176
|
+
- Reporter warnings `RUN_CONDITIONS_CHANGED` (other workers, retries or repetitions than perf
|
|
177
|
+
mode sets, retried results or trace and video attachments set in test files),
|
|
178
|
+
`TESTS_NOT_INSTRUMENTED`, `ATTACHMENT_DUPLICATE`, `COLLECTOR_REQUESTS_PENDING` (with the keys
|
|
179
|
+
that have the most pending requests), `CONFIG_DUPLICATE_ORIGIN_LABEL` for `use.baseURL` of
|
|
180
|
+
measured projects, `NOT_WRAPPED_WITH_PERF` and `THRESHOLDS_DIFF_WRITE_FAILED`; tool errors
|
|
181
|
+
`RUN_SHARDED`, `REPORT_WRITE_FAILED`, `THRESHOLDS_WRITE_FAILED` and
|
|
182
|
+
`REPORTER_INTERNAL_ERROR`; `OUTCOME_WRITE_FAILED` on stderr. A sample attachment that cannot
|
|
183
|
+
be read is skipped with a tool error.
|
|
184
|
+
- The `pw-perf` command (also `playwright-performance-regression`): `pw-perf test` and
|
|
185
|
+
`pw-perf thresholds` run `playwright test` in perf mode. Own options `--env`, `--repeat` and
|
|
186
|
+
(thresholds) `--prune` are read anywhere before `--`; every other argument goes to Playwright
|
|
187
|
+
unchanged, and `--config`/`-c` belongs to Playwright. `--repeat` and `--env` are checked like
|
|
188
|
+
`PW_PERF_REPEAT` and `PW_PERF_ENV`. Playwright is found in the project (from the directory of
|
|
189
|
+
`-c` when given, so a monorepo can run `pw-perf test -c apps/web/playwright.config.ts` from its
|
|
190
|
+
root) and started with Node, without a shell. With `--reporter` the package reporter is added to
|
|
191
|
+
the last `--reporter` value. The CLI sets the `PW_PERF_*` variables, prints the mode line and a
|
|
192
|
+
tip to measure a subset, forwards SIGINT and SIGTERM to Playwright (a second Ctrl+C within 5 s
|
|
193
|
+
stops it at once) and ends with the exit code of the outcome file: 0, 2 or 3, 130 or 143 after a
|
|
194
|
+
signal, Playwright's own code with `--list`. Without an outcome file the result is 3 with
|
|
195
|
+
`CLI_OUTCOME_MISSING` and its usual causes (no `withPerf()`, a config error, no matching test).
|
|
196
|
+
After the run it prints one result line and the report path.
|
|
197
|
+
- CLI errors `CLI_UNKNOWN_COMMAND`, `CLI_INVALID_OPTION`, `CLI_MISSING_ARGUMENT`,
|
|
198
|
+
`CLI_UNSUPPORTED_PLAYWRIGHT_OPTION` (`--ui`, `--ui-host`, `--ui-port`, `--debug`, `--shard`),
|
|
199
|
+
`CLI_PRUNE_WITH_FILTER` (`--prune` with `--grep`, `--grep-invert`, `--project`,
|
|
200
|
+
`--last-failed`, `--only-changed`, `--test-list` or file paths), `CLI_FROM_WITH_PLAYWRIGHT_ARGS`,
|
|
201
|
+
`CLI_PLAYWRIGHT_NOT_FOUND`, `CLI_REPORTER_PATH_UNSUPPORTED`, `CLI_SPAWN_FAILED`,
|
|
202
|
+
`CLI_OUTCOME_INVALID`, `CLI_REPORT_NOT_FOUND`, `CLI_WRITE_FAILED` and `CLI_INTERNAL_ERROR`;
|
|
203
|
+
warnings `CLI_MODE_ALREADY_SET` and `CLI_PLAYWRIGHT_UNSUPPORTED_VERSION`.
|
|
204
|
+
- `pw-perf thresholds --from <report.json>` derives the thresholds files from a run report without
|
|
205
|
+
running tests, with the same functions as a thresholds run (identical files), and writes
|
|
206
|
+
`thresholds-diff.md`. The environment label is `--env` or the label of the report;
|
|
207
|
+
`CLI_REPORT_TESTS_FAILED` warns about a report with failed tests. It needs no Playwright.
|
|
208
|
+
- Package config in the commands without tests: `--config <file>`, else `pw-perf.config.*`
|
|
209
|
+
(`.ts`, `.mts`, `.js`, `.mjs`, `.cjs`, `.json`) in the current directory or in the config
|
|
210
|
+
directory of the report, else the config snapshot of the report. TypeScript files are loaded by
|
|
211
|
+
Node itself; a file that cannot be loaded gives `CONFIG_FILE_LOAD_FAILED` with a fix hint for
|
|
212
|
+
imports without extension, `tsconfig` path aliases and enums (an error with `--config`, a
|
|
213
|
+
warning and the snapshot otherwise), and Node's type-stripping warnings become one `note:` line.
|
|
214
|
+
`CONFIG_FILE_NOT_FOUND` for a missing `--config` file, `CONFIG_SNAPSHOT_DIFFERS` when the file
|
|
215
|
+
differs from the snapshot in options that change the result. The CLI prints the config source
|
|
216
|
+
and the base directory of relative paths (`CLI_CONFIG_DIR_MISSING` when it falls back to the
|
|
217
|
+
current directory).
|
|
218
|
+
- `pw-perf report [--input] [--output] [--config]` renders the HTML report again from a run
|
|
219
|
+
report (`CLI_REPORT_NOT_FOUND` when it is missing), also with `report.html: false`; the page is
|
|
220
|
+
identical to the one written by the run. It needs no Playwright. `HTML_RENDER_FAILED` and
|
|
221
|
+
`CLI_WRITE_FAILED` end it with exit code 3. `--help` (also per command, with the
|
|
222
|
+
note on repeated tests and data conflicts) and `--version`.
|
|
223
|
+
- `pw-perf init [--yes] [--dry-run]`: guided setup in eleven steps, each with a short explanation.
|
|
224
|
+
It reads the project as text (playwright.config is never imported), asks for the label of the
|
|
225
|
+
`baseURL` origin, which tests to measure (all or `@perf`, with `INIT_NO_TAGGED_TESTS` when no
|
|
226
|
+
test has the tag), the repetitions, a warn-only start, environments and a CI job, and shows a
|
|
227
|
+
diff of every change before it asks to apply it: a new `pw-perf.config.ts` with only the values
|
|
228
|
+
that differ from the defaults, `withPerf()` around `export default defineConfig({...})`,
|
|
229
|
+
`export default {...}` or `module.exports = ...`, `withPerfFixtures()` around
|
|
230
|
+
`export const test = base.extend(...)` (or `exports.test = ...`), or imports of `test` from
|
|
231
|
+
`@playwright/test` switched to `playwright-performance-regression/test`, `perf-results/` in
|
|
232
|
+
`.gitignore`, `perf:test` and `perf:thresholds` scripts (with `--grep @perf` and one pair per
|
|
233
|
+
environment with `--env`), and a CI job file from `examples/ci/` for GitHub Actions, GitLab CI,
|
|
234
|
+
Jenkins or Azure Pipelines. Other layouts (config wrappers, several test objects, `mergeTests`)
|
|
235
|
+
and existing scripts or CI files are left as they are, with an `INIT_MANUAL_STEP` instruction.
|
|
236
|
+
A second run changes nothing; an existing `pw-perf.config.ts` is replaced only after its own
|
|
237
|
+
confirmation (never with `--yes`). Without a terminal and without `--yes` it only shows the
|
|
238
|
+
plan. Exit codes: 0 done, 3 `INIT_NO_PLAYWRIGHT_CONFIG`, `INIT_PLAYWRIGHT_TOO_OLD` or
|
|
239
|
+
`INIT_WRITE_FAILED`, 130 interrupted (nothing is written before the changes step).
|
|
240
|
+
- `create-playwright-performance-regression` for `npm init playwright-performance-regression`
|
|
241
|
+
(also `pnpm create` and `yarn create`): installs the package of the same version as a dev
|
|
242
|
+
dependency with the package manager of the project's lockfile, without a shell, then runs
|
|
243
|
+
`pw-perf init` with the given arguments.
|
|
244
|
+
- CI recipes in `examples/ci/` (`github-actions.yml`, `gitlab-ci.yml`, `Jenkinsfile`,
|
|
245
|
+
`azure-pipelines.yml`): pull request and nightly triggers, the report uploaded always, exit
|
|
246
|
+
code 2 as a soft failure on GitLab, Jenkins and Azure Pipelines, and a time limit.
|
|
247
|
+
- User documentation: a README with installation, quick start, CI, limitations, privacy and
|
|
248
|
+
compatibility, and `docs/` with configuration (generated from
|
|
249
|
+
`schemas/config.schema.json`), CLI, adoption in existing projects, thresholds, CI,
|
|
250
|
+
troubleshooting for every warning and error code, FAQ, and upgrading.
|
|
251
|
+
- Example projects `examples/basic` and `examples/with-setup`, runnable against the demo app of
|
|
252
|
+
the repository.
|
|
253
|
+
- Both packages are published from GitHub Actions with npm provenance (trusted publishing), in
|
|
254
|
+
the same version, with pre-releases under the `next` dist-tag; a demo HTML report with a
|
|
255
|
+
blocking violation is published on GitHub Pages.
|
|
256
|
+
|
|
257
|
+
### Changed
|
|
258
|
+
|
|
259
|
+
- `schemas/samples.schema.json`: field descriptions now say that `duration` is `null` also for
|
|
260
|
+
a response that never finished, that `requestStart` and `ttfb` never include a CORS preflight,
|
|
261
|
+
and that `failureText` can be the collector's context-closed text. The structure is unchanged.
|
|
262
|
+
- File validation messages describe the expected format of an environment label or percentile
|
|
263
|
+
name (e.g. `a percentile name like "p95"`) instead of printing the regular expression.
|
|
264
|
+
- Smaller package: the entry points share code chunks instead of each bundling its own copy
|
|
265
|
+
(about 820 kB unpacked instead of 1.3 MB). Every entry point keeps its ESM and CommonJS build.
|
|
266
|
+
- The descriptions in the published `schemas/*.json` use the real names
|
|
267
|
+
(`pw-perf.config.json`, `PW_PERF_ENV`, `PW_PERF_REPEAT`, `PW_PERF_OUTCOME_FILE`, the
|
|
268
|
+
`playwright-performance-regression-samples` attachment) instead of placeholders.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jakub Kaczmarczyk
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,215 @@
|
|
|
1
|
-
#
|
|
1
|
+
# playwright-performance-regression
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Catch backend performance regressions from the Playwright tests you already have.
|
|
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
|
+

|
|
11
|
+
|
|
12
|
+
## How it works
|
|
13
|
+
|
|
14
|
+
1. **Measures** the backend requests your browser makes while your existing e2e tests run, in a
|
|
15
|
+
separate measurement run (`pw-perf test`), with every test repeated a few times.
|
|
16
|
+
2. **Groups** the requests into endpoint keys such as `GET /api/orders/:id`, and computes
|
|
17
|
+
statistics per key: median, p95, p99, error rate and more.
|
|
18
|
+
3. **Derives thresholds** from a run and writes them to JSON files that you review and commit like
|
|
19
|
+
code.
|
|
20
|
+
4. **Fails the run** when an endpoint gets slower or returns more errors than its thresholds
|
|
21
|
+
allow, with a console summary and a self-contained HTML report.
|
|
22
|
+
|
|
23
|
+
Your normal `npx playwright test` runs are not changed.
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
npm init playwright-performance-regression
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
This installs the package as a dev dependency and starts a short guided setup (`pw-perf init`). It
|
|
32
|
+
shows a diff of every change before writing anything: it wraps your Playwright config, wraps your
|
|
33
|
+
`test` object or switches test imports, creates `pw-perf.config.ts`, adds `perf:test` and
|
|
34
|
+
`perf:thresholds` scripts, ignores `perf-results/`, and can add a CI job. `pnpm create` and
|
|
35
|
+
`yarn create` work too; `-- --yes` accepts the defaults without questions.
|
|
36
|
+
|
|
37
|
+
<details>
|
|
38
|
+
<summary>Manual setup</summary>
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
npm install -D playwright-performance-regression
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Wrap the Playwright config:
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
// playwright.config.ts
|
|
48
|
+
import { defineConfig } from '@playwright/test';
|
|
49
|
+
import { withPerf } from 'playwright-performance-regression/config';
|
|
50
|
+
|
|
51
|
+
export default withPerf(defineConfig({/* your config, unchanged */}));
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Then either wrap your own test object:
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
// fixtures.ts
|
|
58
|
+
import { test as base } from '@playwright/test';
|
|
59
|
+
import { withPerfFixtures } from 'playwright-performance-regression/fixture';
|
|
60
|
+
|
|
61
|
+
export const test = withPerfFixtures(base.extend({/* your fixtures */}));
|
|
62
|
+
export { expect } from '@playwright/test';
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
or, if your tests import `test` straight from `@playwright/test`, switch that import:
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
import { test, expect } from 'playwright-performance-regression/test';
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Optionally add `pw-perf.config.ts` and pass it as the second argument of `withPerf()`; see
|
|
72
|
+
[Configuration](docs/configuration.md).
|
|
73
|
+
|
|
74
|
+
</details>
|
|
75
|
+
|
|
76
|
+
Projects with their own fixtures, several test objects, `mergeTests`, playwright-bdd, config
|
|
77
|
+
wrappers or custom reporters: see [Adopting the package in an existing project](docs/adoption.md).
|
|
78
|
+
|
|
79
|
+
## Quick start
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
npm run perf:thresholds # measure and write the thresholds files
|
|
83
|
+
git add perf-thresholds.*.json && git commit -m "test: add performance thresholds"
|
|
84
|
+
npm run perf:test # measure again and compare with the thresholds
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Without the scripts: `npx pw-perf thresholds --grep @perf` and `npx pw-perf test --grep @perf`.
|
|
88
|
+
|
|
89
|
+
Derive thresholds on the same machines that run the check, usually your CI runners, and bring them
|
|
90
|
+
to your repository with `pw-perf thresholds --from <report.json>`. Thresholds measured on a laptop
|
|
91
|
+
do not fit CI. See [Thresholds](docs/thresholds.md).
|
|
92
|
+
|
|
93
|
+
The result is printed in the terminal and written to `perf-results/report.json` and
|
|
94
|
+
`perf-results/report.html`.
|
|
95
|
+
|
|
96
|
+
## Custom measurements
|
|
97
|
+
|
|
98
|
+
Time a user-visible step that spans several requests, or anything else in the test:
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
test('checkout', async ({ page, perf }) => {
|
|
102
|
+
await page.goto('/cart');
|
|
103
|
+
await perf.measure('checkout:load-cart', async () => {
|
|
104
|
+
await page.getByRole('button', { name: 'Checkout' }).click();
|
|
105
|
+
await page.getByText('Order summary').waitFor();
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
`perf.start(name)` and `perf.end(name)` do the same without a callback. Custom measurements get
|
|
111
|
+
their own thresholds file and checks. Coming from `playwright-performance`? `perf.sampleStart()`
|
|
112
|
+
and `perf.sampleEnd()` are aliases of `start()` and `end()`.
|
|
113
|
+
|
|
114
|
+
## CI
|
|
115
|
+
|
|
116
|
+
A GitHub Actions job that measures pull requests and runs every night:
|
|
117
|
+
|
|
118
|
+
```yaml
|
|
119
|
+
name: Performance
|
|
120
|
+
on:
|
|
121
|
+
pull_request:
|
|
122
|
+
schedule:
|
|
123
|
+
- cron: '0 3 * * *'
|
|
124
|
+
jobs:
|
|
125
|
+
perf:
|
|
126
|
+
runs-on: ubuntu-latest
|
|
127
|
+
timeout-minutes: 60
|
|
128
|
+
steps:
|
|
129
|
+
- uses: actions/checkout@v7
|
|
130
|
+
- uses: actions/setup-node@v7
|
|
131
|
+
with:
|
|
132
|
+
node-version: 22
|
|
133
|
+
cache: npm
|
|
134
|
+
- run: npm ci
|
|
135
|
+
- run: npx playwright install --with-deps chromium
|
|
136
|
+
# A tagged subset on pull requests, the full measured suite at night.
|
|
137
|
+
- run: npx pw-perf test ${{ github.event_name == 'pull_request' && '--grep @perf' || '' }}
|
|
138
|
+
- uses: actions/upload-artifact@v7
|
|
139
|
+
if: always() # the report matters most when the run fails
|
|
140
|
+
with:
|
|
141
|
+
name: perf-results
|
|
142
|
+
path: perf-results/
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Exit codes: **0** no blocking regression, **2** performance regression, **3** tool or config error
|
|
146
|
+
(the measurement itself is not trustworthy). Recipes for GitLab CI, Jenkins and Azure Pipelines,
|
|
147
|
+
with code 2 as a soft failure where the platform supports it: [CI](docs/ci.md).
|
|
148
|
+
|
|
149
|
+
## Limitations
|
|
150
|
+
|
|
151
|
+
- REST only: every GraphQL query goes to the same endpoint key.
|
|
152
|
+
- Only requests made by the browser are measured. Tests that use only the `request` fixture, and
|
|
153
|
+
calls through `page.request` or `context.request`, record nothing.
|
|
154
|
+
- Only Chromium projects are measured by default. Firefox and WebKit are best effort.
|
|
155
|
+
- The measurement run is separate from your normal run, uses one worker and repeats every test,
|
|
156
|
+
so it is slow: measure a subset (`--grep @perf`, `--project`).
|
|
157
|
+
- Repeated tests that create data can collide with each other; make the data unique.
|
|
158
|
+
- In manual mode (`PW_PERF_MODE=test npx playwright test`), a `--reporter` flag replaces the
|
|
159
|
+
package reporter and nothing is reported. Use `pw-perf test`.
|
|
160
|
+
|
|
161
|
+
## Privacy
|
|
162
|
+
|
|
163
|
+
No telemetry. The package never makes network requests.
|
|
164
|
+
|
|
165
|
+
What ends up where:
|
|
166
|
+
|
|
167
|
+
- **Thresholds files and `report.json` / `report.html`** contain normalized endpoint keys: numbers,
|
|
168
|
+
UUIDs, long hex strings, tokens, mixed-case ids and e-mail addresses in the path are replaced
|
|
169
|
+
with `:id` or `:email`, and query values are dropped (only parameter names stay). Path segments
|
|
170
|
+
that match none of these patterns, such as user names, stay in the key; add patterns with
|
|
171
|
+
`keys.extraIdPatterns`. The report also contains test titles, file names, the operating system, CPU model
|
|
172
|
+
and CI metadata (commit, branch, build URL).
|
|
173
|
+
- **Raw URLs** go into the report only when you set `report.rawUrls: true`.
|
|
174
|
+
- **Playwright's own report** gets one attachment per test with the full URLs of the measured
|
|
175
|
+
requests.
|
|
176
|
+
|
|
177
|
+
**Before you share a report** outside your team, check the keys for personal data and remember
|
|
178
|
+
that Playwright's HTML report and traces contain the full URLs.
|
|
179
|
+
|
|
180
|
+
## Compatibility
|
|
181
|
+
|
|
182
|
+
| | Supported |
|
|
183
|
+
| ----------------- | ----------------------------------------------------------------------------- |
|
|
184
|
+
| Node.js | 22.18 or newer (22, 24, 26) |
|
|
185
|
+
| Playwright Test | 1.57 or newer (`@playwright/test` is a peer dependency) |
|
|
186
|
+
| Operating systems | Linux, macOS, Windows |
|
|
187
|
+
| Browsers | Chromium (including Chrome and Edge channels); Firefox and WebKit best effort |
|
|
188
|
+
| Module formats | ESM and CommonJS configs; TypeScript configs loaded by Playwright |
|
|
189
|
+
|
|
190
|
+
## Documentation
|
|
191
|
+
|
|
192
|
+
- [Configuration](docs/configuration.md): every option with its default
|
|
193
|
+
- [CLI](docs/cli.md): commands, options and exit codes
|
|
194
|
+
- [Adoption](docs/adoption.md): existing projects, choosing tests, sample counts
|
|
195
|
+
- [Thresholds](docs/thresholds.md): deriving, reviewing, locking and muting
|
|
196
|
+
- [CI](docs/ci.md): recipes for GitHub Actions, GitLab CI, Jenkins and Azure Pipelines
|
|
197
|
+
- [Troubleshooting](docs/troubleshooting.md): every warning and error code
|
|
198
|
+
- [FAQ](docs/faq.md) · [Upgrading and uninstalling](docs/upgrading.md)
|
|
199
|
+
- [Examples](examples): a basic project and one with setup projects and own fixtures
|
|
200
|
+
|
|
201
|
+
## Security
|
|
202
|
+
|
|
203
|
+
Please report vulnerabilities privately through
|
|
204
|
+
[GitHub private vulnerability reporting](https://github.com/Meser6/playwright-performance-regression/security/advisories/new),
|
|
205
|
+
not in public issues.
|
|
206
|
+
|
|
207
|
+
## Contributing
|
|
208
|
+
|
|
209
|
+
Issues and pull requests are welcome. The project uses pnpm, Conventional Commits and squash
|
|
210
|
+
merges; `pnpm lint`, `pnpm typecheck` and `pnpm test` (after `pnpm build`) must pass. Releases
|
|
211
|
+
follow [RELEASING.md](RELEASING.md).
|
|
212
|
+
|
|
213
|
+
## License
|
|
214
|
+
|
|
215
|
+
[MIT](LICENSE)
|