playwright-performance-regression 0.1.0-next.4 → 1.0.1

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,156 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.0.1] - 2026-11-25
11
+
12
+ A hotfix release.
13
+
14
+ ### Fixed
15
+
16
+ - **Later passes repeat your script when it calls `npx playwright test`.** A script such as
17
+ `"e2e:qa": "npm run prep && npx playwright test --grep …"` ran later passes as the bare
18
+ `npx playwright test …` command, because `npx` hides the name of the outer script. The reporter
19
+ now finds the `npm run e2e:qa` process above Playwright and runs `npm run e2e:qa` again, so the
20
+ steps before Playwright run in every pass too. On Windows the behaviour is unchanged.
21
+
22
+ ## [1.0.0] - 2026-11-23
23
+
24
+ The first stable release, published under the `latest` dist-tag: install with
25
+ `npm init playwright-performance-regression`. From now on the project follows semantic versioning
26
+ strictly (breaking changes only in a new major version). Upgrading from `0.1.0-next.4`: see
27
+ [Upgrading](docs/upgrading.md#from-010-nextx-to-100); in short, prune the thresholds entries of
28
+ the newly skipped realtime transports and keep or copy your CI jobs yourself.
29
+
30
+ ### Breaking
31
+
32
+ - **More realtime transports skipped by default.** The default `measure.exclude` is now
33
+ `['/socket.io/', '/sockjs/', '/sockjs-node/', '/signalr/', '/_blazor/']`: besides socket.io it
34
+ skips the HTTP requests of SockJS (also Meteor and the webpack-dev-server 3 reload client),
35
+ classic ASP.NET SignalR and Blazor Server. These are handshakes, long polling and streams, not
36
+ backend endpoints, and gave long or `PENDING` samples. Keys under these paths no longer appear
37
+ in the report; their entries in a thresholds file stay and are reported as not seen
38
+ (`THRESHOLDS_UNSEEN_ENTRIES`). Other keys and the normalization fingerprint do not change, so
39
+ thresholds files stay valid. Migration: run a thresholds run of the full suite with
40
+ `PW_PERF_PRUNE=1` to remove the old entries. A config file that sets `measure.exclude` (an
41
+ earlier guided setup wrote it) keeps its own list: add the new patterns there or use
42
+ `[...perfDefaults.measure.exclude, ...]`. The guided setup now writes the longer default list.
43
+ - **The guided setup adds no CI jobs.** The CI step is gone (steps are now `[n/9]`) and the wizard
44
+ no longer writes `.github/workflows/perf.yml`, `.gitlab/perf.gitlab-ci.yml`, `Jenkinsfile.perf`
45
+ or `azure-pipelines.perf.yml`; it still adds no scripts. Your test command is only used in the
46
+ commands printed at the end and for the check, and the step says so. Migration: CI files written
47
+ by an earlier wizard are left as they are and keep working; copy the recipes from
48
+ `examples/ci/` and [CI](docs/ci.md) for new projects or to pick up the changes below (thresholds
49
+ artifact of `reports/pw-perf/` only, `junit.xml`).
50
+
51
+ ### Added
52
+
53
+ - **Warning and table for keys on default thresholds.** When a thresholds file has entries but
54
+ some endpoints or steps of a measurement run (`PW_PERF_MODE=test`) have none, the run warns
55
+ with the new `THRESHOLDS_KEYS_ON_DEFAULTS` (one per kind, with the number of keys and up to
56
+ three of them) and the console prints a table of those keys under the counters: samples,
57
+ median, the evaluated percentile, the default limits applied and the result, keys with a
58
+ violation first, at most 10 rows and a "… and N more" line. The warning also appears in
59
+ `report.json`, the HTML report and `junit.xml`; its hint suggests a thresholds run to add the
60
+ entries. Not in thresholds mode, and not for a missing or empty file (`THRESHOLDS_FILE_MISSING`
61
+ and `THRESHOLDS_FILE_EMPTY` cover those). It does not change the evaluation or the exit code.
62
+ - **Thresholds files in the report folder.** A thresholds run (`PW_PERF_MODE=thresholds`) writes
63
+ the thresholds files as before and also copies them, byte for byte and under the same names
64
+ (with the environment label), into `report.dir` (`reports/pw-perf/pw-perf-thresholds.json`,
65
+ `reports/pw-perf/pw-perf-thresholds.steps.json`): every file of the measured kinds, also when
66
+ this run left it unchanged, so one CI artifact of `reports/pw-perf/` holds everything to commit
67
+ next to `thresholds-diff.md`. No copies when writing a thresholds file failed or in the check of
68
+ the guided setup. A failed copy is the warning `THRESHOLDS_COPY_FAILED` and does not change the
69
+ exit code. The copies directly in `report.dir` no longer stop it from being emptied at the start
70
+ of the next run. The CI recipes in `examples/ci/` now upload only `reports/pw-perf/` in the
71
+ thresholds job (Azure: the `pw-perf-report` artifact in both modes).
72
+ - **JUnit XML report.** A measurement run (`PW_PERF_MODE=test`) writes `reports/pw-perf/junit.xml`
73
+ next to `report.json`, so GitLab, Jenkins and Azure DevOps show the result in their test views:
74
+ one test case per endpoint and step key, a failure only for a blocking violation (exit code 2),
75
+ muted and not evaluated keys as skipped, tool errors as an error of the `measurement run` test
76
+ case. Not written in thresholds mode or by a check. Turn it off with `report.junit: false`; a
77
+ failed write is the tool error `REPORT_JUNIT_WRITE_FAILED` (exit code 3).
78
+ - **JUnit in the CI recipes.** The recipes in `examples/ci/` publish `junit.xml` without changing
79
+ the job status: GitLab `artifacts: reports: junit`, Jenkins `junit` (empty results allowed,
80
+ build not marked unstable by it), Azure `PublishTestResults@2` in mode `test` only, and an
81
+ optional, commented-out test report step for GitHub Actions. `docs/ci.md` explains where the
82
+ result shows up and how to read it.
83
+
84
+ ### Changed
85
+
86
+ - **Tables in the thresholds diff and the start box.** The changes of a thresholds run are
87
+ listed in a table with lines (marker, key, change), like the tables of the run summary, and the
88
+ skipped keys in a second table with their reason; the start box of a perf-mode run is a table
89
+ with the mode in its top edge, labels on the left and values on the right (long values are
90
+ shortened in the middle). `NO_COLOR` only drops the colors; `TERM=dumb` draws the tables with
91
+ `+`, `-` and `|`.
92
+ - **Clearer labels in the HTML report.** The checks table of a key shows Raw (the value measured
93
+ in the run) and Bound (the 95% confidence bound that Apdex, slow share and error rate compare
94
+ with the limit) instead of Actual and Observed, with a one-line legend; `report.json` keeps the
95
+ field names `actual` and `observed`. The column Headroom is now Limit used (it shows how much of
96
+ the limit is used). A line under the checks table gives T of Apdex and slow share and says when
97
+ T is the lowest the thresholds allow, so a key can pass them while its percentiles fail. The
98
+ Steps tile says how many steps are over their limit ("1 over limit · 0 near limit"). The Tests
99
+ result and the tile without steps count test runs ("passed 50 test runs"), not tests. Hints of
100
+ steps say "samples" instead of "responses". The key header in the details dialog shows the
101
+ origin label as a token before the path (`api` and `/api/prices`, not `GET api/api/prices`),
102
+ with the origin address in its tooltip. The note that the medians of the TTFB split can differ
103
+ from p50 only appears when they differ.
104
+ - **Rounded multiples and percentages.** The hard-limit hint shows the multiple of the limit with
105
+ two decimals, rounded ("2.67×", was "2.6×"), and never one that is not above the hard limit
106
+ factor ("2.05×", was "2.0× … above the hard limit of 2×"). The excess of a failed check in the
107
+ HTML report is the text of the console and `junit.xml` (rounded: "+105%", was "+106%" from
108
+ rounding up), and every output shows at least "+1%" (the console could show "+0%"). The share of
109
+ the limit used by a passing check is rounded ("56% of limit", was "55%"), but never shown as 90%
110
+ or more below 0.9, where the near-limit hint and colour start.
111
+ - **Wording of the guided setup in es, fr, it, pl, uk and ru.** A review of every translated
112
+ text: the question about passes now asks how many passes per measurement (es, fr, it); one word
113
+ for a pass in Italian ("passata", no longer "passaggio", which also means a step) and for a
114
+ measurement ("misurazione"); the wizard is the "procedura guidata" in Italian; the summary is
115
+ "Récapitulatif" in French and "Сводка" in Russian; Ukrainian and Russian no longer say that a
116
+ run "falls" on a regression but that it ends with an error, call step titles "names" and write
117
+ "endpoint" in Cyrillic everywhere; plainer words for the cleaning of step titles (es, pl).
118
+ Meaning and placeholders are unchanged.
119
+ - **The guided setup ends with an IMPORTANT box.** After it writes the setup, the wizard ends
120
+ with a framed box (in the chosen language, at most 80 columns, ASCII with `TERM=dumb`) of the
121
+ next steps with your exact commands: derive the thresholds on CI, on the environment where the
122
+ tests will run (`PW_PERF_MODE=thresholds <your command>`; it can take several hours), download
123
+ the thresholds files from the CI artifacts (the report folder `reports/pw-perf`), commit them,
124
+ and from then on run `PW_PERF_MODE=test <your command>`. It replaces the `Run:` line and the
125
+ "Next steps" list; when the check did not run, one line suggests `PW_PERF_MODE=check` first.
126
+ Without a terminal or with `PW_PERF_DRY_RUN=1` the summary is as before.
127
+ - **The guided setup creates empty thresholds files.** It always adds `pw-perf-thresholds.json`
128
+ and `pw-perf-thresholds.steps.json` next to the Playwright config, without entries and whatever
129
+ you chose to measure, each with its own diff and confirmation; an existing thresholds file is
130
+ never changed. A measurement run with an empty file warns with the new `THRESHOLDS_FILE_EMPTY`
131
+ and suggests a thresholds run (as for a missing file), a check shows `0 entries` and the same
132
+ next step, and the thresholds run fills the files without `THRESHOLDS_MANUAL_FILE`.
133
+ - **The config file of the guided setup lists every option as code.** `pw-perf.config.ts` (or
134
+ `.js`) now sets all 15 listed options: your answers and the default value of every other
135
+ option, so you edit a value instead of uncommenting lines and objects. Each section has a
136
+ short comment above it, and the `report.dir` comment says the folder (with `junit.xml`) is not
137
+ committed. Config files written by an earlier wizard keep working unchanged.
138
+
139
+ ### Fixed
140
+
141
+ - **Violation cards show the rule that failed the run.** A card in the Overview of the HTML report
142
+ showed the failed check with the highest share of its limit, e.g. slow share "+5 pp", while its
143
+ hint explained a p95 above the hard limit. It now shows the deciding check: a blocking check
144
+ above the hard limit first, then other blocking checks. The Limit used column of the key tables
145
+ shows the same check for a failed key.
146
+ - **Step thresholds file no longer "differs".** Run & config compared the normalization
147
+ fingerprint of the step thresholds file with the fingerprint of URL keys, so it always showed
148
+ "differs: keys may not match". It now compares it with the step fingerprint of the run; a real
149
+ difference also links to the `THRESHOLDS_SOURCE_MISMATCH` warning.
150
+ - **No limit for rules that were not evaluated.** A key with too few samples for p95 or p99 showed
151
+ their limits (in red when above), although those rules decided nothing. The key table now shows
152
+ "/ —" with a footnote, and the details say "p95 · not evaluated".
153
+ - **Start box closes on every line.** The title line of the start box used ⏱️ (a character with
154
+ the emoji variation selector U+FE0F), whose width terminals count differently, so its right
155
+ edge stood one column off in VS Code and Terminal.app. The title now uses ⏳, which every modern
156
+ terminal shows in two columns, and no frame or table uses U+FE0F sequences. Text widths of
157
+ frames and tables now follow the wcwidth conventions (variation selectors, joiners and combining
158
+ marks take no column; an emoji sequence is never cut apart).
159
+
10
160
  ## [0.1.0-next.4] - 2026-11-23
11
161
 
12
162
  Upgrading from `0.1.0-next.3`: see [Upgrading](docs/upgrading.md). In short, run your test
package/README.md CHANGED
@@ -2,11 +2,6 @@
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
@@ -27,23 +22,25 @@ Your normal `npx playwright test` runs are not changed.
27
22
  ## Install
28
23
 
29
24
  ```sh
30
- npm init playwright-performance-regression@next
25
+ npm init playwright-performance-regression
31
26
  ```
32
27
 
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
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
36
30
  to measure (endpoints, `test.step` blocks or both), the threshold headroom and your usual test
37
31
  command, then shows a diff of every change before writing it: it creates `pw-perf.config.ts`
38
32
  (`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.
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.
40
36
  Without a fixtures module, it switches the `@playwright/test` imports of your test files to
41
37
  `playwright-performance-regression/test`, one confirmed diff per file; when it cannot change the
42
38
  test object, it shows the code to paste. `package.json` is never changed. At the end it offers a
43
39
  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
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
47
44
  Russian (it asks at the start). It takes no arguments; `PW_PERF_LANG`, `PW_PERF_DRY_RUN` and
48
45
  `PW_PERF_NO_TUTORIAL` change it ([Guided setup](docs/cli.md#guided-setup)).
49
46
 
@@ -108,7 +105,8 @@ On Windows: `npx cross-env PW_PERF_MODE=test npm run e2e` (PowerShell and cmd fo
108
105
  The exit code is Playwright's own; the cause of a failure (a regression, failed tests, a config
109
106
  error) is in `reports/pw-perf/outcome.json`. The result is also printed in the terminal and written
110
107
  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,
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,
112
110
  so it holds only the last run. All variables are described in [Running](docs/cli.md).
113
111
 
114
112
  Derive thresholds on the same machines that run the check, usually your CI runners (see
@@ -130,8 +128,9 @@ words become `:num` (`Transfer 1500 PLN` → `Transfer :num PLN`). See [Step tim
130
128
  ## CI
131
129
 
132
130
  The recommended path: (1) a CI job you start by hand runs with `PW_PERF_MODE=thresholds` and keeps
133
- the thresholds files as an artifact, (2) you commit them, (3) a weekly job runs with
134
- `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:
135
134
 
136
135
  ```yaml
137
136
  name: Performance
@@ -152,7 +151,7 @@ jobs:
152
151
  - run: npm run e2e
153
152
  - uses: actions/upload-artifact@v7
154
153
  if: always()
155
- with: { name: pw-perf-thresholds, path: pw-perf-thresholds*.json }
154
+ with: { name: pw-perf-thresholds, path: reports/pw-perf/ }
156
155
  measure:
157
156
  if: github.event_name == 'schedule' || inputs.mode == 'test'
158
157
  runs-on: ubuntu-latest
@@ -301,7 +301,7 @@ var DEFAULT_CONFIG = {
301
301
  ".eot"
302
302
  ],
303
303
  include: [],
304
- exclude: ["/socket.io/"],
304
+ exclude: ["/socket.io/", "/sockjs/", "/sockjs-node/", "/signalr/", "/_blazor/"],
305
305
  excludeKnownThirdParty: true,
306
306
  successStatuses: ["2xx", "3xx"],
307
307
  steps: true,
@@ -381,7 +381,7 @@ var DEFAULT_CONFIG = {
381
381
  hysteresis: { relative: 0.1, ratio: 0.01 },
382
382
  loosenWarnRelative: 0.5
383
383
  },
384
- report: { dir: "reports/pw-perf", html: true, rawUrls: false },
384
+ report: { dir: "reports/pw-perf", html: true, junit: true, rawUrls: false },
385
385
  advanced: { maxSamplesPerKey: 5e3, seed: 1 }
386
386
  };
387
387
 
@@ -748,7 +748,7 @@ var packageConfig = obj({
748
748
  hysteresis: obj({ relative: unit, ratio: num({ minimum: 0, maximum: 0.01 }) }),
749
749
  loosenWarnRelative: num({ minimum: 0, maximum: 100 })
750
750
  }),
751
- report: obj({ dir: str({ minLength: 1 }), html: bool, rawUrls: bool }),
751
+ report: obj({ dir: str({ minLength: 1 }), html: bool, junit: bool, rawUrls: bool }),
752
752
  advanced: obj({
753
753
  maxSamplesPerKey: int({ minimum: 100, maximum: 1e5 }),
754
754
  seed: int({ minimum: 0, maximum: 4294967295 })
@@ -1,11 +1,11 @@
1
- import { KINDS } from './chunk-RL27E3AB.js';
2
- import { str, nullable, constant, obj, bool, msOrNull, epochMs, enumOf, oneOf, int, arr, issue, isoDate, ratio, msLimit, fingerprint, hostFingerprint, derivationSettings, percentileName, count, timestamp, runId, envLabelOrNull, tool, kind, record, key, nul, anyObject, ms, num, packageConfig, mode, evaluationStatus, testsStatus, isRecord, Sink, child, expandSteps, DEFAULT_CONFIG } from './chunk-CISGJCFW.js';
1
+ import { KINDS } from './chunk-ORWOFAZ5.js';
2
+ import { str, nullable, constant, obj, bool, msOrNull, epochMs, enumOf, oneOf, int, arr, issue, isoDate, ratio, msLimit, fingerprint, hostFingerprint, derivationSettings, percentileName, count, timestamp, runId, envLabelOrNull, tool, kind, record, key, nul, anyObject, ms, num, packageConfig, mode, evaluationStatus, testsStatus, isRecord, Sink, child, expandSteps, DEFAULT_CONFIG } from './chunk-5Y34Q4DR.js';
3
3
  import { rmSync, readFileSync, readdirSync, lstatSync, realpathSync, existsSync } from 'fs';
4
4
  import { readFile, mkdir, writeFile, rename, rm, access } from 'fs/promises';
5
5
  import { tmpdir, homedir, cpus, availableParallelism } from 'os';
6
6
  import { join, resolve, dirname, relative, isAbsolute, basename, sep } from 'path';
7
7
  import { randomUUID } from 'crypto';
8
- import { spawn } from 'child_process';
8
+ import { spawn, spawnSync } from 'child_process';
9
9
 
10
10
  function tempPath(name) {
11
11
  return join(tmpdir(), name);
@@ -184,6 +184,51 @@ function stringifyStable(value) {
184
184
  `;
185
185
  }
186
186
 
187
+ // src/core/format/violation.ts
188
+ var TIME_RULES = /* @__PURE__ */ new Set([
189
+ "median",
190
+ "percentile",
191
+ "p99"
192
+ ]);
193
+ var SHARE_RULES = /* @__PURE__ */ new Set([
194
+ "apdex",
195
+ "wilson",
196
+ "errors"
197
+ ]);
198
+ function exceedance(check2) {
199
+ if (check2.rule === "apdex") return check2.actual === 0 ? Infinity : check2.limit / check2.actual;
200
+ return check2.limit === 0 ? Infinity : check2.actual / check2.limit;
201
+ }
202
+ function overText(check2) {
203
+ if (SHARE_RULES.has(check2.rule)) {
204
+ const points = Math.max(1, Math.round(Math.abs(check2.actual - check2.limit) * 100));
205
+ return `+${String(points)} pp`;
206
+ }
207
+ const r = exceedance(check2);
208
+ if (!Number.isFinite(r)) return ">999%";
209
+ const over = Math.max(1, Math.round((r - 1) * 100));
210
+ return over > 999 ? ">999%" : `+${String(over)}%`;
211
+ }
212
+ function formatFactor(ratio2, threshold = null) {
213
+ const scaled = Math.round(ratio2 * 1e6) / 1e4;
214
+ let hundredths = Math.round(scaled);
215
+ if (threshold !== null && hundredths / 100 <= threshold && ratio2 > threshold) {
216
+ hundredths = Math.ceil(scaled);
217
+ }
218
+ return (hundredths / 100).toFixed(2);
219
+ }
220
+ function formatMs(ms2) {
221
+ return `${Math.round(ms2)} ms`;
222
+ }
223
+ function formatActual(check2) {
224
+ if (TIME_RULES.has(check2.rule)) return formatMs(check2.actual);
225
+ const observed = check2.observed === null ? "" : ` (${check2.observed.toFixed(3)})`;
226
+ return `${check2.actual.toFixed(3)}${observed}`;
227
+ }
228
+ function formatLimit(check2) {
229
+ return TIME_RULES.has(check2.rule) ? formatMs(check2.limit) : check2.limit.toFixed(3);
230
+ }
231
+
187
232
  // src/io/json.ts
188
233
  async function writeTextAtomic(path, text) {
189
234
  const dir = dirname(path);
@@ -239,6 +284,21 @@ function runPass(command, env, cwd) {
239
284
  }
240
285
  });
