playwright-performance-regression 0.1.0-next.0 → 0.1.0-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/CHANGELOG.md +199 -0
  2. package/README.md +73 -52
  3. package/dist/{chunk-GCA73FFP.cjs → chunk-2JO5HVPC.cjs} +351 -44
  4. package/dist/{chunk-R2NPYGB7.cjs → chunk-44ASXVQN.cjs} +96 -198
  5. package/dist/{chunk-HES6BVZT.js → chunk-AQ2XKYNV.js} +349 -47
  6. package/dist/chunk-BAOTUUTV.cjs +611 -0
  7. package/dist/chunk-DX36GFOZ.js +558 -0
  8. package/dist/chunk-LTRHMBVY.js +5592 -0
  9. package/dist/{chunk-UTTU4FUC.js → chunk-MUZFQKGQ.js} +82 -184
  10. package/dist/cli.js +3500 -1157
  11. package/dist/config.cjs +91 -44
  12. package/dist/config.d.cts +4 -2
  13. package/dist/config.d.ts +4 -2
  14. package/dist/config.js +84 -37
  15. package/dist/fixture.cjs +5 -5
  16. package/dist/fixture.d.cts +2 -2
  17. package/dist/fixture.d.ts +2 -2
  18. package/dist/fixture.js +3 -3
  19. package/dist/index.cjs +3 -3
  20. package/dist/index.d.cts +110 -22
  21. package/dist/index.d.ts +110 -22
  22. package/dist/index.js +1 -1
  23. package/dist/perf-api-Rm1h1O_-.d.cts +12 -0
  24. package/dist/perf-api-Rm1h1O_-.d.ts +12 -0
  25. package/dist/reporter.cjs +5204 -1209
  26. package/dist/reporter.js +2035 -254
  27. package/dist/test.cjs +4 -4
  28. package/dist/test.js +3 -3
  29. package/package.json +5 -3
  30. package/schemas/common.schema.json +2 -2
  31. package/schemas/config.schema.json +57 -21
  32. package/schemas/outcome.schema.json +1 -1
  33. package/schemas/run-report.schema.json +534 -19
  34. package/schemas/samples.schema.json +4 -39
  35. package/schemas/thresholds.schema.json +1 -1
  36. package/dist/chunk-6AB42SPF.js +0 -254
  37. package/dist/chunk-JEHUFIY3.js +0 -3390
  38. package/dist/chunk-LV3O2BAT.cjs +0 -319
  39. package/dist/perf-api-V4PeHVE0.d.cts +0 -22
  40. package/dist/perf-api-V4PeHVE0.d.ts +0 -22
@@ -2,12 +2,12 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "https://pkg.invalid/schemas/samples.schema.json",
4
4
  "title": "Sample batch",
5
- "description": "Raw samples collected during one test execution, attached to the test result as the 'playwright-performance-regression-samples' attachment (ADR-0003). In perf mode every test in a measured project gets this attachment, even when it is empty (05-REQ-15). Written by the collector, read by the reporter. Test metadata is not included; the reporter adds it from TestCase/TestResult.",
5
+ "description": "Raw samples collected during one test execution, attached to the test result as the 'pw-perf-samples' attachment (ADR-0003). In perf mode every test in a measured project gets this attachment, even when it is empty (05-REQ-15). Written by the collector, read by the reporter. Test metadata is not included; the reporter adds it from TestCase/TestResult.",
6
6
  "type": "object",
7
7
  "additionalProperties": false,
8
- "required": ["schemaVersion", "collector", "requests", "custom", "diagnostics"],
8
+ "required": ["schemaVersion", "collector", "requests", "diagnostics"],
9
9
  "properties": {
10
- "schemaVersion": {"const": 1},
10
+ "schemaVersion": {"const": 2},
11
11
  "collector": {
12
12
  "description": "Collector that produced the batch.",
13
13
  "type": "object",
@@ -31,13 +31,8 @@
31
31
  "type": "array",
32
32
  "items": {"$ref": "#/$defs/requestSample"}
33
33
  },
34
- "custom": {
35
- "description": "Custom measurement samples in the order they finished.",
36
- "type": "array",
37
- "items": {"$ref": "#/$defs/customSample"}
38
- },
39
34
  "diagnostics": {
40
- "description": "Collector and custom-measurement diagnostics caught during the test (01-REQ-13, 05 §9, 06 §9). Repeated issues are collapsed using 'count'. The reporter turns every diagnostic into an entry in 'warnings' (09-REQ-23); none of them is a tool error.",
35
+ "description": "Collector diagnostics caught during the test (01-REQ-13, 05 §9). Repeated issues are collapsed using 'count'. The reporter turns every diagnostic into an entry in 'warnings' (09-REQ-23); none of them is a tool error.",
41
36
  "type": "array",
42
37
  "items": {"$ref": "common.schema.json#/$defs/issue"}
43
38
  }
@@ -134,36 +129,6 @@
134
129
  }
