playwright-performance-regression 0.1.0-next.3 → 1.0.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +388 -0
  2. package/README.md +53 -41
  3. package/dist/{chunk-MUZFQKGQ.js → chunk-4WX3Z5MJ.js} +321 -30
  4. package/dist/{chunk-AQ2XKYNV.js → chunk-5Y34Q4DR.js} +37 -9
  5. package/dist/chunk-B4XTLSRN.js +1788 -0
  6. package/dist/{chunk-44ASXVQN.cjs → chunk-PWK5XSP2.cjs} +337 -45
  7. package/dist/{chunk-DYLCGMI2.js → chunk-S6UH6QPK.js} +6 -1
  8. package/dist/{chunk-BAOTUUTV.cjs → chunk-VREOANPX.cjs} +75 -28
  9. package/dist/{chunk-2JO5HVPC.cjs → chunk-W7NEFS5V.cjs} +37 -9
  10. package/dist/{chunk-DX36GFOZ.js → chunk-YKBX6SAT.js} +94 -57
  11. package/dist/cli.js +1922 -3307
  12. package/dist/config.cjs +58 -120
  13. package/dist/config.d.cts +2 -3
  14. package/dist/config.d.ts +2 -3
  15. package/dist/config.js +48 -110
  16. package/dist/fixture.cjs +9 -5
  17. package/dist/fixture.d.cts +10 -4
  18. package/dist/fixture.d.ts +10 -4
  19. package/dist/fixture.js +4 -4
  20. package/dist/index.cjs +3 -3
  21. package/dist/index.d.cts +22 -10
  22. package/dist/index.d.ts +22 -10
  23. package/dist/index.js +1 -1
  24. package/dist/perf-api-2DH_keLh.d.cts +17 -0
  25. package/dist/perf-api-2DH_keLh.d.ts +17 -0
  26. package/dist/reporter.cjs +2046 -835
  27. package/dist/reporter.js +6741 -1737
  28. package/dist/test.cjs +4 -4
  29. package/dist/test.js +4 -4
  30. package/package.json +17 -3
  31. package/schemas/config.schema.json +29 -14
  32. package/schemas/outcome.schema.json +1 -1
  33. package/schemas/run-report.schema.json +16 -2
  34. package/schemas/samples.schema.json +48 -2
  35. package/dist/chunk-LTRHMBVY.js +0 -5592
  36. package/dist/perf-api-Rm1h1O_-.d.cts +0 -12
  37. package/dist/perf-api-Rm1h1O_-.d.ts +0 -12
package/dist/config.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkBAOTUUTV_cjs = require('./chunk-BAOTUUTV.cjs');
4
- var chunk2JO5HVPC_cjs = require('./chunk-2JO5HVPC.cjs');
3
+ var chunkVREOANPX_cjs = require('./chunk-VREOANPX.cjs');
4
+ var chunkW7NEFS5V_cjs = require('./chunk-W7NEFS5V.cjs');
5
5
 
6
6
  // src/config/reporter-path.ts