241
286
  }
287
+ function readProcessTable() {
288
+ if (process.platform === "win32") return null;
289
+ try {
290
+ const out = spawnSync("ps", ["-A", "-o", "pid=,ppid=,args="], {
291
+ encoding: "utf8",
292
+ timeout: 2e3,
293
+ shell: false,
294
+ windowsHide: true,
295
+ maxBuffer: 16 * 1024 * 1024
296
+ });
297
+ return out.status === 0 && typeof out.stdout === "string" ? out.stdout : null;
298
+ } catch {
299
+ return null;
300
+ }
301
+ }
242
302
  function readPackageInfo(dir) {
243
303
  for (let current = dir; ; current = dirname(current)) {
244
304
  const file = join(current, "package.json");
@@ -1308,9 +1368,10 @@ function migrateRunReportV3(document) {
1308
1368
  if (!isRecord(config) || !isRecord(config.run)) return document;
1309
1369
  const { projects: _projects, ...run } = config.run;
1310
1370
  const measure = isRecord(config.measure) ? { api: true, ...config.measure } : config.measure;
1371
+ const report = isRecord(config.report) ? { ...config.report, junit: false } : config.report;
1311
1372
  return {
1312
1373
  ...document,
1313
- config: { ...config, run: { ...run, overrideSlowMo: false }, measure }
1374
+ config: { ...config, run: { ...run, overrideSlowMo: false }, measure, report }
1314
1375
  };
1315
1376
  }
1316
1377
  var RUN_REPORT_FORMAT = {
@@ -1465,37 +1526,101 @@ function plural(n, word, many = `${word}s`) {
1465
1526
  return `${n} ${n === 1 ? word : many}`;
1466
1527
  }
1467
1528
  function truncateMiddle(text, width) {
1468
- const chars = Array.from(text);
1469
- if (chars.length <= width) return text;
1529
+ if (textWidth(text) <= width) return text;
1470
1530
  if (width <= 1) return "…".slice(0, width);
1471
- const head = Math.ceil((width - 1) / 2);
1472
- const tail = width - 1 - head;
1473
- return `${chars.slice(0, head).join("")}…${tail === 0 ? "" : chars.slice(-tail).join("")}`;
1531
+ const chars = clusters(text);
1532
+ const headRoom = Math.ceil((width - 1) / 2);
1533
+ const tailRoom = width - 1 - headRoom;
1534
+ let head = "";
1535
+ let used = 0;
1536
+ for (const c of chars) {
1537
+ if (used + c.width > headRoom) break;
1538
+ head += c.text;
1539
+ used += c.width;
1540
+ }
1541
+ let tail = "";
1542
+ used = 0;
1543
+ for (let i = chars.length - 1; i >= 0; i -= 1) {
1544
+ const c = chars[i];
1545
+ if (c === void 0 || used + c.width > tailRoom) break;
1546
+ tail = c.text + tail;
1547
+ used += c.width;
1548
+ }
1549
+ return `${head}…${tail}`;
1474
1550
  }
1475
1551
  var WIDE = [
1476
1552
  [8986, 8987],
1477
1553
  [9193, 9196],
1478
1554
  [9200, 9200],
1479
1555
  [9203, 9203],
1556
+ [9725, 9726],
1557
+ [9748, 9749],
1558
+ [9800, 9811],
1559
+ [9855, 9855],
1560
+ [9875, 9875],
1480
1561
  [9889, 9889],
1562
+ [9898, 9899],
1563
+ [9917, 9918],
1564
+ [9924, 9925],
1565
+ [9934, 9934],
1481
1566
  [9940, 9940],
1567
+ [9962, 9962],
1568
+ [9970, 9971],
1569
+ [9973, 9973],
1570
+ [9978, 9978],
1571
+ [9981, 9981],
1482
1572
  [9989, 9989],
1573
+ [9994, 9995],
1574
+ [10024, 10024],
1483
1575
  [10060, 10060],
1484
1576
  [10062, 10062],
1485
1577
  [10067, 10069],
1486
1578
  [10071, 10071],
1579
+ [10133, 10135],
1580
+ [10160, 10160],
1581
+ [10175, 10175],
1582
+ [11035, 11036],
1487
1583
  [11088, 11088],
1488
1584
  [11093, 11093],
1489
1585
  [127744, 129791]
1490
1586
  ];
1587
+ var ZERO = [
1588
+ [768, 879],
1589
+ [8203, 8205],
1590
+ [8400, 8447],
1591
+ [65024, 65039],
1592
+ [127995, 127999],
1593
+ [917760, 917999]
1594
+ ];
1595
+ var VS16 = 65039;
1596
+ var ZWJ = 8205;
1597
+ function inRanges(cp, ranges) {
1598
+ return ranges.some(([from, to]) => cp >= from && cp <= to);
1599
+ }
1491
1600
  function charWidth(char) {
1492
1601
  const cp = char.codePointAt(0) ?? 0;
1493
- return WIDE.some(([from, to]) => cp >= from && cp <= to) ? 2 : 1;
1602
+ if (inRanges(cp, ZERO)) return 0;
1603
+ return inRanges(cp, WIDE) ? 2 : 1;
1604
+ }
1605
+ function clusters(text) {
1606
+ const out = [];
1607
+ let joined = false;
1608
+ for (const char of text) {
1609
+ const cp = char.codePointAt(0) ?? 0;
1610
+ const last = out[out.length - 1];
1611
+ if (last !== void 0 && (joined || charWidth(char) === 0)) {
1612
+ last.text += char;
1613
+ if (cp === VS16) last.width = 2;
1614
+ joined = cp === ZWJ;
1615
+ continue;
1616
+ }
1617
+ out.push({ text: char, width: charWidth(char) });
1618
+ joined = false;
1619
+ }
1620
+ return out;
1494
1621
  }
1495
1622
  function textWidth(text) {
1496
- let width = 0;
1497
- for (const char of text) width += charWidth(char);
1498
- return width;
1623
+ return clusters(text).reduce((sum2, c) => sum2 + c.width, 0);
1499
1624
  }
1500
1625
  function padEnd(text, width) {
1501
1626
  return text + " ".repeat(Math.max(0, width - textWidth(text)));
@@ -1515,9 +1640,8 @@ function cellsOf(line) {
1515
1640
  const spans = line.spans ?? [{ text: line.text ?? "", style: line.style }];
1516
1641
  const cells = [];
1517
1642
  for (const span of spans) {
1518
- for (const char of span.text) {
1519
- cells.push({ char, style: span.style, width: charWidth(char) });
1520
- }
1643
+ for (const c of clusters(span.text))
1644
+ cells.push({ char: c.text, style: span.style, width: c.width });
1521
1645
  }
1522
1646
  return cells;
1523
1647
  }
@@ -1610,10 +1734,22 @@ function box(lines, opts) {
1610
1734
  return `${boxLines(lines, opts).join("\n")}
1611
1735
  `;
1612
1736
  }
1737
+ function cutText(text, width) {
1738
+ if (textWidth(text) <= width) return text;
1739
+ let out = "";
1740
+ let used = 0;
1741
+ for (const c of clusters(text)) {
1742
+ if (used + c.width > width - 1) break;
1743
+ out += c.text;
1744
+ used += c.width;
1745
+ }
1746
+ return `${out}…`;
1747
+ }
1613
1748
  function table(columns, rows, opts) {
1614
1749
  const g = opts.ascii ? { v: "|", h: "-", top: ["+", "+", "+"], mid: ["+", "+", "+"], bottom: ["+", "+", "+"] } : { v: "│", h: "─", top: ["┌", "┬", "┐"], mid: ["├", "┼", "┤"], bottom: ["└", "┴", "┘"] };
1750
+ const header = opts.header !== false;
1615
1751
  const natural = columns.map(
1616
- (c, i) => Math.max(textWidth(c.header), ...rows.map((r) => textWidth(r.cells[i] ?? "")))
1752
+ (c, i) => Math.max(header ? textWidth(c.header) : 0, ...rows.map((r) => textWidth(r.cells[i] ?? "")))
1617
1753
  );
1618
1754
  const overhead = 3 * columns.length + 1;
1619
1755
  const widths = columns.map((c, i) => {
@@ -1621,28 +1757,47 @@ function table(columns, rows, opts) {
1621
1757
  const others = natural.reduce((sum2, w, j) => j === i ? sum2 : sum2 + w, 0);
1622
1758
  return Math.max(c.minWidth ?? 1, Math.min(natural[i] ?? 0, opts.width - overhead - others));
1623
1759
  });
1624
- const dim = (text) => paint(text, "dim", opts.color);
1625
- const rule = ([left, cross, right]) => dim(`${left}${widths.map((w) => g.h.repeat(w + 2)).join(cross)}${right}`);
1626
- const line = (cells, style) => {
1760
+ let title = opts.title ?? "";
1761
+ if (title !== "") {
1762
+ const inner = () => widths.reduce((sum2, w) => sum2 + w + 3, -1);
1763
+ const room = Math.max(1, opts.width - 2 - 4);
1764
+ title = cutText(title, room);
1765
+ const need = textWidth(title) + 4 - inner();
1766
+ const last = widths.length - 1;
1767
+ if (need > 0 && last >= 0) widths[last] = (widths[last] ?? 0) + need;
1768
+ }
1769
+ const border = opts.border ?? "dim";
1770
+ const edge = (text) => paint(text, border, opts.color);
1771
+ const ruleText = ([left, cross, right]) => `${left}${widths.map((w) => g.h.repeat(w + 2)).join(cross)}${right}`;
1772
+ const rule = (marks2) => edge(ruleText(marks2));
1773
+ const top = () => {
1774
+ if (title === "") return rule(g.top);
1775
+ const rest = ruleText(g.top).slice(textWidth(title) + 4);
1776
+ return `${edge(`${g.top[0] ?? ""}${g.h} `)}${paint(title, "bold", opts.color)}${edge(` ${rest}`)}`;
1777
+ };
1778
+ const line = (cells, style, cellStyles = []) => {
1627
1779
  const texts = columns.map((c, i) => {
1628
1780
  const w = widths[i] ?? 0;
1629
1781
  const raw = cells[i] ?? "";
1630
1782
  const text = c.flex === true ? truncateMiddle(raw, w) : raw;
1631
1783
  const padded = c.align === "right" ? padStart(text, w) : padEnd(text, w);
1632
- return style === void 0 ? padded : paint(padded, style, opts.color);
1784
+ const cellStyle = cellStyles[i] ?? style ?? c.style;
1785
+ return cellStyle === void 0 ? padded : paint(padded, cellStyle, opts.color);
1633
1786
  });
1634
- return `${dim(g.v)} ${texts.join(` ${dim(g.v)} `)} ${dim(g.v)}`;
1787
+ return `${edge(g.v)} ${texts.join(` ${edge(g.v)} `)} ${edge(g.v)}`;
1635
1788
  };
1636
1789
  return [
1637
- rule(g.top),
1638
- line(
1639
- columns.map((c) => c.header),
1640
- "bold"
1641
- ),
1642
- rule(g.mid),
1643
- ...rows.map((r) => line(r.cells, r.style)),
1790
+ top(),
1791
+ ...header ? [
1792
+ line(
1793
+ columns.map((c) => c.header),
1794
+ "bold"
1795
+ ),
1796
+ rule(g.mid)
1797
+ ] : [],
1798
+ ...rows.map((r) => line(r.cells, r.style, r.cellStyles)),
1644
1799
  rule(g.bottom)
1645
1800
  ];
1646
1801
  }
1647
1802
 
1648
- export { SCHEMA_VERSIONS, asciiTerminal, box, boxLines, ceilTo, colorEnabled, compareText, directoryOf, emptyDirSync, floorTo, homeDir, isDirectorySync, listDirSync, loadThresholds, marks, padEnd, paint, painter, parseRunReport, parseSampleBatch, plural, readCiInfo, readHostInfo, readPackageInfo, readSuite, readTextFile, readTextFileSync, realPathSync, relativeSlashPath, removeFileSync, resolvePath, roundMs, roundRatio, runPass, scanDirSync, schemaIssueToIssue, stringifyStable, table, tempPath, textWidth, thresholdsFilePaths, truncateMiddle, writeJsonStable, writeTextAtomic };
1803
+ export { SCHEMA_VERSIONS, asciiTerminal, box, boxLines, ceilTo, colorEnabled, compareText, directoryOf, emptyDirSync, exceedance, floorTo, formatActual, formatFactor, formatLimit, formatMs, homeDir, isDirectorySync, listDirSync, loadThresholds, marks, overText, padEnd, paint, painter, parseRunReport, parseSampleBatch, plural, readCiInfo, readHostInfo, readPackageInfo, readProcessTable, readSuite, readTextFile, readTextFileSync, realPathSync, relativeSlashPath, removeFileSync, resolvePath, roundMs, roundRatio, runPass, scanDirSync, schemaIssueToIssue, stringifyStable, table, tempPath, textWidth, thresholdsFilePaths, truncateMiddle, writeJsonStable, writeTextAtomic };