playwright-performance-regression 0.1.0-next.1 → 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.
- package/CHANGELOG.md +181 -0
- package/README.md +70 -51
- package/dist/{chunk-GCA73FFP.cjs → chunk-2JO5HVPC.cjs} +351 -44
- package/dist/{chunk-WZVQK7CQ.cjs → chunk-44ASXVQN.cjs} +96 -198
- package/dist/{chunk-L5C63HEF.js → chunk-AQ2XKYNV.js} +347 -45
- package/dist/chunk-BAOTUUTV.cjs +611 -0
- package/dist/chunk-DX36GFOZ.js +558 -0
- package/dist/chunk-LTRHMBVY.js +5592 -0
- package/dist/{chunk-B64P2D5A.js → chunk-MUZFQKGQ.js} +82 -184
- package/dist/cli.js +2825 -1406
- package/dist/config.cjs +91 -44
- package/dist/config.d.cts +4 -2
- package/dist/config.d.ts +4 -2
- package/dist/config.js +84 -37
- package/dist/fixture.cjs +5 -5
- package/dist/fixture.d.cts +2 -2
- package/dist/fixture.d.ts +2 -2
- package/dist/fixture.js +3 -3
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +110 -22
- package/dist/index.d.ts +110 -22
- package/dist/index.js +1 -1
- package/dist/perf-api-Rm1h1O_-.d.cts +12 -0
- package/dist/perf-api-Rm1h1O_-.d.ts +12 -0
- package/dist/reporter.cjs +5184 -1207
- package/dist/reporter.js +2029 -245
- package/dist/test.cjs +4 -4
- package/dist/test.js +3 -3
- package/package.json +3 -1
- package/schemas/common.schema.json +2 -2
- package/schemas/config.schema.json +57 -21
- package/schemas/outcome.schema.json +1 -1
- package/schemas/run-report.schema.json +534 -19
- package/schemas/samples.schema.json +4 -39
- package/schemas/thresholds.schema.json +1 -1
- package/dist/chunk-3CLCMD2Q.js +0 -3411
- package/dist/chunk-4SFI55HF.cjs +0 -319
- package/dist/chunk-HBGADXLP.js +0 -254
- package/dist/perf-api-V4PeHVE0.d.cts +0 -22
- package/dist/perf-api-V4PeHVE0.d.ts +0 -22
|
@@ -0,0 +1,558 @@
|
|
|
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 = "pw-perf-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: "↑",
|
|
81
|
+
tightened: "↓",
|
|
82
|
+
mixed: "±",
|
|
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(" · ");
|
|
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)} → ${limitValueText(c.limit, c.after)}`
|
|
134
|
+
).join(separator);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// src/core/types/index.ts
|
|
138
|
+
var KINDS = ["api", "step"];
|
|
139
|
+
|
|
140
|
+
// src/mode/playwright-args.ts
|
|
141
|
+
var WITH_VALUE = /* @__PURE__ */ new Set([
|
|
142
|
+
"--browser",
|
|
143
|
+
"--config",
|
|
144
|
+
"--global-timeout",
|
|
145
|
+
"--grep",
|
|
146
|
+
"--grep-invert",
|
|
147
|
+
"--max-failures",
|
|
148
|
+
"--output",
|
|
149
|
+
"--repeat-each",
|
|
150
|
+
"--reporter",
|
|
151
|
+
"--retries",
|
|
152
|
+
"--shard",
|
|
153
|
+
"--test-list",
|
|
154
|
+
"--test-list-invert",
|
|
155
|
+
"--timeout",
|
|
156
|
+
"--trace",
|
|
157
|
+
"--tsconfig",
|
|
158
|
+
"--ui-host",
|
|
159
|
+
"--ui-port",
|
|
160
|
+
"--update-source-method",
|
|
161
|
+
"--workers"
|
|
162
|
+
]);
|
|
163
|
+
var OPTIONAL_VALUE = /* @__PURE__ */ new Set(["--only-changed", "--update-snapshots"]);
|
|
164
|
+
var VARIADIC = /* @__PURE__ */ new Set(["--project"]);
|
|
165
|
+
var SHORT = {
|
|
166
|
+
c: "--config",
|
|
167
|
+
g: "--grep",
|
|
168
|
+
j: "--workers",
|
|
169
|
+
u: "--update-snapshots",
|
|
170
|
+
x: "-x",
|
|
171
|
+
h: "--help"
|
|
172
|
+
};
|
|
173
|
+
function isOptionLike(arg) {
|
|
174
|
+
return arg.startsWith("-") && arg !== "-";
|
|
175
|
+
}
|
|
176
|
+
function scanPlaywrightArgs(args) {
|
|
177
|
+
const options = [];
|
|
178
|
+
const positionals = [];
|
|
179
|
+
let i = 0;
|
|
180
|
+
while (i < args.length) {
|
|
181
|
+
const arg = args[i];
|
|
182
|
+
if (!isOptionLike(arg)) {
|
|
183
|
+
positionals.push(arg);
|
|
184
|
+
i += 1;
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
let name;
|
|
188
|
+
let inlineValue;
|
|
189
|
+
if (arg.startsWith("--")) {
|
|
190
|
+
const eq = arg.indexOf("=");
|
|
191
|
+
name = eq === -1 ? arg : arg.slice(0, eq);
|
|
192
|
+
if (eq !== -1) inlineValue = arg.slice(eq + 1);
|
|
193
|
+
} else {
|
|
194
|
+
const long = SHORT[arg.charAt(1)];
|
|
195
|
+
name = long ?? arg;
|
|
196
|
+
if (long !== void 0 && arg.length > 2) {
|
|
197
|
+
const rest = arg.slice(2);
|
|
198
|
+
inlineValue = rest.startsWith("=") ? rest.slice(1) : rest;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const option = { name, values: [], index: i, inline: false };
|
|
202
|
+
options.push(option);
|
|
203
|
+
i += 1;
|
|
204
|
+
if (inlineValue !== void 0) {
|
|
205
|
+
option.values.push(inlineValue);
|
|
206
|
+
option.inline = true;
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
if (WITH_VALUE.has(name)) {
|
|
210
|
+
if (i < args.length) {
|
|
211
|
+
option.values.push(args[i]);
|
|
212
|
+
i += 1;
|
|
213
|
+
}
|
|
214
|
+
} else if (OPTIONAL_VALUE.has(name)) {
|
|
215
|
+
if (i < args.length && !isOptionLike(args[i])) {
|
|
216
|
+
option.values.push(args[i]);
|
|
217
|
+
i += 1;
|
|
218
|
+
}
|
|
219
|
+
} else if (VARIADIC.has(name)) {
|
|
220
|
+
while (i < args.length && !isOptionLike(args[i])) {
|
|
221
|
+
option.values.push(args[i]);
|
|
222
|
+
i += 1;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return { options, positionals };
|
|
227
|
+
}
|
|
228
|
+
var FILTERS = /* @__PURE__ */ new Set([
|
|
229
|
+
"--grep",
|
|
230
|
+
"--grep-invert",
|
|
231
|
+
"--project",
|
|
232
|
+
"--last-failed",
|
|
233
|
+
"--only-changed",
|
|
234
|
+
"--test-list",
|
|
235
|
+
"--test-list-invert"
|
|
236
|
+
]);
|
|
237
|
+
function testFilters(args) {
|
|
238
|
+
const scanned = scanPlaywrightArgs(args);
|
|
239
|
+
return [
|
|
240
|
+
...scanned.options.filter((o) => FILTERS.has(o.name)).map((o) => args.slice(o.index, o.index + 1 + (o.inline ? 0 : o.values.length)).join(" ")),
|
|
241
|
+
...scanned.positionals
|
|
242
|
+
];
|
|
243
|
+
}
|
|
244
|
+
var UNSUPPORTED = /* @__PURE__ */ new Set([
|
|
245
|
+
"--ui",
|
|
246
|
+
"--ui-host",
|
|
247
|
+
"--ui-port",
|
|
248
|
+
"--debug",
|
|
249
|
+
"--shard"
|
|
250
|
+
]);
|
|
251
|
+
function unsupportedOptions(args) {
|
|
252
|
+
return scanPlaywrightArgs(args).options.filter((o) => UNSUPPORTED.has(o.name)).map((o) => o.name);
|
|
253
|
+
}
|
|
254
|
+
function isListOnly(args) {
|
|
255
|
+
return scanPlaywrightArgs(args).options.some((o) => o.name === "--list");
|
|
256
|
+
}
|
|
257
|
+
function playwrightConfigArg(args) {
|
|
258
|
+
const configs = scanPlaywrightArgs(args).options.filter(
|
|
259
|
+
(o) => o.name === "--config" && o.values.length > 0
|
|
260
|
+
);
|
|
261
|
+
return configs.length === 0 ? null : configs[configs.length - 1]?.values[0] ?? null;
|
|
262
|
+
}
|
|
263
|
+
function testArgsFromArgv(argv) {
|
|
264
|
+
const at = argv.findIndex((word, i) => i >= 1 && word === "test");
|
|
265
|
+
return at < 0 ? [] : argv.slice(at + 1);
|
|
266
|
+
}
|
|
267
|
+
function lastReporterValue(args) {
|
|
268
|
+
const reporters = scanPlaywrightArgs(args).options.filter((o) => o.name === "--reporter");
|
|
269
|
+
const last = reporters.at(-1);
|
|
270
|
+
return last === void 0 ? null : last.values.join(",");
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// src/mode/argv-warnings.ts
|
|
274
|
+
var INTERACTIVE = /* @__PURE__ */ new Set(["--ui", "--ui-host", "--ui-port", "--debug"]);
|
|
275
|
+
function argvWarnings(argv, packageName) {
|
|
276
|
+
const args = testArgsFromArgv(argv);
|
|
277
|
+
const reporter = lastReporterValue(args);
|
|
278
|
+
const own = reporter !== null && reporter.includes(packageName);
|
|
279
|
+
const interactive = [
|
|
280
|
+
...new Set(
|
|
281
|
+
scanPlaywrightArgs(args).options.filter((o) => INTERACTIVE.has(o.name)).map((o) => o.name)
|
|
282
|
+
)
|
|
283
|
+
];
|
|
284
|
+
return {
|
|
285
|
+
reporter: reporter === null || own ? null : {
|
|
286
|
+
code: "RUN_REPORTER_FLAG",
|
|
287
|
+
message: `--reporter replaces the pw-perf reporter: nothing will be evaluated and no report will be written.`,
|
|
288
|
+
hint: `Remove --reporter from the measurement command, or add ",${packageName}/reporter" to its value.`
|
|
289
|
+
},
|
|
290
|
+
unsupported: interactive.length === 0 ? null : {
|
|
291
|
+
code: "RUN_UNSUPPORTED_FLAG",
|
|
292
|
+
message: `${interactive.join(", ")}: interactive runs are not measured reliably.`,
|
|
293
|
+
hint: "Run the measurement with a separate script without these options."
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// src/mode/pass-command.ts
|
|
299
|
+
var SCRIPT_FILE = /\.[cm]?js$/iu;
|
|
300
|
+
function baseName(path) {
|
|
301
|
+
return path.split(/[\\/]/u).at(-1) ?? path;
|
|
302
|
+
}
|
|
303
|
+
function words(text) {
|
|
304
|
+
const out = [];
|
|
305
|
+
let current = "";
|
|
306
|
+
let quote = null;
|
|
307
|
+
let started = false;
|
|
308
|
+
for (const ch of text) {
|
|
309
|
+
if (quote !== null) {
|
|
310
|
+
if (ch === quote) quote = null;
|
|
311
|
+
else current += ch;
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
if (ch === '"' || ch === "'") {
|
|
315
|
+
quote = ch;
|
|
316
|
+
started = true;
|
|
317
|
+
} else if (/\s/u.test(ch)) {
|
|
318
|
+
if (started) out.push(current);
|
|
319
|
+
current = "";
|
|
320
|
+
started = false;
|
|
321
|
+
} else {
|
|
322
|
+
current += ch;
|
|
323
|
+
started = true;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
if (started) out.push(current);
|
|
327
|
+
return out;
|
|
328
|
+
}
|
|
329
|
+
function scriptPlaywrightArgs(script) {
|
|
330
|
+
const segments = script.split(/&&|\|\||;|\|/u);
|
|
331
|
+
for (let i = segments.length - 1; i >= 0; i -= 1) {
|
|
332
|
+
const w = words(segments[i] ?? "");
|
|
333
|
+
const at = w.findIndex(
|
|
334
|
+
(word, j) => (baseName(word) === "playwright" || word === "playwright") && w[j + 1] === "test"
|
|
335
|
+
);
|
|
336
|
+
if (at >= 0) return w.slice(at + 2);
|
|
337
|
+
}
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
340
|
+
function addedArgs(argv, script) {
|
|
341
|
+
if (script === void 0) return [];
|
|
342
|
+
const own = scriptPlaywrightArgs(script);
|
|
343
|
+
if (own === null) return [];
|
|
344
|
+
const args = testArgsFromArgv(argv);
|
|
345
|
+
const prefix = own.every((word, i) => args[i] === word);
|
|
346
|
+
return args.slice(prefix ? own.length : Math.min(own.length, args.length));
|
|
347
|
+
}
|
|
348
|
+
function passCommand(input) {
|
|
349
|
+
const event = input.env["npm_lifecycle_event"];
|
|
350
|
+
const manager = input.env["npm_execpath"];
|
|
351
|
+
const script = (event === void 0 ? void 0 : input.scripts?.[event]) ?? input.env["npm_lifecycle_script"] ?? "";
|
|
352
|
+
if (event !== void 0 && event !== "" && manager !== void 0 && manager !== "" && /playwright/u.test(script)) {
|
|
353
|
+
const added = addedArgs(input.argv, script);
|
|
354
|
+
const npm = baseName(manager).toLowerCase().startsWith("npm");
|
|
355
|
+
const tail = added.length === 0 ? [] : npm ? ["--", ...added] : added;
|
|
356
|
+
return SCRIPT_FILE.test(manager) ? { file: input.execPath, args: [manager, "run", event, ...tail] } : { file: manager, args: ["run", event, ...tail] };
|
|
357
|
+
}
|
|
358
|
+
return { file: input.execPath, args: input.argv.slice(1) };
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// src/mode/index.ts
|
|
362
|
+
var MODE = "PW_PERF_MODE";
|
|
363
|
+
var PASSES = "PW_PERF_PASSES";
|
|
364
|
+
var PASS = "PW_PERF_PASS";
|
|
365
|
+
var YES = "PW_PERF_YES";
|
|
366
|
+
var REPEAT = "PW_PERF_REPEAT";
|
|
367
|
+
var ENV = "PW_PERF_ENV";
|
|
368
|
+
var RUN_ID = "PW_PERF_RUN_ID";
|
|
369
|
+
var OUTCOME_FILE = "PW_PERF_OUTCOME_FILE";
|
|
370
|
+
var PRUNE = "PW_PERF_PRUNE";
|
|
371
|
+
var MAX_TESTS = "PW_PERF_MAX_TESTS";
|
|
372
|
+
var MODE_ENV_NAMES = [
|
|
373
|
+
MODE,
|
|
374
|
+
PASSES,
|
|
375
|
+
PASS,
|
|
376
|
+
YES,
|
|
377
|
+
REPEAT,
|
|
378
|
+
ENV,
|
|
379
|
+
RUN_ID,
|
|
380
|
+
OUTCOME_FILE,
|
|
381
|
+
PRUNE,
|
|
382
|
+
MAX_TESTS
|
|
383
|
+
];
|
|
384
|
+
function checkStateFileName(runId) {
|
|
385
|
+
return `playwright-performance-regression-${runId}.check.json`;
|
|
386
|
+
}
|
|
387
|
+
var DEFAULT_MAX_TESTS = 10;
|
|
388
|
+
var POSITIVE_INTEGER = /^[1-9][0-9]*$/u;
|
|
389
|
+
var ENV_LABEL = /^[a-z0-9-]{1,32}$/u;
|
|
390
|
+
function parsePasses(text) {
|
|
391
|
+
return POSITIVE_INTEGER.test(text) ? Number(text) : null;
|
|
392
|
+
}
|
|
393
|
+
function parsePass(text) {
|
|
394
|
+
const match = /^([1-9][0-9]*)\/([1-9][0-9]*)$/u.exec(text);
|
|
395
|
+
if (match === null) return null;
|
|
396
|
+
const index = Number(match[1]);
|
|
397
|
+
const total = Number(match[2]);
|
|
398
|
+
return index >= 2 && index <= total && total <= 1e3 ? { index, total } : null;
|
|
399
|
+
}
|
|
400
|
+
function isEnvLabel(text) {
|
|
401
|
+
return ENV_LABEL.test(text);
|
|
402
|
+
}
|
|
403
|
+
var PASSES_FORMAT = 'an integer >= 1, like "5"';
|
|
404
|
+
var ENV_LABEL_FORMAT = 'a label of lowercase letters, digits and "-" (at most 32 characters), like "staging"';
|
|
405
|
+
function generateRunId(date, random) {
|
|
406
|
+
const time = date.toISOString().slice(0, 19).replaceAll(":", "-");
|
|
407
|
+
const hex = Math.floor(random() * 65536).toString(16).padStart(4, "0");
|
|
408
|
+
return `${time}-${hex}`;
|
|
409
|
+
}
|
|
410
|
+
function read(env, name) {
|
|
411
|
+
const value = env[name];
|
|
412
|
+
return value === void 0 || value === "" ? void 0 : value;
|
|
413
|
+
}
|
|
414
|
+
function invalid(name, expected, value, hint) {
|
|
415
|
+
return {
|
|
416
|
+
code: "MODE_INVALID_VALUE",
|
|
417
|
+
message: `${name}: expected ${expected}, got ${JSON.stringify(value)}`,
|
|
418
|
+
hint
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
function readModeState(env) {
|
|
422
|
+
const mode = read(env, MODE);
|
|
423
|
+
if (mode === void 0) return { ok: true, value: null };
|
|
424
|
+
const issues = [];
|
|
425
|
+
if (mode !== "test" && mode !== "thresholds" && mode !== "check") {
|
|
426
|
+
issues.push(
|
|
427
|
+
invalid(
|
|
428
|
+
MODE,
|
|
429
|
+
'"test", "thresholds" or "check"',
|
|
430
|
+
mode,
|
|
431
|
+
`Set ${MODE} to test, thresholds or check, or unset it to run without perf mode.`
|
|
432
|
+
)
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
const state = {
|
|
436
|
+
mode: mode === "thresholds" || mode === "check" ? mode : "test"
|
|
437
|
+
};
|
|
438
|
+
const repeat = read(env, REPEAT);
|
|
439
|
+
if (repeat !== void 0) {
|
|
440
|
+
issues.push({
|
|
441
|
+
code: "MODE_INVALID_VALUE",
|
|
442
|
+
message: `${REPEAT} is no longer supported, got ${JSON.stringify(repeat)}`,
|
|
443
|
+
hint: `Renamed to ${PASSES}: the test command now runs once per pass. Use ${PASSES}=${repeat}.`
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
const passes = read(env, PASSES);
|
|
447
|
+
if (passes !== void 0) {
|
|
448
|
+
const parsed = parsePasses(passes);
|
|
449
|
+
if (parsed !== null) state.passes = parsed;
|
|
450
|
+
else {
|
|
451
|
+
issues.push(
|
|
452
|
+
invalid(
|
|
453
|
+
PASSES,
|
|
454
|
+
PASSES_FORMAT,
|
|
455
|
+
passes,
|
|
456
|
+
`Fix the number of passes, or unset ${PASSES} to use run.passes from the config.`
|
|
457
|
+
)
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
const pass = read(env, PASS);
|
|
462
|
+
if (pass !== void 0) {
|
|
463
|
+
const parsed = parsePass(pass);
|
|
464
|
+
if (parsed !== null) state.pass = parsed;
|
|
465
|
+
else {
|
|
466
|
+
issues.push(
|
|
467
|
+
invalid(
|
|
468
|
+
PASS,
|
|
469
|
+
'"k/N" with 2 <= k <= N, like "2/5"',
|
|
470
|
+
pass,
|
|
471
|
+
`${PASS} is set by the package for passes 2 and later; unset it.`
|
|
472
|
+
)
|
|
473
|
+
);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
const yes = read(env, YES);
|
|
477
|
+
if (yes !== void 0) {
|
|
478
|
+
if (yes === "1") state.yes = true;
|
|
479
|
+
else {
|
|
480
|
+
issues.push(
|
|
481
|
+
invalid(YES, '"1"', yes, `Set ${YES}=1 to skip the Continue? question, or unset it.`)
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
const label = read(env, ENV);
|
|
486
|
+
if (label !== void 0) {
|
|
487
|
+
if (isEnvLabel(label)) state.env = label;
|
|
488
|
+
else {
|
|
489
|
+
issues.push(
|
|
490
|
+
invalid(
|
|
491
|
+
ENV,
|
|
492
|
+
ENV_LABEL_FORMAT,
|
|
493
|
+
label,
|
|
494
|
+
`Fix the environment label, or unset ${ENV} to use run.env from the config.`
|
|
495
|
+
)
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
const runId = read(env, RUN_ID);
|
|
500
|
+
if (runId !== void 0) state.runId = runId;
|
|
501
|
+
const outcomeFile = read(env, OUTCOME_FILE);
|
|
502
|
+
if (outcomeFile !== void 0) state.outcomeFile = outcomeFile;
|
|
503
|
+
const maxTests = read(env, MAX_TESTS);
|
|
504
|
+
if (maxTests !== void 0) {
|
|
505
|
+
const parsed = parsePasses(maxTests);
|
|
506
|
+
if (parsed !== null && parsed <= 1e3) state.maxTests = parsed;
|
|
507
|
+
else {
|
|
508
|
+
issues.push(
|
|
509
|
+
invalid(
|
|
510
|
+
MAX_TESTS,
|
|
511
|
+
'an integer from 1 to 1000, like "10"',
|
|
512
|
+
maxTests,
|
|
513
|
+
`Fix the number of tests a check runs, or unset ${MAX_TESTS} (default ${String(DEFAULT_MAX_TESTS)}).`
|
|
514
|
+
)
|
|
515
|
+
);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
const prune = read(env, PRUNE);
|
|
519
|
+
if (prune !== void 0) {
|
|
520
|
+
if (prune === "1") state.prune = true;
|
|
521
|
+
else {
|
|
522
|
+
issues.push(
|
|
523
|
+
invalid(
|
|
524
|
+
PRUNE,
|
|
525
|
+
'"1"',
|
|
526
|
+
prune,
|
|
527
|
+
`Set ${PRUNE}=1 to remove unlocked entries not seen in the run, or unset it.`
|
|
528
|
+
)
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
return issues.length > 0 ? { ok: false, issues } : { ok: true, value: state };
|
|
533
|
+
}
|
|
534
|
+
function writeModeState(state) {
|
|
535
|
+
const env = { [MODE]: state.mode };
|
|
536
|
+
if (state.passes !== void 0) env[PASSES] = String(state.passes);
|
|
537
|
+
if (state.pass !== void 0)
|
|
538
|
+
env[PASS] = `${String(state.pass.index)}/${String(state.pass.total)}`;
|
|
539
|
+
if (state.yes === true) env[YES] = "1";
|
|
540
|
+
if (state.env !== void 0) env[ENV] = state.env;
|
|
541
|
+
if (state.runId !== void 0) env[RUN_ID] = state.runId;
|
|
542
|
+
if (state.outcomeFile !== void 0) env[OUTCOME_FILE] = state.outcomeFile;
|
|
543
|
+
if (state.prune === true) env[PRUNE] = "1";
|
|
544
|
+
if (state.maxTests !== void 0) env[MAX_TESTS] = String(state.maxTests);
|
|
545
|
+
return env;
|
|
546
|
+
}
|
|
547
|
+
function isCiEnv(env) {
|
|
548
|
+
return read(env, "CI") !== void 0;
|
|
549
|
+
}
|
|
550
|
+
var RUN_ID_ENV = RUN_ID;
|
|
551
|
+
|
|
552
|
+
// package.json
|
|
553
|
+
var version = "0.1.0-next.3";
|
|
554
|
+
var peerDependencies = {
|
|
555
|
+
"@playwright/test": ">=1.57.0"
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
export { CLI_COMMAND, CONFIG_FILE_BASENAME, CONFIG_FILE_EXTENSIONS, CONTEXT_CLOSED_FAILURE_TEXT, ConfigError, DEFAULT_MAX_TESTS, DIFF_CATEGORIES, DOCS_CONFIG_URL, ENV_LABEL_FORMAT, KINDS, LIMIT_NAMES, LISTED_CATEGORIES, MODE_ENV_NAMES, PACKAGE_NAME, PASSES_FORMAT, REPOSITORY_URL, RUN_ID_ENV, SAMPLES_ATTACHMENT_NAME, argvWarnings, checkStateFileName, diffChangeText, diffCountsText, diffMarker, diffValuesText, generateRunId, isCiEnv, isEnvLabel, isListOnly, parsePasses, passCommand, peerDependencies, playwrightConfigArg, readModeState, scanPlaywrightArgs, testArgsFromArgv, testFilters, unsupportedOptions, version, writeModeState };
|