135
130
  }
136
131
  ]
137
- },
138
- "customSample": {
139
- "description": "One custom measurement (06).",
140
- "type": "object",
141
- "additionalProperties": false,
142
- "required": ["name", "outcome", "duration", "endTime"],
143
- "properties": {
144
- "name": {
145
- "description": "Measurement name given by the user (06-REQ-03): 1–200 characters, no leading or trailing whitespace, no control characters.",
146
- "type": "string",
147
- "minLength": 1,
148
- "maxLength": 200,
149
- "pattern": "^[^\\s\\u0000-\\u001F\\u007F](?:[^\\u0000-\\u001F\\u007F]*[^\\s\\u0000-\\u001F\\u007F])?$"
150
- },
151
- "outcome": {
152
- "description": "ok: finished normally; error: the measured function threw; unfinished: started but never ended before test end. Meaning of each outcome for statistics: 06, 08.",
153
- "enum": ["ok", "error", "unfinished"]
154
- },
155
- "duration": {
156
- "description": "Measured duration (performance.now()). Null for unfinished.",
157
- "$ref": "common.schema.json#/$defs/msOrNull"
158
- },
159
- "endTime": {
160
- "description": "Wall-clock end time. Null for unfinished.",
161
- "oneOf": [{"$ref": "common.schema.json#/$defs/epochMs"}, {"type": "null"}]
162
- }
163
- },
164
- "if": {"properties": {"outcome": {"const": "unfinished"}}},
165
- "then": {"properties": {"duration": {"type": "null"}, "endTime": {"type": "null"}}},
166
- "else": {"properties": {"duration": {"type": "number"}, "endTime": {"type": "integer"}}}
167
132
  }
168
133
  }
169
134
  }
@@ -7,7 +7,7 @@
7
7
  "additionalProperties": false,
8
8
  "required": ["schemaVersion", "kind", "generated", "entries"],