7
7
  function currentFile() {
@@ -20,16 +20,10 @@ function reporterEntryPath() {
20
20
  // src/config/run-conditions.ts
21
21
  var CONSOLE_REPORTERS = /* @__PURE__ */ new Set(["list", "line", "dot", "github"]);
22
22
  var ARTIFACTS = ["trace", "video", "screenshot"];
23
- var PACKAGE_REPORTER = `${chunkBAOTUUTV_cjs.PACKAGE_NAME}/reporter`;
23
+ var PACKAGE_REPORTER = `${chunkVREOANPX_cjs.PACKAGE_NAME}/reporter`;
24
24
  function projectName(project) {
25
25
  return project.name ?? "";
26
26
  }
27
- function browserOf(project, config) {
28
- return project?.use?.browserName ?? config.use?.browserName ?? project?.use?.defaultBrowserType ?? config.use?.defaultBrowserType ?? "chromium";
29
- }
30
- function quoted(names) {
31
- return names.map((name) => JSON.stringify(name)).join(", ");
32
- }
33
27
  function records(value) {
34
28
  if (value === void 0 || value === "off") return false;
35
29
  if (typeof value === "object" && value !== null && "mode" in value) return value.mode !== "off";
@@ -53,57 +47,14 @@ function andGrep(extra, own) {
53
47
  [...flags].sort().join("")
54
48
  );
55
49
  }
56
- function measuredNames(config, projects, option) {
57
- const names = projects.map(projectName);
58
- if (option !== "auto") {
59
- const known = new Set(names);
60
- const unknown = option.filter((name) => !known.has(name));
61
- if (unknown.length > 0) {
62
- const available = names.length === 0 || config.projects === void 0 ? "it has no projects, only the default one" : `its projects are ${quoted(names)}`;
63
- return {
64
- ok: false,
65
- issues: unknown.map((name) => ({
66
- code: "CONFIG_UNKNOWN_PROJECT",
67
- path: "run.projects",
68
- message: `run.projects: project ${JSON.stringify(name)} is not in the Playwright config; ${available}`,
69
- hint: 'Use project names from the Playwright config, or "auto".'
70
- }))
71
- };
72
- }
73
- return { ok: true, value: names.filter((name) => option.includes(name)) };
74
- }
50
+ function measurableProjects(projects) {
75
51
  const supporting = new Set(
76
52
  projects.flatMap((p) => [
77
53
  ...p.dependencies ?? [],
78
54
  ...p.teardown === void 0 ? [] : [p.teardown]
79
55
  ])
80
56
  );
81
- const measured = projects.filter((p) => !supporting.has(projectName(p)) && browserOf(p, config) === "chromium").map(projectName);
82
- if (measured.length > 0) return { ok: true, value: measured };
83
- return {
84
- ok: false,
85
- issues: [
86
- {
87
- code: "CONFIG_NO_MEASURED_PROJECT",
88
- path: "run.projects",
89
- message: 'run.projects: no project is measured; "auto" measures Chromium projects that are not a dependency or teardown of another project, and the Playwright config has none',
90
- hint: 'List the projects to measure in run.projects, e.g. ["firefox"].'
91
- }
92
- ]
93
- };
94
- }
95
- function projectsToKeep(projects, measured) {
96
- const byName = new Map(projects.map((p) => [projectName(p), p]));
97
- const keep = /* @__PURE__ */ new Set();
98
- const visit = (name) => {
99
- const project = byName.get(name);
100
- if (project === void 0 || keep.has(name)) return;
101
- keep.add(name);
102
- for (const dependency of project.dependencies ?? []) visit(dependency);
103
- if (project.teardown !== void 0) visit(project.teardown);
104
- };
105
- for (const name of measured) visit(name);
106
- return keep;
57
+ return projects.map(projectName).filter((name) => !supporting.has(name));
107
58
  }
108
59
  function reporterEntries(reporter) {
109
60
  if (reporter === void 0) return [];
@@ -138,7 +89,14 @@ function planReporters(reporter, input) {
138
89
  if (!deduped.some(([name]) => ours(name))) reporters.push([input.reporterPath]);
139
90
  return { reporters, removed, replaced };
140
91
  }
141
- function overriddenSettings(config, kept) {
92
+ function effectiveLaunchOptions(config, project) {
93
+ return project?.use?.launchOptions ?? config.use?.launchOptions;
94
+ }
95
+ function measuredLaunchOptions(config, measured) {
96
+ if (config.projects === void 0) return [config.use?.launchOptions];
97
+ return config.projects.filter((p) => measured.has(projectName(p))).map((p) => effectiveLaunchOptions(config, p));
98
+ }
99
+ function overriddenSettings(config, kept, slowMoOverridden) {
142
100
  const scopes = [config, ...kept];
143
101
  const repeatChanged = [config, ...kept].some(
144
102
  (scope) => scope.repeatEach !== void 0 && scope.repeatEach !== 1
@@ -151,46 +109,15 @@ function overriddenSettings(config, kept) {
151
109
  ...ARTIFACTS.map((name) => [
152
110
  name,
153
111
  scopes.some((scope) => records(scope.use?.[name]))
154
- ])
112
+ ]),
113
+ ["slowMo", slowMoOverridden]
155
114
  ];
156
115
  return changed.filter(([, value]) => value).map(([name]) => name);
157
116
  }
158
- function slowMoWarnings(config, kept) {
159
- const places = [
160
- ...positive(config.use?.launchOptions?.slowMo) ? ["the global config"] : [],
161
- ...kept.filter((p) => positive(p.use?.launchOptions?.slowMo)).map((p) => `project ${JSON.stringify(projectName(p))}`)
162
- ];
163
- if (places.length === 0) return [];
164
- return [
165
- {
166
- code: "CONFIG_SLOW_MO",
167
- path: "use.launchOptions.slowMo",
168
- message: `use.launchOptions.slowMo: is greater than 0 in ${places.join(", ")}; it slows down every browser action and distorts the measured times`,
169
- hint: "Remove slowMo from the Playwright config for the measurement run."
170
- }
171
- ];
172
- }
173
- function enginesWarnings(config, projects, measured) {
174
- const byName = new Map(projects.map((p) => [projectName(p), p]));
175
- const engines = [...new Set(measured.map((name) => browserOf(byName.get(name), config)))];
176
- if (engines.length < 2) return [];
177
- return [
178
- {
179
- code: "CONFIG_MULTIPLE_ENGINES",
180
- path: "run.projects",
181
- message: `run.projects: the measured projects use more than one browser engine (${engines.join(", ")}); their samples go to the same keys`,
182
- hint: "Measure one browser engine per run: list projects of one engine in run.projects."
183
- }
184
- ];
185
- }
186
117
  function planPerfRun(config, input) {
187
118
  const source = config;
188
119
  const projects = source.projects ?? [{}];
189
- const measured = measuredNames(source, projects, input.projects);
190
- if (!measured.ok) return measured;
191
- const keep = projectsToKeep(projects, measured.value);
192
- const kept = source.projects === void 0 ? [] : projects.filter((p) => keep.has(projectName(p)));
193
- const removedProjects = source.projects === void 0 ? [] : projects.filter((p) => !keep.has(projectName(p))).map(projectName);
120
+ const measured = measurableProjects(projects);
194
121
  const { reporters, removed, replaced } = planReporters(source.reporter, input);
195
122
  const result = {
196
123
  ...source,
@@ -202,68 +129,78 @@ function planPerfRun(config, input) {
202
129
  };
203
130
  result.repeatEach = 1;
204
131
  const grep = input.grep ?? null;
132
+ const overrideSlowMo = input.overrideSlowMo ?? false;
133
+ const kept = source.projects ?? [];
134
+ const measuredSet = new Set(measured);
205
135
  if (source.projects !== void 0) {
206
- const measuredSet = new Set(measured.value);
207
136
  result.projects = kept.map((p) => {
208
137
  const project = { ...p, repeatEach: 1, use: artifactsOff(p.use) };
209
- if (grep !== null && measuredSet.has(projectName(p))) {
138
+ const isMeasured = measuredSet.has(projectName(p));
139
+ if (grep !== null && isMeasured) {
210
140
  project.grep = andGrep(grep, p.grep ?? source.grep);
211
141
  }
142
+ if (overrideSlowMo && isMeasured) {
143
+ project.use = {
144
+ ...project.use,
145
+ launchOptions: { ...effectiveLaunchOptions(source, p), slowMo: 0 }
146
+ };
147
+ }
212
148
  return project;
213
149
  });
214
- } else if (grep !== null) {
215
- result.grep = andGrep(grep, source.grep);
150
+ } else {
151
+ if (grep !== null) result.grep = andGrep(grep, source.grep);
152
+ if (overrideSlowMo) {
153
+ result.use = { ...result.use, launchOptions: { ...source.use?.launchOptions, slowMo: 0 } };
154
+ }
216
155
  }
156
+ const slowMoOverridden = overrideSlowMo && measuredLaunchOptions(source, measuredSet).some((options) => positive(options?.slowMo));
217
157
  return {
218
158
  ok: true,
219
159
  value: {
220
160
  config: result,
221
- measuredProjects: measured.value,
161
+ measuredProjects: measured,
222
162
  runConditions: {
223
- overridden: overriddenSettings(source, kept),
224
- removedProjects,
163
+ overridden: overriddenSettings(source, kept, slowMoOverridden),
225
164
  removedReporters: removed,
226
165
  replacedReporters: replaced
227
- },
228
- warnings: [
229
- ...enginesWarnings(source, projects, measured.value),
230
- ...slowMoWarnings(source, kept)
231
- ]
166
+ }
232
167
  }
233
168
  };
234
169
  }
235
170
 
236
171
  // src/config/with-perf.ts
237
172
  function withPerf(config, perfConfig) {
238
- const first = chunkBAOTUUTV_cjs.readModeState(process.env);
239
- if (!first.ok) throw new chunkBAOTUUTV_cjs.ConfigError(first.issues);
173
+ const first = chunkVREOANPX_cjs.readModeState(process.env);
174
+ if (!first.ok) throw new chunkVREOANPX_cjs.ConfigError(first.issues);
240
175
  if (first.value === null) return config;
241
- const argvIssues = mainProcessSetup(first.value.outcomeFile === void 0);
242
- const mode = chunkBAOTUUTV_cjs.readModeState(process.env);
176
+ const argvIssues = mainProcessSetup(first.value.mode);
177
+ const mode = chunkVREOANPX_cjs.readModeState(process.env);
243
178
  if (!mode.ok || mode.value === null) throw new Error("withPerf: the mode state changed");
244
179
  const state = mode.value;
245
- const resolved = chunk2JO5HVPC_cjs.resolveConfig(perfConfig, {
180
+ const resolved = chunkW7NEFS5V_cjs.resolveConfig(perfConfig, {
246
181
  mode: state.mode === "check" ? "test" : state.mode,
247
182
  ...passesOverride(state),
248
- ...state.env === void 0 ? {} : { env: state.env }
183
+ ...state.env === void 0 ? {} : { env: state.env },
184
+ ...state.thresholdsDir === void 0 ? {} : { thresholdsDir: state.thresholdsDir },
185
+ ...state.minSamples === void 0 ? {} : { minSamples: state.minSamples }
249
186
  });
250
- if (!resolved.ok) throw new chunkBAOTUUTV_cjs.ConfigError(resolved.issues);
187
+ if (!resolved.ok) throw new chunkVREOANPX_cjs.ConfigError(resolved.issues);
251
188
  const { config: perf, snapshot, warnings } = resolved.value;
252
189
  const plan = planPerfRun(config, {
253
- projects: perf.run.projects,
254
190
  keepReporters: perf.run.keepReporters,
255
191
  grep: perf.run.grep,
192
+ overrideSlowMo: perf.run.overrideSlowMo,
256
193
  reporterPath: reporterEntryPath()
257
194
  });
258
- if (!plan.ok) throw new chunkBAOTUUTV_cjs.ConfigError(plan.issues);
259
- chunkBAOTUUTV_cjs.setRegistered({
195
+ chunkVREOANPX_cjs.setRegistered({
260
196
  config: perf,
261
197
  snapshot,
262
198
  mode: state,
263
- packageVersion: chunkBAOTUUTV_cjs.version,
199
+ packageVersion: chunkVREOANPX_cjs.version,
264
200
  measuredProjects: plan.value.measuredProjects,
265
201
  runConditions: plan.value.runConditions,
266
- warnings: [...warnings, ...plan.value.warnings, ...argvIssues]
202
+ warnings: [...warnings, ...argvIssues],
203
+ perfConfigPassed: perfConfig !== void 0
267
204
  });
268
205
  return plan.value.config;
269
206
  }
@@ -273,20 +210,21 @@ function passesOverride(state) {
273
210
  return state.passes === void 0 ? {} : { passes: state.passes };
274
211
  }
275
212
  var SETUP_DONE = /* @__PURE__ */ Symbol.for("playwright-performance-regression.mainProcessSetup");
276
- function mainProcessSetup(environmentMode) {
277
- if (!environmentMode || process.env.TEST_WORKER_INDEX !== void 0) return [];
213
+ function mainProcessSetup(mode) {
214
+ if (process.env.TEST_WORKER_INDEX !== void 0) return [];
278
215
  const store = globalThis;
279
216
  const done = store[SETUP_DONE];
280
217
  if (done !== void 0) return done;
281
- if ((process.env[chunkBAOTUUTV_cjs.RUN_ID_ENV] ?? "") === "") {
282
- process.env[chunkBAOTUUTV_cjs.RUN_ID_ENV] = chunkBAOTUUTV_cjs.generateRunId(/* @__PURE__ */ new Date(), Math.random);
218
+ if ((process.env[chunkVREOANPX_cjs.RUN_ID_ENV] ?? "") === "") {
219
+ process.env[chunkVREOANPX_cjs.RUN_ID_ENV] = chunkVREOANPX_cjs.generateRunId(/* @__PURE__ */ new Date(), Math.random);
283
220
  }
284
- const found = chunkBAOTUUTV_cjs.argvWarnings(process.argv, chunkBAOTUUTV_cjs.PACKAGE_NAME);
221
+ const found = chunkVREOANPX_cjs.argvWarnings(process.argv, chunkVREOANPX_cjs.PACKAGE_NAME, mode);
222
+ if (found.reporter !== null && mode !== "check") throw new chunkVREOANPX_cjs.ConfigError([found.reporter]);
285
223
  const report = [];
286
224
  for (const issue of [found.reporter, found.unsupported]) {
287
225
  if (issue === null) continue;
288
226
  process.stderr.write(
289
- `${chunkBAOTUUTV_cjs.PACKAGE_NAME}: warning ${issue.code}: ${issue.message}
227
+ `${chunkVREOANPX_cjs.PACKAGE_NAME}: warning ${issue.code}: ${issue.message}
290
228
  Hint: ${issue.hint}
291
229
  `
292
230
  );
@@ -298,6 +236,6 @@ function mainProcessSetup(environmentMode) {
298
236
 
299
237
  Object.defineProperty(exports, "definePerfConfig", {
300
238
  enumerable: true,
301
- get: function () { return chunk2JO5HVPC_cjs.definePerfConfig; }
239
+ get: function () { return chunkW7NEFS5V_cjs.definePerfConfig; }
302
240
  });
303
241
  exports.withPerf = withPerf;
package/dist/config.d.cts CHANGED
@@ -8,9 +8,8 @@ import { PlaywrightTestConfig } from '@playwright/test';
8
8
  * reporter and the fixtures of this process and returns a copy of `config` with the run
9
9
  * conditions of perf mode; invalid config or mode variables throw ConfigError before any test
10
10
  * runs. The returned config depends only on the arguments and the environment, so it is the same
11
- * in the main process and in the workers (01-REQ-09). Only in the main process of the
12
- * environment mode (no CLI) it sets PW_PERF_RUN_ID for the workers and warns about arguments
13
- * (04-REQ-60, 04-REQ-61).
11
+ * in the main process and in the workers (01-REQ-09). Only in the main process it sets
12
+ * PW_PERF_RUN_ID for the workers and warns about arguments (04-REQ-60, 04-REQ-61).
14
13
  */
15
14
  declare function withPerf<T extends PlaywrightTestConfig>(config: T, perfConfig?: PerfConfigInput): T;
16
15
 
package/dist/config.d.ts CHANGED
@@ -8,9 +8,8 @@ import { PlaywrightTestConfig } from '@playwright/test';
8
8
  * reporter and the fixtures of this process and returns a copy of `config` with the run
9
9
  * conditions of perf mode; invalid config or mode variables throw ConfigError before any test
10
10
  * runs. The returned config depends only on the arguments and the environment, so it is the same
11
- * in the main process and in the workers (01-REQ-09). Only in the main process of the
12
- * environment mode (no CLI) it sets PW_PERF_RUN_ID for the workers and warns about arguments
13
- * (04-REQ-60, 04-REQ-61).
11
+ * in the main process and in the workers (01-REQ-09). Only in the main process it sets
12
+ * PW_PERF_RUN_ID for the workers and warns about arguments (04-REQ-60, 04-REQ-61).
14
13
  */
15
14
  declare function withPerf<T extends PlaywrightTestConfig>(config: T, perfConfig?: PerfConfigInput): T;
16
15
 
package/dist/config.js CHANGED
@@ -1,7 +1,7 @@
1
- import { setRegistered } from './chunk-DYLCGMI2.js';
2
- import { readModeState, ConfigError, version, RUN_ID_ENV, generateRunId, argvWarnings, PACKAGE_NAME } from './chunk-DX36GFOZ.js';
3
- import { resolveConfig } from './chunk-AQ2XKYNV.js';
4
- export { definePerfConfig } from './chunk-AQ2XKYNV.js';
1
+ import { setRegistered } from './chunk-S6UH6QPK.js';
2
+ import { readModeState, ConfigError, version, RUN_ID_ENV, generateRunId, argvWarnings, PACKAGE_NAME } from './chunk-YKBX6SAT.js';
3
+ import { resolveConfig } from './chunk-5Y34Q4DR.js';
4
+ export { definePerfConfig } from './chunk-5Y34Q4DR.js';
5
5
 
6
6
  // src/config/reporter-path.ts
7
7
  function currentFile() {
@@ -24,12 +24,6 @@ var PACKAGE_REPORTER = `${PACKAGE_NAME}/reporter`;
24
24
  function projectName(project) {
25
25
  return project.name ?? "";
26
26
  }
27
- function browserOf(project, config) {
28
- return project?.use?.browserName ?? config.use?.browserName ?? project?.use?.defaultBrowserType ?? config.use?.defaultBrowserType ?? "chromium";
29
- }
30
- function quoted(names) {
31
- return names.map((name) => JSON.stringify(name)).join(", ");
32
- }
33
27
  function records(value) {
34
28
  if (value === void 0 || value === "off") return false;
35
29
  if (typeof value === "object" && value !== null && "mode" in value) return value.mode !== "off";
@@ -53,57 +47,14 @@ function andGrep(extra, own) {
53
47
  [...flags].sort().join("")
54
48
  );
55
49
  }
56
- function measuredNames(config, projects, option) {
57
- const names = projects.map(projectName);
58
- if (option !== "auto") {
59
- const known = new Set(names);
60
- const unknown = option.filter((name) => !known.has(name));
61
- if (unknown.length > 0) {
62
- const available = names.length === 0 || config.projects === void 0 ? "it has no projects, only the default one" : `its projects are ${quoted(names)}`;
63
- return {
64
- ok: false,
65
- issues: unknown.map((name) => ({
66
- code: "CONFIG_UNKNOWN_PROJECT",
67
- path: "run.projects",
68
- message: `run.projects: project ${JSON.stringify(name)} is not in the Playwright config; ${available}`,
69
- hint: 'Use project names from the Playwright config, or "auto".'
70
- }))
71
- };
72
- }
73
- return { ok: true, value: names.filter((name) => option.includes(name)) };
74
- }
50
+ function measurableProjects(projects) {
75
51
  const supporting = new Set(
76
52
  projects.flatMap((p) => [
77
53
  ...p.dependencies ?? [],
78
54
  ...p.teardown === void 0 ? [] : [p.teardown]
79
55
  ])
80
56
  );
81
- const measured = projects.filter((p) => !supporting.has(projectName(p)) && browserOf(p, config) === "chromium").map(projectName);
82
- if (measured.length > 0) return { ok: true, value: measured };
83
- return {
84
- ok: false,
85
- issues: [
86
- {
87
- code: "CONFIG_NO_MEASURED_PROJECT",
88
- path: "run.projects",
89
- message: 'run.projects: no project is measured; "auto" measures Chromium projects that are not a dependency or teardown of another project, and the Playwright config has none',
90
- hint: 'List the projects to measure in run.projects, e.g. ["firefox"].'
91
- }
92
- ]
93
- };
94
- }
95
- function projectsToKeep(projects, measured) {
96
- const byName = new Map(projects.map((p) => [projectName(p), p]));
97
- const keep = /* @__PURE__ */ new Set();
98
- const visit = (name) => {
99
- const project = byName.get(name);
100
- if (project === void 0 || keep.has(name)) return;
101
- keep.add(name);
102
- for (const dependency of project.dependencies ?? []) visit(dependency);
103
- if (project.teardown !== void 0) visit(project.teardown);
104
- };
105
- for (const name of measured) visit(name);
106
- return keep;
57
+ return projects.map(projectName).filter((name) => !supporting.has(name));
107
58
  }
108
59
  function reporterEntries(reporter) {
109
60
  if (reporter === void 0) return [];
@@ -138,7 +89,14 @@ function planReporters(reporter, input) {
138
89
  if (!deduped.some(([name]) => ours(name))) reporters.push([input.reporterPath]);
139
90
  return { reporters, removed, replaced };
140
91
  }
141
- function overriddenSettings(config, kept) {
92
+ function effectiveLaunchOptions(config, project) {
93
+ return project?.use?.launchOptions ?? config.use?.launchOptions;
94
+ }
95
+ function measuredLaunchOptions(config, measured) {
96
+ if (config.projects === void 0) return [config.use?.launchOptions];
97
+ return config.projects.filter((p) => measured.has(projectName(p))).map((p) => effectiveLaunchOptions(config, p));
98
+ }
99
+ function overriddenSettings(config, kept, slowMoOverridden) {
142
100
  const scopes = [config, ...kept];
143
101
  const repeatChanged = [config, ...kept].some(
144
102
  (scope) => scope.repeatEach !== void 0 && scope.repeatEach !== 1
@@ -151,46 +109,15 @@ function overriddenSettings(config, kept) {
151
109
  ...ARTIFACTS.map((name) => [
152
110
  name,
153
111
  scopes.some((scope) => records(scope.use?.[name]))
154
- ])
112
+ ]),
113
+ ["slowMo", slowMoOverridden]
155
114
  ];
156
115
  return changed.filter(([, value]) => value).map(([name]) => name);
157
116
  }
158
- function slowMoWarnings(config, kept) {
159
- const places = [
160
- ...positive(config.use?.launchOptions?.slowMo) ? ["the global config"] : [],
161
- ...kept.filter((p) => positive(p.use?.launchOptions?.slowMo)).map((p) => `project ${JSON.stringify(projectName(p))}`)
162
- ];
163
- if (places.length === 0) return [];
164
- return [
165
- {
166
- code: "CONFIG_SLOW_MO",
167
- path: "use.launchOptions.slowMo",
168
- message: `use.launchOptions.slowMo: is greater than 0 in ${places.join(", ")}; it slows down every browser action and distorts the measured times`,
169
- hint: "Remove slowMo from the Playwright config for the measurement run."
170
- }
171
- ];
172
- }
173
- function enginesWarnings(config, projects, measured) {
174
- const byName = new Map(projects.map((p) => [projectName(p), p]));
175
- const engines = [...new Set(measured.map((name) => browserOf(byName.get(name), config)))];
176
- if (engines.length < 2) return [];
177
- return [
178
- {
179
- code: "CONFIG_MULTIPLE_ENGINES",
180
- path: "run.projects",
181
- message: `run.projects: the measured projects use more than one browser engine (${engines.join(", ")}); their samples go to the same keys`,
182
- hint: "Measure one browser engine per run: list projects of one engine in run.projects."
183
- }
184
- ];
185
- }
186
117
  function planPerfRun(config, input) {
187
118
  const source = config;
188
119
  const projects = source.projects ?? [{}];
189
- const measured = measuredNames(source, projects, input.projects);
190
- if (!measured.ok) return measured;
191
- const keep = projectsToKeep(projects, measured.value);
192
- const kept = source.projects === void 0 ? [] : projects.filter((p) => keep.has(projectName(p)));
193
- const removedProjects = source.projects === void 0 ? [] : projects.filter((p) => !keep.has(projectName(p))).map(projectName);
120
+ const measured = measurableProjects(projects);
194
121
  const { reporters, removed, replaced } = planReporters(source.reporter, input);
195
122
  const result = {
196
123
  ...source,
@@ -202,33 +129,41 @@ function planPerfRun(config, input) {
202
129
  };
203
130
  result.repeatEach = 1;
204
131
  const grep = input.grep ?? null;
132
+ const overrideSlowMo = input.overrideSlowMo ?? false;
133
+ const kept = source.projects ?? [];
134
+ const measuredSet = new Set(measured);
205
135
  if (source.projects !== void 0) {
206
- const measuredSet = new Set(measured.value);
207
136
  result.projects = kept.map((p) => {
208
137
  const project = { ...p, repeatEach: 1, use: artifactsOff(p.use) };
209
- if (grep !== null && measuredSet.has(projectName(p))) {
138
+ const isMeasured = measuredSet.has(projectName(p));
139
+ if (grep !== null && isMeasured) {
210
140
  project.grep = andGrep(grep, p.grep ?? source.grep);
211
141
  }
142
+ if (overrideSlowMo && isMeasured) {
143
+ project.use = {
144
+ ...project.use,
145
+ launchOptions: { ...effectiveLaunchOptions(source, p), slowMo: 0 }
146
+ };
147
+ }
212
148
  return project;
213
149
  });
214
- } else if (grep !== null) {
215
- result.grep = andGrep(grep, source.grep);
150
+ } else {
151
+ if (grep !== null) result.grep = andGrep(grep, source.grep);
152
+ if (overrideSlowMo) {
153
+ result.use = { ...result.use, launchOptions: { ...source.use?.launchOptions, slowMo: 0 } };
154
+ }
216
155
  }
156
+ const slowMoOverridden = overrideSlowMo && measuredLaunchOptions(source, measuredSet).some((options) => positive(options?.slowMo));
217
157
  return {
218
158
  ok: true,
219
159
  value: {
220
160
  config: result,
221
- measuredProjects: measured.value,
161
+ measuredProjects: measured,
222
162
  runConditions: {
223
- overridden: overriddenSettings(source, kept),
224
- removedProjects,
163
+ overridden: overriddenSettings(source, kept, slowMoOverridden),
225
164
  removedReporters: removed,
226
165
  replacedReporters: replaced
227
- },
228
- warnings: [
229
- ...enginesWarnings(source, projects, measured.value),
230
- ...slowMoWarnings(source, kept)
231
- ]
166
+ }
232
167
  }
233
168
  };
234
169
  }
@@ -238,24 +173,25 @@ function withPerf(config, perfConfig) {
238
173
  const first = readModeState(process.env);
239
174
  if (!first.ok) throw new ConfigError(first.issues);
240
175
  if (first.value === null) return config;
241
- const argvIssues = mainProcessSetup(first.value.outcomeFile === void 0);
176
+ const argvIssues = mainProcessSetup(first.value.mode);
242
177
  const mode = readModeState(process.env);
243
178
  if (!mode.ok || mode.value === null) throw new Error("withPerf: the mode state changed");
244
179
  const state = mode.value;
245
180
  const resolved = resolveConfig(perfConfig, {
246
181
  mode: state.mode === "check" ? "test" : state.mode,
247
182
  ...passesOverride(state),
248
- ...state.env === void 0 ? {} : { env: state.env }
183
+ ...state.env === void 0 ? {} : { env: state.env },
184
+ ...state.thresholdsDir === void 0 ? {} : { thresholdsDir: state.thresholdsDir },
185
+ ...state.minSamples === void 0 ? {} : { minSamples: state.minSamples }
249
186
  });
250
187
  if (!resolved.ok) throw new ConfigError(resolved.issues);
251
188
  const { config: perf, snapshot, warnings } = resolved.value;
252
189
  const plan = planPerfRun(config, {
253
- projects: perf.run.projects,
254
190
  keepReporters: perf.run.keepReporters,
255
191
  grep: perf.run.grep,
192
+ overrideSlowMo: perf.run.overrideSlowMo,
256
193
  reporterPath: reporterEntryPath()
257
194
  });
258
- if (!plan.ok) throw new ConfigError(plan.issues);
259
195
  setRegistered({
260
196
  config: perf,
261
197
  snapshot,
@@ -263,7 +199,8 @@ function withPerf(config, perfConfig) {
263
199
  packageVersion: version,
264
200
  measuredProjects: plan.value.measuredProjects,
265
201
  runConditions: plan.value.runConditions,
266
- warnings: [...warnings, ...plan.value.warnings, ...argvIssues]
202
+ warnings: [...warnings, ...argvIssues],
203
+ perfConfigPassed: perfConfig !== void 0
267
204
  });
268
205
  return plan.value.config;
269
206
  }
@@ -273,15 +210,16 @@ function passesOverride(state) {
273
210
  return state.passes === void 0 ? {} : { passes: state.passes };
274
211
  }
275
212
  var SETUP_DONE = /* @__PURE__ */ Symbol.for("playwright-performance-regression.mainProcessSetup");
276
- function mainProcessSetup(environmentMode) {
277
- if (!environmentMode || process.env.TEST_WORKER_INDEX !== void 0) return [];
213
+ function mainProcessSetup(mode) {
214
+ if (process.env.TEST_WORKER_INDEX !== void 0) return [];
278
215
  const store = globalThis;
279
216
  const done = store[SETUP_DONE];
280
217
  if (done !== void 0) return done;
281
218
  if ((process.env[RUN_ID_ENV] ?? "") === "") {
282
219
  process.env[RUN_ID_ENV] = generateRunId(/* @__PURE__ */ new Date(), Math.random);
283
220
  }
284
- const found = argvWarnings(process.argv, PACKAGE_NAME);
221
+ const found = argvWarnings(process.argv, PACKAGE_NAME, mode);
222
+ if (found.reporter !== null && mode !== "check") throw new ConfigError([found.reporter]);
285
223
  const report = [];
286
224
  for (const issue of [found.reporter, found.unsupported]) {
287
225
  if (issue === null) continue;
package/dist/fixture.cjs CHANGED
@@ -1,16 +1,20 @@
1
1
  'use strict';
2
2
 
3
- var chunk44ASXVQN_cjs = require('./chunk-44ASXVQN.cjs');
4
- require('./chunk-BAOTUUTV.cjs');
5
- require('./chunk-2JO5HVPC.cjs');
3
+ var chunkPWK5XSP2_cjs = require('./chunk-PWK5XSP2.cjs');
4
+ require('./chunk-VREOANPX.cjs');
5
+ require('./chunk-W7NEFS5V.cjs');
6
6
 
7
7
 
8
8
 
9
9
  Object.defineProperty(exports, "trackContext", {
10
10
  enumerable: true,
11
- get: function () { return chunk44ASXVQN_cjs.trackContext; }
11
+ get: function () { return chunkPWK5XSP2_cjs.trackContext; }
12
+ });
13
+ Object.defineProperty(exports, "trackRequestContext", {
14
+ enumerable: true,
15
+ get: function () { return chunkPWK5XSP2_cjs.trackRequestContext; }
12
16
  });
13
17
  Object.defineProperty(exports, "withPerfFixtures", {
14
18
  enumerable: true,
15
- get: function () { return chunk44ASXVQN_cjs.withPerfFixtures; }
19
+ get: function () { return chunkPWK5XSP2_cjs.withPerfFixtures; }
16
20
  });
@@ -1,6 +1,6 @@
1
- import { TestType, BrowserContext } from '@playwright/test';
2
- import { P as PerfFixtures } from './perf-api-Rm1h1O_-.cjs';
3
- export { a as PerfApi } from './perf-api-Rm1h1O_-.cjs';
1
+ import { TestType, BrowserContext, APIRequestContext } from '@playwright/test';
2
+ import { P as PerfFixtures } from './perf-api-2DH_keLh.cjs';
3
+ export { a as PerfApi } from './perf-api-2DH_keLh.cjs';
4
4
 
5
5
  /** `base` with the `perf` fixture added; other fixtures and options keep their types. */
6
6
  type PerfTestType<T> = T extends TestType<infer TestArgs, infer WorkerArgs> ? TestType<TestArgs & PerfFixtures, WorkerArgs> : never;
@@ -17,6 +17,12 @@ declare function withPerfFixtures<T extends TestType<any, any>>(base: T): PerfTe
17
17
  * outside perf mode.
18
18
  */
19
19
  declare function trackContext(context: BrowserContext): void;
20
+ /**
21
+ * Measures the calls of an APIRequestContext created with playwright.request.newContext(), also
22
+ * in a worker-scoped fixture (15-REQ-03): each call made during a test of a measured project is
23
+ * recorded by that test. Does nothing outside perf mode or with measure.api off.
24
+ */
25
+ declare function trackRequestContext(requestContext: APIRequestContext): void;
20
26
 
21
- export { PerfFixtures, trackContext, withPerfFixtures };
27
+ export { PerfFixtures, trackContext, trackRequestContext, withPerfFixtures };
22
28
  export type { PerfTestType };
package/dist/fixture.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { TestType, BrowserContext } from '@playwright/test';
2
- import { P as PerfFixtures } from './perf-api-Rm1h1O_-.js';
3
- export { a as PerfApi } from './perf-api-Rm1h1O_-.js';
1
+ import { TestType, BrowserContext, APIRequestContext } from '@playwright/test';
2
+ import { P as PerfFixtures } from './perf-api-2DH_keLh.js';
3
+ export { a as PerfApi } from './perf-api-2DH_keLh.js';
4
4
 
5
5
  /** `base` with the `perf` fixture added; other fixtures and options keep their types. */
6
6
  type PerfTestType<T> = T extends TestType<infer TestArgs, infer WorkerArgs> ? TestType<TestArgs & PerfFixtures, WorkerArgs> : never;
@@ -17,6 +17,12 @@ declare function withPerfFixtures<T extends TestType<any, any>>(base: T): PerfTe
17
17
  * outside perf mode.
18
18
  */
19
19
  declare function trackContext(context: BrowserContext): void;
20
+ /**
21
+ * Measures the calls of an APIRequestContext created with playwright.request.newContext(), also
22
+ * in a worker-scoped fixture (15-REQ-03): each call made during a test of a measured project is
23
+ * recorded by that test. Does nothing outside perf mode or with measure.api off.
24
+ */
25
+ declare function trackRequestContext(requestContext: APIRequestContext): void;
20
26
 
21
- export { PerfFixtures, trackContext, withPerfFixtures };
27
+ export { PerfFixtures, trackContext, trackRequestContext, withPerfFixtures };
22
28
  export type { PerfTestType };
package/dist/fixture.js CHANGED
@@ -1,4 +1,4 @@
1
- export { trackContext, withPerfFixtures } from './chunk-MUZFQKGQ.js';
2
- import './chunk-DYLCGMI2.js';
3
- import './chunk-DX36GFOZ.js';
4
- import './chunk-AQ2XKYNV.js';
1
+ export { trackContext, trackRequestContext, withPerfFixtures } from './chunk-4WX3Z5MJ.js';
2
+ import './chunk-S6UH6QPK.js';
3
+ import './chunk-YKBX6SAT.js';
4
+ import './chunk-5Y34Q4DR.js';