9
9
  "properties": {
10
- "schemaVersion": {"const": 1},
10
+ "schemaVersion": {"const": 2},
11
11
  "kind": {"$ref": "common.schema.json#/$defs/kind"},
12
12
  "generated": {
13
13
  "description": "How the file was derived. Null for a file written entirely by hand. Contains no wall-clock time of generation, so deriving twice from the same report gives identical files (S-04).",
@@ -1,254 +0,0 @@
1
- // src/core/types/constants.ts
2
- var CONTEXT_CLOSED_FAILURE_TEXT = "pw-perf: context closed";
3
- var PACKAGE_NAME = "playwright-performance-regression";
4
- var SAMPLES_ATTACHMENT_NAME = `${PACKAGE_NAME}-samples`;
5
- var CLI_COMMAND = "npx pw-perf";
6
- var REPOSITORY_URL = "https://github.com/Meser6/playwright-performance-regression";
7
- var DOCS_CONFIG_URL = `${REPOSITORY_URL}/blob/main/docs/configuration.md`;
8
- var CONFIG_FILE_BASENAME = "pw-perf.config";
9
- var CONFIG_FILE_EXTENSIONS = [
10
- ".ts",
11
- ".mts",
12
- ".js",
13
- ".mjs",
14
- ".cjs",
15
- ".json"
16
- ];
17
-
18
- // src/core/types/common.ts
19
- var ConfigError = class extends Error {
20
- issues;
21
- constructor(issues) {
22
- const count = `${issues.length} ${issues.length === 1 ? "problem" : "problems"}`;
23
- super(
24
- [
25
- `${PACKAGE_NAME}: invalid configuration (${count})`,
26
- ...issues.flatMap((issue) => [
27
- ` - ${issue.message}`,
28
- ...issue.hint === void 0 ? [] : [` ${issue.hint}`]
29
- ]),
30
- `See ${DOCS_CONFIG_URL} for all options.`
31
- ].join("\n")
32
- );
33
- this.name = "ConfigError";
34
- this.issues = issues;
35
- }
36
- };
37
-
38
- // src/core/types/thresholds.ts
39
- var LIMIT_NAMES = [
40
- "t",
41
- "median",
42
- "percentile",
43
- "p99",
44
- "minApdex",
45
- "maxWilson",
46
- "maxErrorRate"
47
- ];
48
- var DIFF_CATEGORIES = [
49
- "added",
50
- "removed",
51
- "loosened",
52
- "tightened",
53
- "mixed",
54
- "unchanged",
55
- "locked",
56
- "unseen",
57
- "skipped"
58
- ];
59
- function limitLabel(limit, level) {
60
- switch (limit) {
61
- case "percentile":
62
- return level;
63
- case "minApdex":
64
- return "apdex";
65
- case "maxWilson":
66
- return "wilson";
67
- case "maxErrorRate":
68
- return "errors";
69
- default:
70
- return limit;
71
- }
72
- }
73
- function limitValueText(limit, value) {
74
- if (value === null) return "null";
75
- return limit === "t" || limit === "median" || limit === "percentile" || limit === "p99" ? String(value) : value.toFixed(3);
76
- }
77
- var MARKERS = {
78
- added: "+",
79
- removed: "-",
80
- loosened: "\u2191",
81
- tightened: "\u2193",
82
- mixed: "\xB1",
83
- unchanged: "=",
84
- locked: "#",
85
- unseen: "?",
86
- skipped: "."
87
- };
88
- function diffMarker(diff) {
89
- const large = diff.changes.some((c) => c.large === true);
90
- return `${MARKERS[diff.category]}${large ? "!" : ""}`;
91
- }
92
- var LISTED_CATEGORIES = /* @__PURE__ */ new Set([
93
- "added",
94
- "removed",
95
- "loosened",
96
- "tightened",
97
- "mixed"
98
- ]);
99
- function diffCountsText(diff) {
100
- const parts = [];
101
- for (const category of DIFF_CATEGORIES) {
102
- const n = diff.counts[category];
103
- if (n === 0) continue;
104
- let extra = "";
105
- if (category === "unchanged") {
106
- const kept = diff.keys.filter((k) => k.withinHysteresis === true).length;
107
- if (kept > 0) extra = ` (${kept} within hysteresis)`;
108
- } else if (category === "locked") {
109
- const incomplete = diff.keys.filter((k) => k.incomplete === true).length;
110
- if (incomplete > 0)
111
- extra = ` (${incomplete} incomplete ${incomplete === 1 ? "entry" : "entries"})`;
112
- }
113
- parts.push(`${n} ${category}${extra}`);
114
- }
115
- return parts.length === 0 ? "no entries" : parts.join(" \xB7 ");
116
- }
117
- function diffValuesText(diff, side, level, separator) {
118
- if (diff.limits !== void 0) {
119
- const shown = diff.category === "added" === (side === "after");
120
- if (!shown) return "";
121
- const limits = diff.limits;
122
- return LIMIT_NAMES.map(
123
- (name) => `${limitLabel(name, level)} ${limitValueText(name, limits[name])}`
124
- ).join(separator);
125
- }
126
- return diff.changes.map((c) => `${limitLabel(c.limit, level)} ${limitValueText(c.limit, c[side])}`).join(separator);
127
- }
128
- function diffChangeText(diff, level, separator) {
129
- if (diff.limits !== void 0) {
130
- return diffValuesText(diff, diff.category === "added" ? "after" : "before", level, separator);
131
- }
132
- return diff.changes.map(
133
- (c) => `${limitLabel(c.limit, level)} ${limitValueText(c.limit, c.before)} \u2192 ${limitValueText(c.limit, c.after)}`
134
- ).join(separator);
135
- }
136
-
137
- // src/mode/index.ts
138
- var MODE = "PW_PERF_MODE";
139
- var REPEAT = "PW_PERF_REPEAT";
140
- var ENV = "PW_PERF_ENV";
141
- var RUN_ID = "PW_PERF_RUN_ID";
142
- var OUTCOME_FILE = "PW_PERF_OUTCOME_FILE";
143
- var PRUNE = "PW_PERF_PRUNE";
144
- var MODE_ENV_NAMES = [MODE, REPEAT, ENV, RUN_ID, OUTCOME_FILE, PRUNE];
145
- var POSITIVE_INTEGER = /^[1-9][0-9]*$/u;
146
- var ENV_LABEL = /^[a-z0-9-]{1,32}$/u;
147
- function parseRepeat(text) {
148
- return POSITIVE_INTEGER.test(text) ? Number(text) : null;
149
- }
150
- function isEnvLabel(text) {
151
- return ENV_LABEL.test(text);
152
- }
153
- var REPEAT_FORMAT = 'an integer >= 1, like "5"';
154
- var ENV_LABEL_FORMAT = 'a label of lowercase letters, digits and "-" (at most 32 characters), like "staging"';
155
- function generateRunId(date, random) {
156
- const time = date.toISOString().slice(0, 19).replaceAll(":", "-");
157
- const hex = Math.floor(random() * 65536).toString(16).padStart(4, "0");
158
- return `${time}-${hex}`;
159
- }
160
- function read(env, name) {
161
- const value = env[name];
162
- return value === void 0 || value === "" ? void 0 : value;
163
- }
164
- function invalid(name, expected, value, hint) {
165
- return {
166
- code: "MODE_INVALID_VALUE",
167
- message: `${name}: expected ${expected}, got ${JSON.stringify(value)}`,
168
- hint
169
- };
170
- }
171
- function readModeState(env) {
172
- const mode = read(env, MODE);
173
- if (mode === void 0) return { ok: true, value: null };
174
- const issues = [];
175
- if (mode !== "test" && mode !== "thresholds") {
176
- issues.push(
177
- invalid(
178
- MODE,
179
- '"test" or "thresholds"',
180
- mode,
181
- `Unset ${MODE} to run without perf mode, or start the run with "npx pw-perf test".`
182
- )
183
- );
184
- }
185
- const state = { mode: mode === "thresholds" ? "thresholds" : "test" };
186
- const repeat = read(env, REPEAT);
187
- if (repeat !== void 0) {
188
- const parsed = parseRepeat(repeat);
189
- if (parsed !== null) state.repeat = parsed;
190
- else {
191
- issues.push(
192
- invalid(
193
- REPEAT,
194
- REPEAT_FORMAT,
195
- repeat,
196
- `Fix the number of repetitions per test, or unset ${REPEAT} to use run.repeat from the config.`
197
- )
198
- );
199
- }
200
- }
201
- const label = read(env, ENV);
202
- if (label !== void 0) {
203
- if (isEnvLabel(label)) state.env = label;
204
- else {
205
- issues.push(
206
- invalid(
207
- ENV,
208
- ENV_LABEL_FORMAT,
209
- label,
210
- `Fix the environment label, or unset ${ENV} to use run.env from the config.`
211
- )
212
- );
213
- }
214
- }
215
- const runId = read(env, RUN_ID);
216
- if (runId !== void 0) state.runId = runId;
217
- const outcomeFile = read(env, OUTCOME_FILE);
218
- if (outcomeFile !== void 0) state.outcomeFile = outcomeFile;
219
- const prune = read(env, PRUNE);
220
- if (prune !== void 0) {
221
- if (prune === "1") state.prune = true;
222
- else {
223
- issues.push(
224
- invalid(
225
- PRUNE,
226
- '"1"',
227
- prune,
228
- `Set ${PRUNE}=1 to remove unlocked entries not seen in the run, or unset it.`
229
- )
230
- );
231
- }
232
- }
233
- return issues.length > 0 ? { ok: false, issues } : { ok: true, value: state };
234
- }
235
- function writeModeState(state) {
236
- const env = { [MODE]: state.mode };
237
- if (state.repeat !== void 0) env[REPEAT] = String(state.repeat);
238
- if (state.env !== void 0) env[ENV] = state.env;
239
- if (state.runId !== void 0) env[RUN_ID] = state.runId;
240
- if (state.outcomeFile !== void 0) env[OUTCOME_FILE] = state.outcomeFile;
241
- if (state.prune === true) env[PRUNE] = "1";
242
- return env;
243
- }
244
- function isCiEnv(env) {
245
- return read(env, "CI") !== void 0;
246
- }
247
-
248
- // package.json
249
- var version = "0.1.0-next.0";
250
- var peerDependencies = {
251
- "@playwright/test": ">=1.57.0"
252
- };
253
-
254
- export { CLI_COMMAND, CONFIG_FILE_BASENAME, CONFIG_FILE_EXTENSIONS, CONTEXT_CLOSED_FAILURE_TEXT, ConfigError, DIFF_CATEGORIES, DOCS_CONFIG_URL, ENV_LABEL_FORMAT, LIMIT_NAMES, LISTED_CATEGORIES, MODE_ENV_NAMES, PACKAGE_NAME, REPEAT_FORMAT, REPOSITORY_URL, SAMPLES_ATTACHMENT_NAME, diffChangeText, diffCountsText, diffMarker, diffValuesText, generateRunId, isCiEnv, isEnvLabel, parseRepeat, peerDependencies, readModeState, version, writeModeState };