playwright 1.62.1 → 1.65.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.
@@ -52,53 +52,140 @@ __export(testRunner_exports, {
52
52
  TestRunnerEvent: () => TestRunnerEvent,
53
53
  runAllTestsWithConfig: () => runAllTestsWithConfig
54
54
  });
55
- var import_events2 = __toESM(require("events"));
56
- var import_fs13 = __toESM(require("fs"));
57
- var import_path17 = __toESM(require("path"));
58
- var import_coreBundle2 = require("playwright-core/lib/coreBundle");
55
+ var import_events3 = __toESM(require("events"));
56
+ var import_coreBundle3 = require("playwright-core/lib/coreBundle");
59
57
  var import_common10 = require("../common");
60
58
 
61
59
  // packages/playwright/src/runner/fsWatcher.ts
62
- var chokidar = require("playwright-core/lib/utilsBundle").chokidar;
60
+ var import_fs = __toESM(require("fs"));
61
+ var import_path = __toESM(require("path"));
62
+ var kNativeRecursiveWatch = process.platform === "darwin" || process.platform === "win32";
63
63
  var FSWatcher = class {
64
64
  constructor(onChange) {
65
- this._watchedPaths = [];
66
- this._ignoredFolders = [];
67
- this._collector = [];
65
+ this._params = { paths: [], ignoredFolders: [] };
66
+ this._watchedFiles = /* @__PURE__ */ new Set();
67
+ this._watchers = /* @__PURE__ */ new Map();
68
+ this._collector = /* @__PURE__ */ new Set();
68
69
  this._onChange = onChange;
69
70
  }
70
- async update(watchedPaths, ignoredFolders, reportPending) {
71
- if (JSON.stringify([this._watchedPaths, this._ignoredFolders]) === JSON.stringify([watchedPaths, ignoredFolders]))
71
+ async update(params, reportPending) {
72
+ if (JSON.stringify(this._params) === JSON.stringify(params))
72
73
  return;
73
74
  if (reportPending)
74
75
  this._reportEventsIfAny();
75
- this._watchedPaths = watchedPaths;
76
- this._ignoredFolders = ignoredFolders;
77
- void this._fsWatcher?.close();
78
- this._fsWatcher = void 0;
79
- this._collector.length = 0;
76
+ this._params = params;
77
+ this._closeAll();
78
+ this._collector.clear();
80
79
  clearTimeout(this._throttleTimer);
81
80
  this._throttleTimer = void 0;
82
- if (!this._watchedPaths.length)
83
- return;
84
- const ignored = [...this._ignoredFolders, "**/node_modules/**"];
85
- this._fsWatcher = chokidar.watch(watchedPaths, { ignoreInitial: true, ignored }).on("all", async (event, file) => {
86
- if (this._throttleTimer)
87
- clearTimeout(this._throttleTimer);
88
- this._collector.push({ event, file });
89
- this._throttleTimer = setTimeout(() => this._reportEventsIfAny(), 250);
90
- });
91
- await new Promise((resolve, reject) => this._fsWatcher.once("ready", resolve).once("error", reject));
81
+ const paths = params.paths.map((p) => p.length > 1 && p.endsWith(import_path.default.sep) ? p.slice(0, -1) : p);
82
+ const dirs = new Set(paths.filter((p) => isDirectory(p)));
83
+ const isCovered = (p) => [...dirs].some((dir) => isInside(dir, p));
84
+ for (const dir of dirs) {
85
+ if (isCovered(dir))
86
+ continue;
87
+ if (kNativeRecursiveWatch)
88
+ this._watch(dir, true, (file) => this._onDirEvent(file));
89
+ else
90
+ this._watchTree(dir);
91
+ }
92
+ this._watchedFiles = new Set(paths.filter((p) => !dirs.has(p) && !isCovered(p)));
93
+ for (const dir of new Set([...this._watchedFiles].map((file) => import_path.default.dirname(file))))
94
+ this._watch(dir, false, (file) => this._onFileEvent(file));
92
95
  }
93
96
  async close() {
94
- await this._fsWatcher?.close();
97
+ this._closeAll();
98
+ clearTimeout(this._throttleTimer);
99
+ this._throttleTimer = void 0;
100
+ }
101
+ _watch(dir, recursive, onEvent) {
102
+ if (this._watchers.has(dir))
103
+ return;
104
+ try {
105
+ const watcher = import_fs.default.watch(dir, { persistent: true, recursive }, (eventType, filename) => {
106
+ onEvent(filename ? import_path.default.join(dir, filename) : dir);
107
+ });
108
+ watcher.on("error", () => this._close(dir));
109
+ this._watchers.set(dir, watcher);
110
+ } catch {
111
+ }
112
+ }
113
+ _watchTree(dir) {
114
+ if (this._isIgnored(dir) || this._watchers.has(dir))
115
+ return;
116
+ this._watch(dir, false, (file) => this._onTreeEvent(file));
117
+ if (!this._watchers.has(dir))
118
+ return;
119
+ let entries = [];
120
+ try {
121
+ entries = import_fs.default.readdirSync(dir, { withFileTypes: true });
122
+ } catch {
123
+ }
124
+ for (const entry of entries) {
125
+ if (entry.isDirectory())
126
+ this._watchTree(import_path.default.join(dir, entry.name));
127
+ }
128
+ }
129
+ _onDirEvent(file) {
130
+ if (!this._isIgnored(file))
131
+ this._collect(file);
132
+ }
133
+ _onTreeEvent(file) {
134
+ if (this._isIgnored(file))
135
+ return;
136
+ this._collect(file);
137
+ if (this._watchers.has(file)) {
138
+ if (!isDirectory(file))
139
+ this._closeTree(file);
140
+ } else if (isDirectory(file)) {
141
+ this._watchTree(file);
142
+ }
143
+ }
144
+ _onFileEvent(file) {
145
+ if (this._watchedFiles.has(file))
146
+ this._collect(file);
147
+ }
148
+ _isIgnored(file) {
149
+ if (file.split(import_path.default.sep).includes("node_modules"))
150
+ return true;
151
+ return this._params.ignoredFolders.some((folder) => file === folder || isInside(folder, file));
152
+ }
153
+ _collect(file) {
154
+ this._collector.add(file);
155
+ clearTimeout(this._throttleTimer);
156
+ this._throttleTimer = setTimeout(() => this._reportEventsIfAny(), 250);
95
157
  }
96
158
  _reportEventsIfAny() {
97
- if (this._collector.length)
98
- this._onChange(this._collector.slice());
99
- this._collector.length = 0;
159
+ if (this._collector.size)
160
+ this._onChange([...this._collector]);
161
+ this._collector.clear();
162
+ }
163
+ _close(dir) {
164
+ this._watchers.get(dir)?.close();
165
+ this._watchers.delete(dir);
166
+ }
167
+ _closeTree(dir) {
168
+ for (const watched of [...this._watchers.keys()]) {
169
+ if (watched === dir || isInside(dir, watched))
170
+ this._close(watched);
171
+ }
172
+ }
173
+ _closeAll() {
174
+ for (const watcher of this._watchers.values())
175
+ watcher.close();
176
+ this._watchers.clear();
100
177
  }
101
178
  };
179
+ function isInside(dir, file) {
180
+ return file.startsWith(dir + import_path.default.sep);
181
+ }
182
+ function isDirectory(file) {
183
+ try {
184
+ return import_fs.default.lstatSync(file).isDirectory();
185
+ } catch {
186
+ return false;
187
+ }
188
+ }
102
189
 
103
190
  // packages/playwright/src/isomorphic/teleReceiver.ts
104
191
  var TeleReporterReceiver = class {
@@ -131,10 +218,6 @@ var TeleReporterReceiver = class {
131
218
  this._onTestBegin(params.testId, params.result);
132
219
  return;
133
220
  }
134
- if (method === "onTestPaused") {
135
- this._onTestPaused(params.testId, params.resultId, params.errors);
136
- return;
137
- }
138
221
  if (method === "onTestEnd") {
139
222
  this._onTestEnd(params.test, params.result);
140
223
  return;
@@ -201,13 +284,6 @@ var TeleReporterReceiver = class {
201
284
  testResult.setStartTimeNumber(payload.startTime);
202
285
  this._reporter.onTestBegin?.(test, testResult);
203
286
  }
204
- _onTestPaused(testId, resultId, errors) {
205
- const test = this._tests.get(testId);
206
- const result = test.results.find((r) => r._id === resultId);
207
- result.errors.push(...errors);
208
- result.error = result.errors[0];
209
- void this._reporter.onTestPaused?.(test, result);
210
- }
211
287
  _onTestEnd(testEndPayload, payload) {
212
288
  const test = this._tests.get(testEndPayload.testId);
213
289
  test.timeout = testEndPayload.timeout;
@@ -498,7 +574,9 @@ var TeleTestStep = class {
498
574
  this.steps = [];
499
575
  this._startTime = 0;
500
576
  this.title = payload.title;
577
+ this.subtitle = payload.subtitle;
501
578
  this.category = payload.category;
579
+ this.params = payload.params;
502
580
  this.location = location;
503
581
  this.parent = parentStep;
504
582
  this._startTime = payload.startTime;
@@ -562,6 +640,7 @@ var baseFullConfig = {
562
640
  metadata: {},
563
641
  preserveOutput: "always",
564
642
  projects: [],
643
+ filteredProjects: [],
565
644
  reporter: [[process.env.CI ? "dot" : "list"]],
566
645
  reportSlowTests: {
567
646
  max: 5,
@@ -573,7 +652,7 @@ var baseFullConfig = {
573
652
  quiet: false,
574
653
  shard: null,
575
654
  tags: [],
576
- updateSnapshots: "missing",
655
+ updateSnapshots: "default",
577
656
  updateSourceMethod: "patch",
578
657
  version: "",
579
658
  workers: 0,
@@ -597,7 +676,7 @@ function parseRegexPatterns(patterns) {
597
676
  }
598
677
  function computeTestCaseOutcome(test) {
599
678
  let skipped = 0;
600
- let didNotRun = 0;
679
+ let didNotRun2 = 0;
601
680
  let expected = 0;
602
681
  let interrupted = 0;
603
682
  let unexpected = 0;
@@ -607,7 +686,7 @@ function computeTestCaseOutcome(test) {
607
686
  } else if (result.status === "skipped" && test.expectedStatus === "skipped") {
608
687
  ++skipped;
609
688
  } else if (result.status === "skipped") {
610
- ++didNotRun;
689
+ ++didNotRun2;
611
690
  } else if (result.status === test.expectedStatus) {
612
691
  ++expected;
613
692
  } else {
@@ -634,8 +713,7 @@ function asFullConfig(config2) {
634
713
  }
635
714
 
636
715
  // packages/playwright/src/plugins/gitCommitInfoPlugin.ts
637
- var fs = __toESM(require("fs"));
638
- var { monotonicTime } = require("playwright-core/lib/coreBundle").iso;
716
+ var fs2 = __toESM(require("fs"));
639
717
  var { spawnAsync } = require("playwright-core/lib/coreBundle").utils;
640
718
  var GIT_OPERATIONS_TIMEOUT_MS = 3e3;
641
719
  var addGitCommitInfoPlugin = (fullConfig) => {
@@ -680,7 +758,7 @@ async function ciInfo() {
680
758
  if (process.env.GITHUB_ACTIONS) {
681
759
  let pr;
682
760
  try {
683
- const json = JSON.parse(await fs.promises.readFile(process.env.GITHUB_EVENT_PATH, "utf8"));
761
+ const json = JSON.parse(await fs2.promises.readFile(process.env.GITHUB_EVENT_PATH, "utf8"));
684
762
  pr = { title: json.pull_request.title, number: json.pull_request.number, baseHash: json.pull_request.base.sha };
685
763
  } catch {
686
764
  }
@@ -759,7 +837,14 @@ async function gitCommitInfo(gitDir) {
759
837
  async function gitDiff(gitDir, ci) {
760
838
  const diffLimit = 1e5;
761
839
  if (ci?.prBaseHash) {
762
- await runGit(["fetch", "origin", ci.prBaseHash, "--depth=1", "--no-auto-maintenance", "--no-auto-gc", "--no-tags", "--no-recurse-submodules"], gitDir);
840
+ const hasBaseCommit = await runGit(["cat-file", "-e", `${ci.prBaseHash}^{commit}`], gitDir) !== void 0;
841
+ if (!hasBaseCommit) {
842
+ const isShallow = await runGit(["rev-parse", "--is-shallow-repository"], gitDir) === "true";
843
+ const fetchArgs = ["fetch", "origin", ci.prBaseHash, "--no-auto-maintenance", "--no-auto-gc", "--no-tags", "--no-recurse-submodules"];
844
+ if (isShallow)
845
+ fetchArgs.push("--depth=1");
846
+ await runGit(fetchArgs, gitDir);
847
+ }
763
848
  const diff3 = await runGit(["diff", ci.prBaseHash, "HEAD"], gitDir);
764
849
  if (diff3)
765
850
  return diff3.substring(0, diffLimit);
@@ -777,13 +862,13 @@ async function gitDiff(gitDir, ci) {
777
862
  }
778
863
  async function runGit(args, cwd) {
779
864
  debug(`running "git ${args.join(" ")}"`);
780
- const start = monotonicTime();
781
- const result = await spawnAsync(
782
- "git",
783
- args,
784
- { stdio: "pipe", cwd, timeout: GIT_OPERATIONS_TIMEOUT_MS }
785
- );
786
- if (monotonicTime() - start > GIT_OPERATIONS_TIMEOUT_MS) {
865
+ const result = await spawnAsync("git", ["-c", "credential.interactive=false", ...args], {
866
+ stdio: "pipe",
867
+ cwd,
868
+ timeout: GIT_OPERATIONS_TIMEOUT_MS,
869
+ env: { ...process.env, GIT_TERMINAL_PROMPT: "0" }
870
+ });
871
+ if (result.timedOut) {
787
872
  print(`timeout of ${GIT_OPERATIONS_TIMEOUT_MS}ms exceeded while running "git ${args.join(" ")}"`);
788
873
  return;
789
874
  }
@@ -798,12 +883,12 @@ ${result.stderr}`);
798
883
 
799
884
  // packages/playwright/src/plugins/webServerPlugin.ts
800
885
  var import_net = __toESM(require("net"));
801
- var import_path = __toESM(require("path"));
886
+ var import_path2 = __toESM(require("path"));
802
887
  var import_util = require("util");
803
888
  var colors = require("playwright-core/lib/utilsBundle").colors;
804
889
  var debug2 = require("playwright-core/lib/utilsBundle").debug;
805
890
  var { ManualPromise } = require("playwright-core/lib/coreBundle").iso;
806
- var { monotonicTime: monotonicTime2 } = require("playwright-core/lib/coreBundle").iso;
891
+ var { monotonicTime } = require("playwright-core/lib/coreBundle").iso;
807
892
  var { raceAgainstDeadline } = require("playwright-core/lib/coreBundle").iso;
808
893
  var { isURLAvailable } = require("playwright-core/lib/coreBundle").utils;
809
894
  var { launchProcess } = require("playwright-core/lib/coreBundle").utils;
@@ -824,7 +909,7 @@ var WebServerPlugin = class {
824
909
  this._reporter = reporter;
825
910
  if (this._options.url)
826
911
  this._isAvailableCallback = getIsAvailableFunction(this._options.url, this._checkPortOnly, !!this._options.ignoreHTTPSErrors, this._reporter.onStdErr?.bind(this._reporter));
827
- this._options.cwd = this._options.cwd ? import_path.default.resolve(configDir, this._options.cwd) : configDir;
912
+ this._options.cwd = this._options.cwd ? import_path2.default.resolve(configDir, this._options.cwd) : configDir;
828
913
  try {
829
914
  await this._startProcess();
830
915
  await this._waitForProcess();
@@ -928,7 +1013,7 @@ var WebServerPlugin = class {
928
1013
  debugWebServer(`Waiting for availability...`);
929
1014
  const launchTimeout = this._options.timeout || 60 * 1e3;
930
1015
  const cancellationToken = { canceled: false };
931
- const deadline = monotonicTime2() + launchTimeout;
1016
+ const deadline = monotonicTime() + launchTimeout;
932
1017
  const racingPromises = [this._processExitedPromise];
933
1018
  if (this._isAvailableCallback)
934
1019
  racingPromises.push(raceAgainstDeadline(() => waitFor(this._isAvailableCallback, cancellationToken), deadline));
@@ -1014,29 +1099,32 @@ function prefixOutputLines(output, prefixName = "WebServer") {
1014
1099
  var base_exports = {};
1015
1100
  __export(base_exports, {
1016
1101
  TerminalReporter: () => TerminalReporter,
1102
+ createTestFilter: () => createTestFilter,
1103
+ filterTests: () => filterTests,
1017
1104
  formatError: () => formatError,
1018
1105
  formatFailure: () => formatFailure,
1019
1106
  formatResultFailure: () => formatResultFailure,
1020
1107
  formatRetry: () => formatRetry,
1021
1108
  internalScreen: () => internalScreen,
1109
+ isFailure: () => isFailure,
1022
1110
  kOutputSymbol: () => kOutputSymbol,
1023
- markErrorsAsReported: () => markErrorsAsReported,
1024
1111
  nonTerminalScreen: () => nonTerminalScreen,
1025
1112
  prepareErrorStack: () => prepareErrorStack,
1026
1113
  relativeFilePath: () => relativeFilePath,
1027
1114
  resolveOutputFile: () => resolveOutputFile,
1028
1115
  separator: () => separator,
1029
1116
  stepSuffix: () => stepSuffix,
1030
- terminalScreen: () => terminalScreen
1117
+ terminalScreen: () => terminalScreen,
1118
+ visitTests: () => visitTests
1031
1119
  });
1032
- var import_path2 = __toESM(require("path"));
1120
+ var import_path3 = __toESM(require("path"));
1033
1121
  var import_stream = require("stream");
1034
1122
  var import_util2 = require("../util");
1035
1123
  var realColors = require("playwright-core/lib/utilsBundle").colors;
1036
1124
  var { noColors } = require("playwright-core/lib/coreBundle").iso;
1037
1125
  var { msToString } = require("playwright-core/lib/coreBundle").iso;
1038
1126
  var { parseErrorStack } = require("playwright-core/lib/coreBundle").utils;
1039
- var { getPackageManagerExecCommand } = require("playwright-core/lib/coreBundle").utils;
1127
+ var { getAsBooleanFromENV, getPackageManagerExecCommand } = require("playwright-core/lib/coreBundle").utils;
1040
1128
  var { fitToWidth } = require("playwright-core/lib/coreBundle").utils;
1041
1129
  var kOutputSymbol = /* @__PURE__ */ Symbol("output");
1042
1130
  var DEFAULT_TTY_WIDTH = 100;
@@ -1167,9 +1255,10 @@ var TerminalReporter = class {
1167
1255
  generateStartingMessage() {
1168
1256
  const jobs = this.config.metadata.actualWorkers ?? this.config.workers;
1169
1257
  const shardDetails = this.config.shard ? `, shard ${this.config.shard.current} of ${this.config.shard.total}` : "";
1258
+ const shuffleDetails = this.config.metadata.shuffleSeed ? `, shuffle seed ${this.config.metadata.shuffleSeed}` : "";
1170
1259
  if (!this.totalTestCount)
1171
1260
  return "";
1172
- return "\n" + this.screen.colors.dim("Running ") + this.totalTestCount + this.screen.colors.dim(` test${this.totalTestCount !== 1 ? "s" : ""} using `) + jobs + this.screen.colors.dim(` worker${jobs !== 1 ? "s" : ""}${shardDetails}`);
1261
+ return "\n" + this.screen.colors.dim("Running ") + this.totalTestCount + this.screen.colors.dim(` test${this.totalTestCount !== 1 ? "s" : ""} using `) + jobs + this.screen.colors.dim(` worker${jobs !== 1 ? "s" : ""}${shardDetails}${shuffleDetails}`);
1173
1262
  }
1174
1263
  getSlowTests() {
1175
1264
  if (!this.config.reportSlowTests)
@@ -1180,7 +1269,7 @@ var TerminalReporter = class {
1180
1269
  const threshold = this.config.reportSlowTests.threshold;
1181
1270
  return fileDurations.filter(([, duration]) => duration > threshold).slice(0, count);
1182
1271
  }
1183
- generateSummaryMessage({ didNotRun, skipped, expected, interrupted, unexpected, flaky, fatalErrors }) {
1272
+ generateSummaryMessage({ didNotRun: didNotRun2, skipped, expected, interrupted, unexpected, flaky, fatalErrors }) {
1184
1273
  const tokens = [];
1185
1274
  if (unexpected.length) {
1186
1275
  tokens.push(this.screen.colors.red(` ${unexpected.length} failed`));
@@ -1199,8 +1288,8 @@ var TerminalReporter = class {
1199
1288
  }
1200
1289
  if (skipped)
1201
1290
  tokens.push(this.screen.colors.yellow(` ${skipped} skipped`));
1202
- if (didNotRun)
1203
- tokens.push(this.screen.colors.yellow(` ${didNotRun} did not run`));
1291
+ if (didNotRun2)
1292
+ tokens.push(this.screen.colors.yellow(` ${didNotRun2} did not run`));
1204
1293
  if (expected)
1205
1294
  tokens.push(this.screen.colors.green(` ${expected} passed`) + this.screen.colors.dim(` (${msToString(this.result.duration)})`));
1206
1295
  if (fatalErrors.length && expected + unexpected.length + interrupted.length + flaky.length > 0)
@@ -1208,7 +1297,7 @@ var TerminalReporter = class {
1208
1297
  return tokens.join("\n");
1209
1298
  }
1210
1299
  generateSummary() {
1211
- let didNotRun = 0;
1300
+ let didNotRun2 = 0;
1212
1301
  let skipped = 0;
1213
1302
  let expected = 0;
1214
1303
  const interrupted = [];
@@ -1223,7 +1312,7 @@ var TerminalReporter = class {
1223
1312
  interruptedToPrint.push(test);
1224
1313
  interrupted.push(test);
1225
1314
  } else if (!test.results.length || test.expectedStatus !== "skipped") {
1226
- ++didNotRun;
1315
+ ++didNotRun2;
1227
1316
  } else {
1228
1317
  ++skipped;
1229
1318
  }
@@ -1242,7 +1331,7 @@ var TerminalReporter = class {
1242
1331
  });
1243
1332
  const failuresToPrint = [...unexpected, ...flaky, ...interruptedToPrint];
1244
1333
  return {
1245
- didNotRun,
1334
+ didNotRun: didNotRun2,
1246
1335
  skipped,
1247
1336
  expected,
1248
1337
  interrupted,
@@ -1285,7 +1374,7 @@ var TerminalReporter = class {
1285
1374
  return formatTestTitle(this.screen, this.config, test, step, this._options);
1286
1375
  }
1287
1376
  formatTestHeader(test, options = {}) {
1288
- return formatTestHeader(this.screen, this.config, test, { ...options, includeTestId: this._options.includeTestId });
1377
+ return formatTestHeader(this.screen, this.config, test, { ...options, includeTestId: this._options.includeTestId, omitTags: this._options.omitTags });
1289
1378
  }
1290
1379
  formatFailure(test, index) {
1291
1380
  return formatFailure(this.screen, this.config, test, index, this._options);
@@ -1300,6 +1389,25 @@ var TerminalReporter = class {
1300
1389
  this.screen.stdout?.write(line ? line + "\n" : "\n");
1301
1390
  }
1302
1391
  };
1392
+ function isFailure(test) {
1393
+ const outcome = test.outcome();
1394
+ return outcome === "unexpected" || outcome === "flaky" || test.results.some((result) => result.status === "interrupted");
1395
+ }
1396
+ function createTestFilter(options, reporterName) {
1397
+ const onlyFailures = options._mode !== "list" && getAsBooleanFromENV(`PLAYWRIGHT_${reporterName}_ONLY_FAILURES`, !!options.onlyFailures);
1398
+ return onlyFailures ? isFailure : void 0;
1399
+ }
1400
+ function* visitTests(suite, filter) {
1401
+ for (const entry of suite.entries()) {
1402
+ if (entry.type !== "test")
1403
+ yield* visitTests(entry, filter);
1404
+ else if (!filter || filter(entry))
1405
+ yield entry;
1406
+ }
1407
+ }
1408
+ function filterTests(entries, filter) {
1409
+ return filter ? entries.filter((entry) => entry.type === "test" ? filter(entry) : !visitTests(entry, filter).next().done) : entries;
1410
+ }
1303
1411
  function formatResultErrors(screen, test, result) {
1304
1412
  const lines = [];
1305
1413
  if (test.outcome() === "unexpected") {
@@ -1314,13 +1422,14 @@ function formatResultErrors(screen, test, result) {
1314
1422
  function formatFailure(screen, config2, test, index, options) {
1315
1423
  const lines = [];
1316
1424
  let printedHeader = false;
1317
- for (const result of test.results) {
1425
+ const results = options?.lastResult ? test.results.slice(-1) : test.results;
1426
+ for (const result of results) {
1318
1427
  const resultLines = [];
1319
1428
  const errors = formatResultFailure(screen, test, result, " ");
1320
1429
  if (!errors.length)
1321
1430
  continue;
1322
1431
  if (!printedHeader) {
1323
- const header = formatTestHeader(screen, config2, test, { indent: " ", index, mode: "error", includeTestId: options?.includeTestId });
1432
+ const header = formatTestHeader(screen, config2, test, { indent: " ", index, mode: "error", includeTestId: options?.includeTestId, omitTags: options?.omitTags });
1324
1433
  lines.push(screen.colors.red(header));
1325
1434
  printedHeader = true;
1326
1435
  }
@@ -1393,14 +1502,10 @@ function formatRetry(screen, result) {
1393
1502
  }
1394
1503
  return retryLines;
1395
1504
  }
1396
- function quotePathIfNeeded(path20) {
1397
- if (/\s/.test(path20))
1398
- return `"${path20}"`;
1399
- return path20;
1400
- }
1401
- var kReportedSymbol = /* @__PURE__ */ Symbol("reported");
1402
- function markErrorsAsReported(result) {
1403
- result[kReportedSymbol] = result.errors.length;
1505
+ function quotePathIfNeeded(path22) {
1506
+ if (/\s/.test(path22))
1507
+ return `"${path22}"`;
1508
+ return path22;
1404
1509
  }
1405
1510
  function formatResultFailure(screen, test, result, initialIndent) {
1406
1511
  const errorDetails = [];
@@ -1414,8 +1519,7 @@ function formatResultFailure(screen, test, result, initialIndent) {
1414
1519
  message: indent(screen.colors.red(`Test was interrupted.`), initialIndent)
1415
1520
  });
1416
1521
  }
1417
- const reportedIndex = result[kReportedSymbol] || 0;
1418
- for (const error of result.errors.slice(reportedIndex)) {
1522
+ for (const error of result.errors) {
1419
1523
  const formattedError = formatError(screen, error);
1420
1524
  errorDetails.push({
1421
1525
  message: indent(formattedError.message, initialIndent),
@@ -1426,14 +1530,16 @@ function formatResultFailure(screen, test, result, initialIndent) {
1426
1530
  }
1427
1531
  function relativeFilePath(screen, config2, file) {
1428
1532
  if (screen.resolveFiles === "cwd")
1429
- return import_path2.default.relative(process.cwd(), file);
1430
- return import_path2.default.relative(config2.rootDir, file);
1533
+ return import_path3.default.relative(process.cwd(), file);
1534
+ return import_path3.default.relative(config2.rootDir, file);
1431
1535
  }
1432
1536
  function relativeTestPath(screen, config2, test) {
1433
1537
  return relativeFilePath(screen, config2, test.location.file);
1434
1538
  }
1435
1539
  function stepSuffix(step) {
1436
- const stepTitles = step ? step.titlePath() : [];
1540
+ const stepTitles = [];
1541
+ for (let current = step; current; current = current.parent)
1542
+ stepTitles.unshift(current.subtitle ? `${current.title} ${current.subtitle}` : current.title);
1437
1543
  return stepTitles.map((t2) => t2.split("\n")[0]).map((t2) => " \u203A " + t2).join("");
1438
1544
  }
1439
1545
  function formatTestTitle(screen, config2, test, step, options = {}) {
@@ -1443,7 +1549,7 @@ function formatTestTitle(screen, config2, test, step, options = {}) {
1443
1549
  const projectLabel = options.includeTestId ? `project=` : "";
1444
1550
  const projectTitle = projectName ? `[${projectLabel}${projectName}] \u203A ` : "";
1445
1551
  const testTitle = `${testId}${projectTitle}${location} \u203A ${titles.join(" \u203A ")}`;
1446
- const extraTags = test.tags.filter((t2) => !testTitle.includes(t2) && !config2.tags.includes(t2));
1552
+ const extraTags = options.omitTags ? [] : test.tags.filter((t2) => !testTitle.includes(t2) && !config2.tags.includes(t2));
1447
1553
  return `${testTitle}${stepSuffix(step)}${extraTags.length ? " " + extraTags.join(" ") : ""}`;
1448
1554
  }
1449
1555
  function formatTestHeader(screen, config2, test, options = {}) {
@@ -1512,19 +1618,19 @@ function prepareErrorStack(stack) {
1512
1618
  function resolveFromEnv(name) {
1513
1619
  const value = process.env[name];
1514
1620
  if (value)
1515
- return import_path2.default.resolve(process.cwd(), value);
1621
+ return import_path3.default.resolve(process.cwd(), value);
1516
1622
  return void 0;
1517
1623
  }
1518
1624
  function resolveOutputFile(reporterName, options) {
1519
1625
  const name = reporterName.toUpperCase();
1520
1626
  let outputFile = resolveFromEnv(`PLAYWRIGHT_${name}_OUTPUT_FILE`);
1521
1627
  if (!outputFile && options.outputFile)
1522
- outputFile = import_path2.default.resolve(options.configDir, options.outputFile);
1628
+ outputFile = import_path3.default.resolve(options.configDir, options.outputFile);
1523
1629
  if (outputFile)
1524
1630
  return { outputFile };
1525
1631
  let outputDir = resolveFromEnv(`PLAYWRIGHT_${name}_OUTPUT_DIR`);
1526
1632
  if (!outputDir && options.outputDir)
1527
- outputDir = import_path2.default.resolve(options.configDir, options.outputDir);
1633
+ outputDir = import_path3.default.resolve(options.configDir, options.outputDir);
1528
1634
  if (!outputDir && options.default)
1529
1635
  outputDir = (0, import_util2.resolveReporterOutputPath)(options.default.outputDir, options.configDir, void 0);
1530
1636
  if (!outputDir)
@@ -1532,7 +1638,7 @@ function resolveOutputFile(reporterName, options) {
1532
1638
  const reportName = process.env[`PLAYWRIGHT_${name}_OUTPUT_NAME`] ?? options.fileName ?? options.default?.fileName;
1533
1639
  if (!reportName)
1534
1640
  return void 0;
1535
- outputFile = import_path2.default.resolve(outputDir, reportName);
1641
+ outputFile = import_path3.default.resolve(outputDir, reportName);
1536
1642
  return { outputFile, outputDir };
1537
1643
  }
1538
1644
  function groupAttachments(attachments) {
@@ -1568,7 +1674,7 @@ function groupAttachments(attachments) {
1568
1674
  }
1569
1675
 
1570
1676
  // packages/playwright/src/reporters/internalReporter.ts
1571
- var import_fs = __toESM(require("fs"));
1677
+ var import_fs2 = __toESM(require("fs"));
1572
1678
 
1573
1679
  // packages/playwright/src/reporters/multiplexer.ts
1574
1680
  var import_util3 = require("../util");
@@ -1607,10 +1713,6 @@ var Multiplexer = class {
1607
1713
  for (const reporter of this._reporters)
1608
1714
  this._wrap(() => reporter.onStdErr?.(chunk, test, result));
1609
1715
  }
1610
- async onTestPaused(test, result) {
1611
- for (const reporter of this._reporters)
1612
- await this._wrapAsync(() => reporter.onTestPaused?.(test, result));
1613
- }
1614
1716
  onTestEnd(test, result) {
1615
1717
  for (const reporter of this._reporters)
1616
1718
  this._wrap(() => reporter.onTestEnd?.(test, result));
@@ -1675,7 +1777,6 @@ var Multiplexer = class {
1675
1777
 
1676
1778
  // packages/playwright/src/reporters/internalReporter.ts
1677
1779
  var import_common = require("../common");
1678
- var babel = __toESM(require("../transform/babelBundle"));
1679
1780
 
1680
1781
  // packages/playwright/src/reporters/reporterV2.ts
1681
1782
  function wrapReporterAsV2(reporter) {
@@ -1758,7 +1859,8 @@ var ReporterV2Wrapper = class {
1758
1859
  };
1759
1860
 
1760
1861
  // packages/playwright/src/reporters/internalReporter.ts
1761
- var { monotonicTime: monotonicTime3 } = require("playwright-core/lib/coreBundle").iso;
1862
+ var { codeFrame } = require("playwright-core/lib/coreBundle").iso;
1863
+ var { monotonicTime: monotonicTime2 } = require("playwright-core/lib/coreBundle").iso;
1762
1864
  var InternalReporter = class {
1763
1865
  constructor(reporters) {
1764
1866
  this._didBegin = false;
@@ -1773,7 +1875,7 @@ var InternalReporter = class {
1773
1875
  onConfigure(config2) {
1774
1876
  this._config = config2;
1775
1877
  this._startTime = /* @__PURE__ */ new Date();
1776
- this._monotonicStartTime = monotonicTime3();
1878
+ this._monotonicStartTime = monotonicTime2();
1777
1879
  this._reporter.onConfigure?.(config2);
1778
1880
  }
1779
1881
  async preprocess(params) {
@@ -1792,10 +1894,6 @@ var InternalReporter = class {
1792
1894
  onStdErr(chunk, test, result) {
1793
1895
  this._reporter.onStdErr?.(chunk, test, result);
1794
1896
  }
1795
- async onTestPaused(test, result) {
1796
- this._addSnippetToTestErrors(test, result);
1797
- return await this._reporter.onTestPaused?.(test, result);
1798
- }
1799
1897
  onTestEnd(test, result) {
1800
1898
  this._addSnippetToTestErrors(test, result);
1801
1899
  this._reporter.onTestEnd?.(test, result);
@@ -1807,7 +1905,7 @@ var InternalReporter = class {
1807
1905
  return await this._reporter.onEnd?.({
1808
1906
  ...result,
1809
1907
  startTime: this._startTime,
1810
- duration: monotonicTime3() - this._monotonicStartTime
1908
+ duration: monotonicTime2() - this._monotonicStartTime
1811
1909
  });
1812
1910
  }
1813
1911
  async onExit() {
@@ -1846,20 +1944,20 @@ function addLocationAndSnippetToError(config2, error, file) {
1846
1944
  return;
1847
1945
  try {
1848
1946
  const tokens = [];
1849
- const source = import_fs.default.readFileSync(location.file, "utf8");
1850
- const codeFrame = babel.codeFrameColumns(source, { start: location }, { highlightCode: true });
1851
- if (!file || import_fs.default.realpathSync(file) !== location.file) {
1947
+ const source = import_fs2.default.readFileSync(location.file, "utf8");
1948
+ const frame = codeFrame(source, location, { colors: internalScreen.colors });
1949
+ if (!file || import_fs2.default.realpathSync(file) !== location.file) {
1852
1950
  tokens.push(internalScreen.colors.gray(` at `) + `${relativeFilePath(internalScreen, config2, location.file)}:${location.line}`);
1853
1951
  tokens.push("");
1854
1952
  }
1855
- tokens.push(codeFrame);
1953
+ tokens.push(frame);
1856
1954
  error.snippet = tokens.join("\n");
1857
1955
  } catch (e) {
1858
1956
  }
1859
1957
  }
1860
1958
 
1861
1959
  // packages/playwright/src/runner/testRunner.ts
1862
- var import_util15 = require("../util");
1960
+ var import_util17 = require("../util");
1863
1961
 
1864
1962
  // packages/playwright/src/runner/reporters.ts
1865
1963
  var reporters_exports = {};
@@ -1867,19 +1965,20 @@ __export(reporters_exports, {
1867
1965
  createErrorCollectingReporter: () => createErrorCollectingReporter,
1868
1966
  createReporters: () => createReporters
1869
1967
  });
1870
- var import_fs8 = __toESM(require("fs"));
1968
+ var import_fs11 = __toESM(require("fs"));
1871
1969
 
1872
1970
  // packages/playwright/src/runner/loadUtils.ts
1873
- var import_path4 = __toESM(require("path"));
1874
- var import_fs3 = __toESM(require("fs"));
1971
+ var import_path5 = __toESM(require("path"));
1972
+ var import_fs4 = __toESM(require("fs"));
1875
1973
 
1876
1974
  // packages/playwright/src/runner/processHost.ts
1877
1975
  var import_child_process = __toESM(require("child_process"));
1878
1976
  var import_events = require("events");
1879
1977
  var debug3 = require("playwright-core/lib/utilsBundle").debug;
1880
1978
  var { assert } = require("playwright-core/lib/coreBundle").iso;
1881
- var { monotonicTime: monotonicTime4, timeOrigin } = require("playwright-core/lib/coreBundle").iso;
1979
+ var { monotonicTime: monotonicTime3, timeOrigin } = require("playwright-core/lib/coreBundle").iso;
1882
1980
  var { raceAgainstDeadline: raceAgainstDeadline2 } = require("playwright-core/lib/coreBundle").iso;
1981
+ var { killProcessTree } = require("playwright-core/lib/coreBundle").utils;
1883
1982
  var ProcessHost = class extends import_events.EventEmitter {
1884
1983
  constructor(entryScript, processName, env) {
1885
1984
  super();
@@ -1968,7 +2067,6 @@ var ProcessHost = class extends import_events.EventEmitter {
1968
2067
  if (error)
1969
2068
  return error;
1970
2069
  const processParams = {
1971
- processName: this._processName,
1972
2070
  timeOrigin: timeOrigin()
1973
2071
  };
1974
2072
  this.send({
@@ -2007,24 +2105,28 @@ var ProcessHost = class extends import_events.EventEmitter {
2007
2105
  return;
2008
2106
  const exitPromise = new Promise((f) => this.once("exit", () => f()));
2009
2107
  const timeout = +(process.env.PWTEST_CHILD_PROCESS_TIMEOUT || 5 * 60 * 1e3);
2010
- const result = await raceAgainstDeadline2(() => exitPromise, monotonicTime4() + timeout);
2011
- if (result.timedOut) {
2012
- this.emit("processError", { message: `Error: ${this._processName} process did not exit within ${timeout}ms after stop, force-killed it` });
2013
- this._forceKill();
2014
- await exitPromise;
2108
+ let lastHeartbeat = monotonicTime3();
2109
+ const onHeartbeat = () => lastHeartbeat = monotonicTime3();
2110
+ this.on("__heartbeat__", onHeartbeat);
2111
+ try {
2112
+ while (true) {
2113
+ const result = await raceAgainstDeadline2(() => exitPromise, lastHeartbeat + timeout);
2114
+ if (!result.timedOut)
2115
+ return;
2116
+ if (monotonicTime3() < lastHeartbeat + timeout)
2117
+ continue;
2118
+ this.emit("processError", { message: `Error: ${this._processName} process did not exit within ${timeout}ms after stop, force-killed it` });
2119
+ this._forceKill();
2120
+ await exitPromise;
2121
+ return;
2122
+ }
2123
+ } finally {
2124
+ this.off("__heartbeat__", onHeartbeat);
2015
2125
  }
2016
2126
  }
2017
2127
  _forceKill() {
2018
- const pid = this.process?.pid;
2019
- if (!pid)
2020
- return;
2021
- try {
2022
- if (process.platform === "win32")
2023
- import_child_process.default.spawnSync(`taskkill /pid ${pid} /T /F`, { shell: true });
2024
- else
2025
- process.kill(pid, "SIGKILL");
2026
- } catch {
2027
- }
2128
+ if (this.process?.pid)
2129
+ killProcessTree(this.process.pid);
2028
2130
  }
2029
2131
  didSendStop() {
2030
2132
  return this._didSendStop;
@@ -2098,20 +2200,20 @@ __export(projectUtils_exports, {
2098
2200
  filterProjects: () => filterProjects,
2099
2201
  findTopLevelProjects: () => findTopLevelProjects
2100
2202
  });
2101
- var import_fs2 = __toESM(require("fs"));
2102
- var import_path3 = __toESM(require("path"));
2203
+ var import_fs3 = __toESM(require("fs"));
2204
+ var import_path4 = __toESM(require("path"));
2103
2205
  var import_util4 = require("util");
2104
2206
  var import_util5 = require("../util");
2105
2207
  var { minimatch } = require("playwright-core/lib/utilsBundle");
2106
2208
  var { escapeRegExp } = require("playwright-core/lib/coreBundle").iso;
2107
- var readFileAsync = (0, import_util4.promisify)(import_fs2.default.readFile);
2108
- var readDirAsync = (0, import_util4.promisify)(import_fs2.default.readdir);
2209
+ var readFileAsync = (0, import_util4.promisify)(import_fs3.default.readFile);
2210
+ var readDirAsync = (0, import_util4.promisify)(import_fs3.default.readdir);
2109
2211
  function wildcardPatternToRegExp(pattern) {
2110
2212
  return new RegExp("^" + pattern.split("*").map(escapeRegExp).join(".*") + "$", "ig");
2111
2213
  }
2112
- function filterProjects(projects, projectNames) {
2214
+ function filterProjects(projects, projectNames, includeNonDefault) {
2113
2215
  if (!projectNames)
2114
- return [...projects];
2216
+ return projects.filter((project) => includeNonDefault || project.default);
2115
2217
  const projectNamesToFind = /* @__PURE__ */ new Set();
2116
2218
  const unmatchedProjectNames = /* @__PURE__ */ new Map();
2117
2219
  const patterns = /* @__PURE__ */ new Set();
@@ -2208,7 +2310,7 @@ function buildDependentProjects(forProjects, projects) {
2208
2310
  }
2209
2311
  async function collectFilesForProject(project, fsCache = /* @__PURE__ */ new Map()) {
2210
2312
  const extensions = /* @__PURE__ */ new Set([".js", ".ts", ".mjs", ".mts", ".cjs", ".cts", ".jsx", ".tsx", ".mjsx", ".mtsx", ".cjsx", ".ctsx"]);
2211
- const testFileExtension = (file) => extensions.has(import_path3.default.extname(file));
2313
+ const testFileExtension = (file) => extensions.has(import_path4.default.extname(file));
2212
2314
  const allFiles = await cachedCollectFiles(project.project.testDir, project.respectGitIgnore, fsCache);
2213
2315
  const testMatch = (0, import_util5.createFileMatcher)(project.project.testMatch);
2214
2316
  const testIgnore = (0, import_util5.createFileMatcher)(project.project.testIgnore);
@@ -2232,22 +2334,22 @@ async function cachedCollectFiles(testDir, respectGitIgnore, fsCache) {
2232
2334
  return result;
2233
2335
  }
2234
2336
  async function collectFiles(testDir, respectGitIgnore) {
2235
- if (!import_fs2.default.existsSync(testDir))
2337
+ if (!import_fs3.default.existsSync(testDir))
2236
2338
  return [];
2237
- if (!import_fs2.default.statSync(testDir).isDirectory())
2339
+ if (!import_fs3.default.statSync(testDir).isDirectory())
2238
2340
  return [];
2239
- const checkIgnores = (entryPath, rules, isDirectory, parentStatus) => {
2341
+ const checkIgnores = (entryPath, rules, isDirectory2, parentStatus) => {
2240
2342
  let status = parentStatus;
2241
2343
  for (const rule of rules) {
2242
2344
  const ruleIncludes = rule.negate;
2243
2345
  if (status === "included" === ruleIncludes)
2244
2346
  continue;
2245
- const relative = import_path3.default.relative(rule.dir, entryPath);
2347
+ const relative = import_path4.default.relative(rule.dir, entryPath);
2246
2348
  if (rule.match("/" + relative) || rule.match(relative)) {
2247
2349
  status = ruleIncludes ? "included" : "ignored";
2248
- } else if (isDirectory && (rule.match("/" + relative + "/") || rule.match(relative + "/"))) {
2350
+ } else if (isDirectory2 && (rule.match("/" + relative + "/") || rule.match(relative + "/"))) {
2249
2351
  status = ruleIncludes ? "included" : "ignored";
2250
- } else if (isDirectory && ruleIncludes && (rule.match("/" + relative, true) || rule.match(relative, true))) {
2352
+ } else if (isDirectory2 && ruleIncludes && (rule.match("/" + relative, true) || rule.match(relative, true))) {
2251
2353
  status = "ignored-but-recurse";
2252
2354
  }
2253
2355
  }
@@ -2260,7 +2362,7 @@ async function collectFiles(testDir, respectGitIgnore) {
2260
2362
  if (respectGitIgnore) {
2261
2363
  const gitignore = entries.find((e) => e.isFile() && e.name === ".gitignore");
2262
2364
  if (gitignore) {
2263
- const content = await readFileAsync(import_path3.default.join(dir, gitignore.name), "utf8");
2365
+ const content = await readFileAsync(import_path4.default.join(dir, gitignore.name), "utf8");
2264
2366
  const newRules = content.split(/\r?\n/).map((s) => {
2265
2367
  s = s.trim();
2266
2368
  if (!s)
@@ -2281,7 +2383,7 @@ async function collectFiles(testDir, respectGitIgnore) {
2281
2383
  continue;
2282
2384
  if (entry.isDirectory() && entry.name === "node_modules")
2283
2385
  continue;
2284
- const entryPath = import_path3.default.join(dir, entry.name);
2386
+ const entryPath = import_path4.default.join(dir, entry.name);
2285
2387
  const entryStatus = checkIgnores(entryPath, rules, entry.isDirectory(), status);
2286
2388
  if (entry.isDirectory() && entryStatus !== "ignored")
2287
2389
  await visit(entryPath, rules, entryStatus);
@@ -2311,6 +2413,15 @@ var ReporterTestRunImpl = class {
2311
2413
  shouldSkipSharding() {
2312
2414
  return this._skipSharding;
2313
2415
  }
2416
+ mode(suite) {
2417
+ if (!this._active)
2418
+ throw new Error(`TestRun.mode() can only be called from Reporter.preprocess().`);
2419
+ for (let current = suite; current; current = current.parent) {
2420
+ if (current._parallelMode !== "none")
2421
+ return current._parallelMode;
2422
+ }
2423
+ return "default";
2424
+ }
2314
2425
  skipSharding() {
2315
2426
  if (!this._active)
2316
2427
  throw new Error(`TestRun.skipSharding() can only be called from Reporter.preprocess().`);
@@ -2353,6 +2464,7 @@ var ReporterTestRunImpl = class {
2353
2464
  };
2354
2465
 
2355
2466
  // packages/playwright/src/runner/testGroups.ts
2467
+ var { calculateSha1 } = require("playwright-core/lib/coreBundle").utils;
2356
2468
  function createTestGroups(projectSuite, expectedParallelism) {
2357
2469
  const groups = /* @__PURE__ */ new Map();
2358
2470
  const createGroup = (test) => {
@@ -2361,7 +2473,8 @@ function createTestGroups(projectSuite, expectedParallelism) {
2361
2473
  requireFile: test._requireFile,
2362
2474
  repeatEachIndex: test.repeatEachIndex,
2363
2475
  projectId: test._projectId,
2364
- tests: []
2476
+ tests: [],
2477
+ locks: []
2365
2478
  };
2366
2479
  };
2367
2480
  for (const test of projectSuite.allTests()) {
@@ -2421,16 +2534,28 @@ function createTestGroups(projectSuite, expectedParallelism) {
2421
2534
  }
2422
2535
  }
2423
2536
  }
2537
+ for (const group of result) {
2538
+ const locks = /* @__PURE__ */ new Set();
2539
+ for (const test of group.tests) {
2540
+ for (const lock of test._locks)
2541
+ locks.add(lock);
2542
+ }
2543
+ group.locks = [...locks];
2544
+ }
2424
2545
  return result;
2425
2546
  }
2547
+ function shuffleTestGroups(testGroups, seed) {
2548
+ const keys = new Map(testGroups.map((group) => [group, calculateSha1(seed + "" + group.tests[0].id)]));
2549
+ testGroups.sort((a, b) => keys.get(a).localeCompare(keys.get(b)));
2550
+ }
2426
2551
  function filterForShard(shard, weights, testGroups) {
2427
2552
  weights ??= Array.from({ length: shard.total }, () => 1);
2428
2553
  if (weights.length !== shard.total)
2429
2554
  throw new Error(`PWTEST_SHARD_WEIGHTS number of weights must match the shard total of ${shard.total}`);
2430
2555
  const totalWeight = weights.reduce((a, b) => a + b, 0);
2431
- let shardableTotal = 0;
2432
- for (const group of testGroups)
2433
- shardableTotal += group.tests.length;
2556
+ const activeSizes = testGroups.map((group) => group.tests.filter((test) => test.expectedStatus !== "skipped").length);
2557
+ const groupSizes = activeSizes.some(Boolean) ? activeSizes : testGroups.map((group) => group.tests.length);
2558
+ const shardableTotal = groupSizes.reduce((a, b) => a + b, 0);
2434
2559
  const shardSizes = weights.map((w) => Math.floor(w * shardableTotal / totalWeight));
2435
2560
  const remainder = shardableTotal - shardSizes.reduce((a, b) => a + b, 0);
2436
2561
  for (let i = 0; i < remainder; i++) {
@@ -2442,11 +2567,12 @@ function filterForShard(shard, weights, testGroups) {
2442
2567
  const to = from + shardSizes[shard.current - 1];
2443
2568
  let current = 0;
2444
2569
  const result = /* @__PURE__ */ new Set();
2445
- for (const group of testGroups) {
2446
- if (current >= from && current < to)
2570
+ testGroups.forEach((group, index) => {
2571
+ const position = groupSizes[index] ? current : Math.max(current - 1, 0);
2572
+ if (position >= from && position < to)
2447
2573
  result.add(group);
2448
- current += group.tests.length;
2449
- }
2574
+ current += groupSizes[index];
2575
+ });
2450
2576
  return result;
2451
2577
  }
2452
2578
 
@@ -2506,8 +2632,8 @@ async function loadFileSuites(testRun, mode, errors) {
2506
2632
  for (const file of allTestFiles) {
2507
2633
  for (const dependency of import_common4.cc.dependenciesForTestFile(file)) {
2508
2634
  if (allTestFiles.has(dependency)) {
2509
- const importer = import_path4.default.relative(config2.config.rootDir, file);
2510
- const importee = import_path4.default.relative(config2.config.rootDir, dependency);
2635
+ const importer = import_path5.default.relative(config2.config.rootDir, file);
2636
+ const importee = import_path5.default.relative(config2.config.rootDir, dependency);
2511
2637
  errors.push({
2512
2638
  message: `Error: test file "${importer}" should not import test file "${importee}"`,
2513
2639
  location: { file, line: 1, column: 1 }
@@ -2550,10 +2676,11 @@ async function createRootSuite(testRun, errors, shouldFilterOnly) {
2550
2676
  rootSuite._addSuite(buildProjectSuite(project, filteredProjectSuites.get(project)));
2551
2677
  }
2552
2678
  }
2679
+ testRun.testCountBeforeSharding = rootSuite.allTests().length;
2553
2680
  if (config2.config.forbidOnly) {
2554
2681
  const onlyTestsAndSuites = rootSuite._getOnlyItems();
2555
2682
  if (onlyTestsAndSuites.length > 0) {
2556
- const configFilePath = config2.config.configFile ? import_path4.default.relative(config2.config.rootDir, config2.config.configFile) : void 0;
2683
+ const configFilePath = config2.config.configFile ? import_path5.default.relative(config2.config.rootDir, config2.config.configFile) : void 0;
2557
2684
  errors.push(...createForbidOnlyErrors(onlyTestsAndSuites, config2.configCLIOverrides.forbidOnly, configFilePath));
2558
2685
  }
2559
2686
  }
@@ -2674,7 +2801,7 @@ function createDuplicateTitlesErrors(config2, fileSuite) {
2674
2801
  function buildItemLocation(rootDir, testOrSuite) {
2675
2802
  if (!testOrSuite.location)
2676
2803
  return "";
2677
- return `${import_path4.default.relative(rootDir, testOrSuite.location.file)}:${testOrSuite.location.line}`;
2804
+ return `${import_path5.default.relative(rootDir, testOrSuite.location.file)}:${testOrSuite.location.line}`;
2678
2805
  }
2679
2806
  async function requireOrImportDefaultFunction(file, expectConstructor) {
2680
2807
  let func = await import_common4.transform.requireOrImport(file);
@@ -2685,10 +2812,10 @@ async function requireOrImportDefaultFunction(file, expectConstructor) {
2685
2812
  return func;
2686
2813
  }
2687
2814
  function loadGlobalHook(config2, file) {
2688
- return requireOrImportDefaultFunction(import_path4.default.resolve(config2.config.rootDir, file), false);
2815
+ return requireOrImportDefaultFunction(import_path5.default.resolve(config2.config.rootDir, file), false);
2689
2816
  }
2690
2817
  function loadReporter(config2, file) {
2691
- return requireOrImportDefaultFunction(config2 ? import_path4.default.resolve(config2.config.rootDir, file) : file, true);
2818
+ return requireOrImportDefaultFunction(config2 ? import_path5.default.resolve(config2.config.rootDir, file) : file, true);
2692
2819
  }
2693
2820
  function sourceMapSources(file, cache) {
2694
2821
  let sources = [file];
@@ -2700,7 +2827,7 @@ function sourceMapSources(file, cache) {
2700
2827
  const sourceMap = sourceMapSupport.retrieveSourceMap(file);
2701
2828
  const sourceMapData = typeof sourceMap?.map === "string" ? JSON.parse(sourceMap.map) : sourceMap?.map;
2702
2829
  if (sourceMapData?.sources)
2703
- sources = sourceMapData.sources.map((source) => import_path4.default.resolve(import_path4.default.dirname(file), source));
2830
+ sources = sourceMapData.sources.map((source) => import_path5.default.resolve(import_path5.default.dirname(file), source));
2704
2831
  } finally {
2705
2832
  cache.set(file, sources);
2706
2833
  return sources;
@@ -2708,7 +2835,7 @@ function sourceMapSources(file, cache) {
2708
2835
  }
2709
2836
  async function loadTestList(config2, filePath) {
2710
2837
  try {
2711
- const content = await import_fs3.default.promises.readFile(filePath, "utf-8");
2838
+ const content = await import_fs4.default.promises.readFile(filePath, "utf-8");
2712
2839
  const lines = content.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
2713
2840
  const descriptions = lines.map((line) => {
2714
2841
  const delimiter = line.includes("\u203A") ? "\u203A" : ">";
@@ -2726,13 +2853,13 @@ async function loadTestList(config2, filePath) {
2726
2853
  const [projectName, , ...titles] = test.titlePath();
2727
2854
  if (d.project !== void 0 && d.project !== projectName)
2728
2855
  return false;
2729
- const relativeFile = toPosixPath(import_path4.default.relative(config2.config.rootDir, test.location.file));
2856
+ const relativeFile = toPosixPath(import_path5.default.relative(config2.config.rootDir, test.location.file));
2730
2857
  if (relativeFile !== d.file)
2731
2858
  return false;
2732
2859
  return d.titlePath.length <= titles.length && d.titlePath.every((_, index) => titles[index] === d.titlePath[index]);
2733
2860
  });
2734
2861
  const fileFilter = (file) => {
2735
- const relativeFile = toPosixPath(import_path4.default.relative(config2.config.rootDir, file));
2862
+ const relativeFile = toPosixPath(import_path5.default.relative(config2.config.rootDir, file));
2736
2863
  return descriptions.some((d) => d.file === relativeFile);
2737
2864
  };
2738
2865
  return { testFilter, fileFilter };
@@ -2742,18 +2869,17 @@ async function loadTestList(config2, filePath) {
2742
2869
  }
2743
2870
 
2744
2871
  // packages/playwright/src/reporters/blob.ts
2745
- var import_fs4 = __toESM(require("fs"));
2746
- var import_path6 = __toESM(require("path"));
2872
+ var import_fs5 = __toESM(require("fs"));
2873
+ var import_path7 = __toESM(require("path"));
2747
2874
  var import_stream2 = require("stream");
2748
2875
  var import_coreBundle = require("playwright-core/lib/coreBundle");
2749
2876
 
2750
2877
  // packages/playwright/src/reporters/teleEmitter.ts
2751
- var import_path5 = __toESM(require("path"));
2878
+ var import_path6 = __toESM(require("path"));
2752
2879
  var { createGuid } = require("playwright-core/lib/coreBundle").utils;
2753
2880
  var TeleReporterEmitter = class {
2754
2881
  constructor(messageSink, options = {}) {
2755
2882
  this._resultKnownAttachmentCounts = /* @__PURE__ */ new Map();
2756
- this._resultKnownErrorCounts = /* @__PURE__ */ new Map();
2757
2883
  // In case there is blob reporter and UI mode, make sure one doesn't override
2758
2884
  // the id assigned by the other.
2759
2885
  this._idSymbol = /* @__PURE__ */ Symbol("id");
@@ -2783,20 +2909,6 @@ var TeleReporterEmitter = class {
2783
2909
  }
2784
2910
  });
2785
2911
  }
2786
- async onTestPaused(test, result) {
2787
- const resultId = result[this._idSymbol];
2788
- this._resultKnownErrorCounts.set(resultId, result.errors.length);
2789
- this._messageSink({
2790
- method: "onTestPaused",
2791
- params: {
2792
- testId: test.id,
2793
- resultId,
2794
- errors: result.errors
2795
- }
2796
- });
2797
- await new Promise(() => {
2798
- });
2799
- }
2800
2912
  onTestEnd(test, result) {
2801
2913
  const testEnd = {
2802
2914
  testId: test.id,
@@ -2814,7 +2926,6 @@ var TeleReporterEmitter = class {
2814
2926
  });
2815
2927
  const resultId = result[this._idSymbol];
2816
2928
  this._resultKnownAttachmentCounts.delete(resultId);
2817
- this._resultKnownErrorCounts.delete(resultId);
2818
2929
  }
2819
2930
  onStepBegin(test, result, step) {
2820
2931
  step[this._idSymbol] = createGuid();
@@ -2969,7 +3080,7 @@ var TeleReporterEmitter = class {
2969
3080
  id,
2970
3081
  duration: result.duration,
2971
3082
  status: result.status,
2972
- errors: this._resultKnownErrorCounts.has(id) ? result.errors.slice(this._resultKnownAttachmentCounts.get(id)) : result.errors,
3083
+ errors: result.errors,
2973
3084
  annotations: result.annotations?.length ? this._relativeAnnotationLocations(result.annotations) : void 0
2974
3085
  };
2975
3086
  }
@@ -3003,7 +3114,9 @@ var TeleReporterEmitter = class {
3003
3114
  id: step[this._idSymbol],
3004
3115
  parentStepId: step.parent?.[this._idSymbol],
3005
3116
  title: step.title,
3117
+ subtitle: step.subtitle,
3006
3118
  category: step.category,
3119
+ params: step.params,
3007
3120
  startTime: +step.startTime,
3008
3121
  location: this._relativeLocation(step.location)
3009
3122
  };
@@ -3034,7 +3147,7 @@ var TeleReporterEmitter = class {
3034
3147
  _relativePath(absolutePath) {
3035
3148
  if (!absolutePath)
3036
3149
  return absolutePath;
3037
- return import_path5.default.relative(this._rootDir, absolutePath);
3150
+ return import_path6.default.relative(this._rootDir, absolutePath);
3038
3151
  }
3039
3152
  };
3040
3153
 
@@ -3042,7 +3155,7 @@ var TeleReporterEmitter = class {
3042
3155
  var mime = require("playwright-core/lib/utilsBundle").mime;
3043
3156
  var yazl = require("playwright-core/lib/utilsBundle").yazl;
3044
3157
  var { ManualPromise: ManualPromise2 } = require("playwright-core/lib/coreBundle").iso;
3045
- var { calculateSha1, createGuid: createGuid2 } = require("playwright-core/lib/coreBundle").utils;
3158
+ var { calculateSha1: calculateSha12, createGuid: createGuid2 } = require("playwright-core/lib/coreBundle").utils;
3046
3159
  var { removeFolders, sanitizeForFilePath } = require("playwright-core/lib/coreBundle").utils;
3047
3160
  var currentBlobReportVersion = 2;
3048
3161
  var BlobReporter = class extends TeleReporterEmitter {
@@ -3062,7 +3175,7 @@ var BlobReporter = class extends TeleReporterEmitter {
3062
3175
  // TODO: remove after some time, recommend config.tag instead.
3063
3176
  name: process.env.PWTEST_BOT_NAME,
3064
3177
  shard: config2.shard ?? void 0,
3065
- pathSeparator: import_path6.default.sep
3178
+ pathSeparator: import_path7.default.sep
3066
3179
  };
3067
3180
  this._messages.push({
3068
3181
  method: "onBlobReportMetadata",
@@ -3071,8 +3184,6 @@ var BlobReporter = class extends TeleReporterEmitter {
3071
3184
  this._config = config2;
3072
3185
  super.onConfigure(config2);
3073
3186
  }
3074
- async onTestPaused(test, result) {
3075
- }
3076
3187
  async onEnd(result) {
3077
3188
  await super.onEnd(result);
3078
3189
  const zipFileName = await this._prepareOutputFile();
@@ -3082,11 +3193,11 @@ var BlobReporter = class extends TeleReporterEmitter {
3082
3193
  throw new Error(`Failed to write report ${zipFileName}: ` + e.message);
3083
3194
  });
3084
3195
  zipFile.on("error", (error) => zipFinishPromise.reject(error));
3085
- zipFile.outputStream.pipe(import_fs4.default.createWriteStream(zipFileName)).on("close", () => {
3196
+ zipFile.outputStream.pipe(import_fs5.default.createWriteStream(zipFileName)).on("close", () => {
3086
3197
  zipFinishPromise.resolve(void 0);
3087
3198
  }).on("error", (error) => zipFinishPromise.reject(error));
3088
3199
  for (const { originalPath, zipEntryPath } of this._attachments) {
3089
- if (!import_fs4.default.statSync(originalPath, { throwIfNoEntry: false })?.isFile())
3200
+ if (!import_fs5.default.statSync(originalPath, { throwIfNoEntry: false })?.isFile())
3090
3201
  continue;
3091
3202
  zipFile.addFile(originalPath, zipEntryPath);
3092
3203
  }
@@ -3106,7 +3217,7 @@ var BlobReporter = class extends TeleReporterEmitter {
3106
3217
  });
3107
3218
  if (!process.env.PWTEST_BLOB_DO_NOT_REMOVE)
3108
3219
  await removeFolders([outputDir]);
3109
- await import_fs4.default.promises.mkdir(import_path6.default.dirname(outputFile), { recursive: true });
3220
+ await import_fs5.default.promises.mkdir(import_path7.default.dirname(outputFile), { recursive: true });
3110
3221
  return outputFile;
3111
3222
  }
3112
3223
  _defaultReportName(config2) {
@@ -3123,7 +3234,7 @@ var BlobReporter = class extends TeleReporterEmitter {
3123
3234
  return super._serializeAttachments(attachments).map((attachment) => {
3124
3235
  if (!attachment.path)
3125
3236
  return attachment;
3126
- const sha1 = calculateSha1(attachment.path + this._salt);
3237
+ const sha1 = calculateSha12(attachment.path + this._salt);
3127
3238
  const extension = mime.getExtension(attachment.contentType) || "dat";
3128
3239
  const newPath = `resources/${sha1}.${extension}`;
3129
3240
  this._attachments.push({ originalPath: attachment.path, zipEntryPath: newPath });
@@ -3135,10 +3246,186 @@ var BlobReporter = class extends TeleReporterEmitter {
3135
3246
  }
3136
3247
  };
3137
3248
 
3249
+ // packages/playwright/src/reporters/coverage.ts
3250
+ var import_fs6 = __toESM(require("fs"));
3251
+ var import_path8 = __toESM(require("path"));
3252
+ var import_util7 = require("../util");
3253
+ var { mergeIstanbulCoverage, sortedIstanbulCoverage } = require("playwright-core/lib/coreBundle").iso;
3254
+ var { ZipFile } = require("playwright-core/lib/coreBundle").utils;
3255
+ var CoverageReporter = class {
3256
+ constructor(options) {
3257
+ this._traceFiles = /* @__PURE__ */ new Set();
3258
+ this._options = options;
3259
+ }
3260
+ version() {
3261
+ return "v2";
3262
+ }
3263
+ printsToStdio() {
3264
+ return false;
3265
+ }
3266
+ onTestEnd(test, result) {
3267
+ for (const attachment of result.attachments) {
3268
+ if (attachment.name === "trace" && attachment.path)
3269
+ this._traceFiles.add(attachment.path);
3270
+ }
3271
+ }
3272
+ async onEnd() {
3273
+ const coverage = /* @__PURE__ */ new Map();
3274
+ const traceFiles = [...this._traceFiles];
3275
+ while (traceFiles.length) {
3276
+ const batch = traceFiles.splice(0, 16).map(async (traceFile) => {
3277
+ const zipFile = new ZipFile(traceFile);
3278
+ try {
3279
+ const entries = (await zipFile.entries()).filter((entry) => entry.match(/(^|-)trace\.coverage$/));
3280
+ return await Promise.all(entries.map((entry) => zipFile.read(entry)));
3281
+ } catch {
3282
+ return [];
3283
+ } finally {
3284
+ zipFile.close();
3285
+ }
3286
+ });
3287
+ for (const buffers of await Promise.all(batch)) {
3288
+ for (const buffer of buffers) {
3289
+ try {
3290
+ mergeIstanbulCoverage(coverage, JSON.parse(buffer.toString("utf8")));
3291
+ } catch {
3292
+ }
3293
+ }
3294
+ }
3295
+ }
3296
+ if (!coverage.size) {
3297
+ writeLine([
3298
+ `
3299
+ No code coverage was collected.`,
3300
+ `Make sure the application under test is built with istanbul instrumentation`,
3301
+ `(e.g. vite-plugin-istanbul or babel-plugin-istanbul) so that pages expose window.__coverage__,`,
3302
+ `and that tracing is configured with coverage, e.g. trace: { mode: 'on', coverage: true }.`,
3303
+ `Coverage is aggregated from the tests whose traces are kept.`
3304
+ ].join("\n"));
3305
+ return;
3306
+ }
3307
+ const outputDir = (0, import_util7.resolveReporterOutputPath)("coverage", this._options.configDir, this._options.outputDir);
3308
+ await import_fs6.default.promises.mkdir(outputDir, { recursive: true });
3309
+ const mergedJson = sortedIstanbulCoverage(coverage);
3310
+ await import_fs6.default.promises.writeFile(import_path8.default.join(outputDir, "coverage-final.json"), JSON.stringify(mergedJson));
3311
+ await import_fs6.default.promises.writeFile(import_path8.default.join(outputDir, "lcov.info"), lcovReport(mergedJson));
3312
+ const hasHtml = this._tryWriteHtmlReport(mergedJson, outputDir);
3313
+ const summary = computeSummary(mergedJson);
3314
+ const lines = [
3315
+ ``,
3316
+ `Code coverage (${coverage.size} files):`,
3317
+ ` statements: ${formatMetric(summary.statements)}`,
3318
+ ` branches: ${formatMetric(summary.branches)}`,
3319
+ ` functions: ${formatMetric(summary.functions)}`,
3320
+ ` lines: ${formatMetric(summary.lines)}`,
3321
+ `Coverage report written to ${import_path8.default.relative(process.cwd(), outputDir)}`
3322
+ ];
3323
+ if (!hasHtml)
3324
+ lines.push(`For an HTML report, install istanbul-lib-coverage, istanbul-lib-report and istanbul-reports, or run 'npx nyc report --temp-dir=${import_path8.default.relative(process.cwd(), outputDir)} --reporter=html'.`);
3325
+ writeLine(lines.join("\n"));
3326
+ }
3327
+ // Istanbul report libraries are not shipped with Playwright, use the project's if any.
3328
+ _tryWriteHtmlReport(mergedJson, outputDir) {
3329
+ try {
3330
+ const resolveFrom = (name) => require.resolve(name, { paths: [this._options.configDir] });
3331
+ const libCoverage = require(resolveFrom("istanbul-lib-coverage"));
3332
+ const libReport = require(resolveFrom("istanbul-lib-report"));
3333
+ const reports = require(resolveFrom("istanbul-reports"));
3334
+ const context = libReport.createContext({
3335
+ dir: outputDir,
3336
+ coverageMap: libCoverage.createCoverageMap(mergedJson)
3337
+ });
3338
+ reports.create("html").execute(context);
3339
+ return true;
3340
+ } catch {
3341
+ return false;
3342
+ }
3343
+ }
3344
+ };
3345
+ function computeSummary(mergedJson) {
3346
+ const statements = { covered: 0, total: 0 };
3347
+ const branches = { covered: 0, total: 0 };
3348
+ const functions = { covered: 0, total: 0 };
3349
+ const lines = { covered: 0, total: 0 };
3350
+ for (const fileCov of Object.values(mergedJson)) {
3351
+ countHits(statements, Object.values(fileCov.s));
3352
+ countHits(functions, Object.values(fileCov.f));
3353
+ for (const counts of Object.values(fileCov.b))
3354
+ countHits(branches, counts);
3355
+ countHits(lines, lineCoverage(fileCov).values());
3356
+ }
3357
+ return { statements, branches, functions, lines };
3358
+ }
3359
+ function countHits(metric, counts) {
3360
+ for (const count of counts) {
3361
+ ++metric.total;
3362
+ if (count > 0)
3363
+ ++metric.covered;
3364
+ }
3365
+ }
3366
+ function lineCoverage(fileCov) {
3367
+ const lines = /* @__PURE__ */ new Map();
3368
+ for (const [key, statement] of Object.entries(fileCov.statementMap)) {
3369
+ const line = statement.start.line;
3370
+ const count = fileCov.s[key] || 0;
3371
+ lines.set(line, Math.max(lines.get(line) || 0, count));
3372
+ }
3373
+ return lines;
3374
+ }
3375
+ function formatMetric(metric) {
3376
+ const percent = metric.total ? (metric.covered / metric.total * 100).toFixed(2) : "100.00";
3377
+ return `${percent}% (${metric.covered}/${metric.total})`;
3378
+ }
3379
+ function lcovReport(mergedJson) {
3380
+ const out = [];
3381
+ for (const [file, fileCov] of Object.entries(mergedJson)) {
3382
+ out.push(`SF:${file}`);
3383
+ let functionsCovered = 0;
3384
+ for (const [key, fn] of Object.entries(fileCov.fnMap)) {
3385
+ out.push(`FN:${fn.decl.start.line},${fn.name}`);
3386
+ out.push(`FNDA:${fileCov.f[key] || 0},${fn.name}`);
3387
+ if (fileCov.f[key] > 0)
3388
+ ++functionsCovered;
3389
+ }
3390
+ out.push(`FNF:${Object.keys(fileCov.fnMap).length}`);
3391
+ out.push(`FNH:${functionsCovered}`);
3392
+ let branchesFound = 0;
3393
+ let branchesCovered = 0;
3394
+ for (const [key, branch] of Object.entries(fileCov.branchMap)) {
3395
+ const counts = fileCov.b[key] || [];
3396
+ branch.locations.forEach((location, i) => {
3397
+ const count = counts[i] || 0;
3398
+ out.push(`BRDA:${location.start.line ?? branch.loc.start.line},${key},${i},${count}`);
3399
+ ++branchesFound;
3400
+ if (count > 0)
3401
+ ++branchesCovered;
3402
+ });
3403
+ }
3404
+ out.push(`BRF:${branchesFound}`);
3405
+ out.push(`BRH:${branchesCovered}`);
3406
+ const lines = lineCoverage(fileCov);
3407
+ let linesCovered = 0;
3408
+ for (const [line, count] of [...lines.entries()].sort((a, b) => a[0] - b[0])) {
3409
+ out.push(`DA:${line},${count}`);
3410
+ if (count > 0)
3411
+ ++linesCovered;
3412
+ }
3413
+ out.push(`LF:${lines.size}`);
3414
+ out.push(`LH:${linesCovered}`);
3415
+ out.push(`end_of_record`);
3416
+ }
3417
+ return out.join("\n") + "\n";
3418
+ }
3419
+ function writeLine(line) {
3420
+ terminalScreen.stdout.write(line + "\n");
3421
+ }
3422
+ var coverage_default = CoverageReporter;
3423
+
3138
3424
  // packages/playwright/src/reporters/dot.ts
3425
+ var { getAsBooleanFromENV: getAsBooleanFromENV2 } = require("playwright-core/lib/coreBundle").utils;
3139
3426
  var DotReporter = class extends TerminalReporter {
3140
- constructor() {
3141
- super(...arguments);
3427
+ constructor(options) {
3428
+ super({ ...options, omitTags: getAsBooleanFromENV2("PLAYWRIGHT_DOT_OMIT_TAGS", options?.omitTags) });
3142
3429
  this._counter = 0;
3143
3430
  }
3144
3431
  onBegin(suite) {
@@ -3187,23 +3474,6 @@ var DotReporter = class extends TerminalReporter {
3187
3474
  this.writeLine("\n" + this.formatError(error).message);
3188
3475
  this._counter = 0;
3189
3476
  }
3190
- async onTestPaused(test, result) {
3191
- if (!process.stdin.isTTY && !process.env.PW_TEST_DEBUG_REPORTERS)
3192
- return;
3193
- this.screen.stdout.write("\n");
3194
- if (test.outcome() === "unexpected") {
3195
- this.writeLine(this.screen.colors.red(this.formatTestHeader(test, { indent: " " })));
3196
- this.writeLine(this.formatResultErrors(test, result));
3197
- markErrorsAsReported(result);
3198
- this.writeLine(this.screen.colors.yellow(" Paused on error. Press Ctrl+C to end.") + "\n");
3199
- } else {
3200
- this.writeLine(this.screen.colors.yellow(this.formatTestHeader(test, { indent: " " })));
3201
- this.writeLine(this.screen.colors.yellow(" Paused at test end. Press Ctrl+C to end.") + "\n");
3202
- }
3203
- this._counter = 0;
3204
- await new Promise(() => {
3205
- });
3206
- }
3207
3477
  async onEnd(result) {
3208
3478
  await super.onEnd(result);
3209
3479
  this.screen.stdout.write("\n");
@@ -3223,19 +3493,85 @@ var EmptyReporter = class {
3223
3493
  };
3224
3494
  var empty_default = EmptyReporter;
3225
3495
 
3496
+ // packages/playwright/src/reporters/failures.ts
3497
+ var { msToString: msToString2 } = require("playwright-core/lib/coreBundle").iso;
3498
+ var { getAsBooleanFromENV: getAsBooleanFromENV3 } = require("playwright-core/lib/coreBundle").utils;
3499
+ var FailuresReporter = class extends TerminalReporter {
3500
+ constructor(options) {
3501
+ super({ ...options, omitTags: getAsBooleanFromENV3("PLAYWRIGHT_FAILURES_OMIT_TAGS", options?.omitTags), lastResult: true });
3502
+ this._failureIndex = /* @__PURE__ */ new Map();
3503
+ this._needNewLine = false;
3504
+ }
3505
+ onStdOut(chunk, test, result) {
3506
+ super.onStdOut(chunk, test, result);
3507
+ this._dumpToStdio(chunk, this.screen.stdout);
3508
+ }
3509
+ onStdErr(chunk, test, result) {
3510
+ super.onStdErr(chunk, test, result);
3511
+ this._dumpToStdio(chunk, this.screen.stderr);
3512
+ }
3513
+ _dumpToStdio(chunk, stream) {
3514
+ if (this.config.quiet)
3515
+ return;
3516
+ stream.write(chunk);
3517
+ if (chunk.length)
3518
+ this._needNewLine = !chunk.toString().endsWith("\n");
3519
+ }
3520
+ onTestEnd(test, result) {
3521
+ super.onTestEnd(test, result);
3522
+ if (result.status !== "skipped" && result.status !== test.expectedStatus) {
3523
+ this._printFailure(test);
3524
+ } else if (result.retry && result.status === "passed") {
3525
+ this._maybeWriteNewLine();
3526
+ this.writeLine(this.screen.colors.green(this.formatTestHeader(test, { indent: " ", index: this._failureIndex.get(test) })));
3527
+ this.writeLine(this.screen.colors.green(` Passed on retry #${result.retry} (${msToString2(result.duration)}).`));
3528
+ this.writeLine();
3529
+ }
3530
+ }
3531
+ _printFailure(test) {
3532
+ let index = this._failureIndex.get(test);
3533
+ if (index === void 0) {
3534
+ index = this._failureIndex.size + 1;
3535
+ this._failureIndex.set(test, index);
3536
+ }
3537
+ const message = this.formatFailure(test, index);
3538
+ if (message.trim()) {
3539
+ this._maybeWriteNewLine();
3540
+ this.writeLine(message);
3541
+ }
3542
+ }
3543
+ onError(error) {
3544
+ super.onError(error);
3545
+ this._maybeWriteNewLine();
3546
+ this.writeLine(this.formatError(error).message);
3547
+ }
3548
+ async onEnd(result) {
3549
+ await super.onEnd(result);
3550
+ this._maybeWriteNewLine();
3551
+ this.epilogue(false);
3552
+ }
3553
+ _maybeWriteNewLine() {
3554
+ if (this._needNewLine) {
3555
+ this.writeLine();
3556
+ this._needNewLine = false;
3557
+ }
3558
+ }
3559
+ };
3560
+ var failures_default = FailuresReporter;
3561
+
3226
3562
  // packages/playwright/src/reporters/github.ts
3227
- var import_path7 = __toESM(require("path"));
3228
- var import_util7 = require("../util");
3563
+ var import_path9 = __toESM(require("path"));
3564
+ var import_util8 = require("../util");
3229
3565
  var { noColors: noColors2 } = require("playwright-core/lib/coreBundle").iso;
3230
- var { msToString: msToString2 } = require("playwright-core/lib/coreBundle").iso;
3566
+ var { msToString: msToString3 } = require("playwright-core/lib/coreBundle").iso;
3567
+ var { getAsBooleanFromENV: getAsBooleanFromENV4 } = require("playwright-core/lib/coreBundle").utils;
3231
3568
  var GitHubLogger = class {
3232
3569
  newLine() {
3233
3570
  process.stdout.write("\n");
3234
3571
  }
3235
3572
  _log(message, type = "notice", options = {}) {
3236
- message = message.replace(/\n/g, "%0A");
3237
- const configs = Object.entries(options).map(([key, option]) => `${key}=${option}`).join(",");
3238
- process.stdout.write((0, import_util7.stripAnsiEscapes)(`::${type} ${configs}::${message}
3573
+ const configs = Object.entries(options).map(([key, option]) => `${key}=${escapeProperty(String(option))}`).join(",");
3574
+ process.stdout.write((0, import_util8.stripAnsiEscapes)(`::${type} ${configs}::${escapeData(message)}
3239
3575
  `));
3240
3576
  }
3241
3577
  debug(message, options) {
@@ -3251,9 +3587,15 @@ var GitHubLogger = class {
3251
3587
  this._log(message, "warning", options);
3252
3588
  }
3253
3589
  };
3590
+ function escapeData(s) {
3591
+ return s.replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A");
3592
+ }
3593
+ function escapeProperty(s) {
3594
+ return escapeData(s).replace(/:/g, "%3A").replace(/,/g, "%2C");
3595
+ }
3254
3596
  var GitHubReporter = class extends TerminalReporter {
3255
3597
  constructor(options = {}) {
3256
- super(options);
3598
+ super({ ...options, omitTags: getAsBooleanFromENV4("PLAYWRIGHT_GITHUB_OMIT_TAGS", options.omitTags) });
3257
3599
  this.githubLogger = new GitHubLogger();
3258
3600
  this._failedTestCount = 0;
3259
3601
  this.screen = { ...this.screen, colors: noColors2 };
@@ -3299,8 +3641,8 @@ var GitHubReporter = class extends TerminalReporter {
3299
3641
  }
3300
3642
  _printSlowTestAnnotations() {
3301
3643
  this.getSlowTests().forEach(([file, duration]) => {
3302
- const filePath = workspaceRelativePath(import_path7.default.join(process.cwd(), file));
3303
- this.githubLogger.warning(`${filePath} took ${msToString2(duration)}`, {
3644
+ const filePath = workspaceRelativePath(import_path9.default.join(process.cwd(), file));
3645
+ this.githubLogger.warning(`${filePath} took ${msToString3(duration)}`, {
3304
3646
  title: "Slow Test",
3305
3647
  file: filePath
3306
3648
  });
@@ -3330,7 +3672,7 @@ var GitHubReporter = class extends TerminalReporter {
3330
3672
  }
3331
3673
  };
3332
3674
  function workspaceRelativePath(filePath) {
3333
- return import_path7.default.relative(process.env["GITHUB_WORKSPACE"] ?? "", filePath);
3675
+ return import_path9.default.relative(process.env["GITHUB_WORKSPACE"] ?? "", filePath);
3334
3676
  }
3335
3677
  var github_default = GitHubReporter;
3336
3678
 
@@ -3340,18 +3682,18 @@ __export(html_exports, {
3340
3682
  default: () => html_default,
3341
3683
  showHTMLReport: () => showHTMLReport
3342
3684
  });
3343
- var import_fs5 = __toESM(require("fs"));
3685
+ var import_fs7 = __toESM(require("fs"));
3344
3686
  var import_os = __toESM(require("os"));
3345
- var import_path8 = __toESM(require("path"));
3687
+ var import_path10 = __toESM(require("path"));
3346
3688
  var import_stream3 = require("stream");
3347
- var babel2 = __toESM(require("../transform/babelBundle"));
3348
- var import_util8 = require("../util");
3689
+ var import_util9 = require("../util");
3349
3690
  var colors2 = require("playwright-core/lib/utilsBundle").colors;
3350
3691
  var mime2 = require("playwright-core/lib/utilsBundle").mime;
3351
3692
  var open = require("playwright-core/lib/utilsBundle").open;
3352
3693
  var yazl2 = require("playwright-core/lib/utilsBundle").yazl;
3694
+ var { codeFrame: codeFrame2 } = require("playwright-core/lib/coreBundle").iso;
3353
3695
  var { MultiMap } = require("playwright-core/lib/coreBundle").iso;
3354
- var { calculateSha1: calculateSha12 } = require("playwright-core/lib/coreBundle").utils;
3696
+ var { calculateSha1: calculateSha13 } = require("playwright-core/lib/coreBundle").utils;
3355
3697
  var { copyFileAndMakeWritable, removeFolders: removeFolders2, sanitizeForFilePath: sanitizeForFilePath2, toPosixPath: toPosixPath2 } = require("playwright-core/lib/coreBundle").utils;
3356
3698
  var { getPackageManagerExecCommand: getPackageManagerExecCommand2, isCodingAgent } = require("playwright-core/lib/coreBundle").utils;
3357
3699
  var { HttpServer, serveFolder } = require("playwright-core/lib/coreBundle").utils;
@@ -3391,19 +3733,19 @@ var HtmlReporter = class {
3391
3733
  if (reportedWarnings.has(key))
3392
3734
  continue;
3393
3735
  reportedWarnings.add(key);
3394
- writeLine(colors2.red(`Configuration Error: HTML reporter output folder clashes with the tests output folder:`));
3395
- writeLine(`
3736
+ writeLine2(colors2.red(`Configuration Error: HTML reporter output folder clashes with the tests output folder:`));
3737
+ writeLine2(`
3396
3738
  html reporter folder: ${colors2.bold(outputFolder)}
3397
3739
  test results folder: ${colors2.bold(project.outputDir)}`);
3398
- writeLine("");
3399
- writeLine(`HTML reporter will clear its output directory prior to being generated, which will lead to the artifact loss.
3740
+ writeLine2("");
3741
+ writeLine2(`HTML reporter will clear its output directory prior to being generated, which will lead to the artifact loss.
3400
3742
  `);
3401
3743
  }
3402
3744
  }
3403
3745
  this.suite = suite;
3404
3746
  }
3405
3747
  _resolveOptions() {
3406
- const outputFolder = reportFolderFromEnv() ?? (0, import_util8.resolveReporterOutputPath)("playwright-report", this._options.configDir, this._options.outputFolder);
3748
+ const outputFolder = reportFolderFromEnv() ?? (0, import_util9.resolveReporterOutputPath)("playwright-report", this._options.configDir, this._options.outputFolder);
3407
3749
  return {
3408
3750
  outputFolder,
3409
3751
  open: getHtmlReportOptionProcessEnv() || this._options.open || "on-failure",
@@ -3413,8 +3755,8 @@ var HtmlReporter = class {
3413
3755
  };
3414
3756
  }
3415
3757
  _isSubdirectory(parentDir, dir) {
3416
- const relativePath = import_path8.default.relative(parentDir, dir);
3417
- return !!relativePath && !relativePath.startsWith("..") && !import_path8.default.isAbsolute(relativePath);
3758
+ const relativePath = import_path10.default.relative(parentDir, dir);
3759
+ return !!relativePath && !relativePath.startsWith("..") && !import_path10.default.isAbsolute(relativePath);
3418
3760
  }
3419
3761
  onError(error) {
3420
3762
  this._topLevelErrors.push(error);
@@ -3439,7 +3781,7 @@ var HtmlReporter = class {
3439
3781
  noSnippets,
3440
3782
  noCopyPrompt,
3441
3783
  mergeFiles
3442
- });
3784
+ }, createTestFilter(this._options, "HTML"));
3443
3785
  this._buildResult = await builder.build(this.config.metadata, projectSuites, result, this._topLevelErrors, this._machines);
3444
3786
  }
3445
3787
  async onExit() {
@@ -3451,12 +3793,14 @@ var HtmlReporter = class {
3451
3793
  await showHTMLReport(this._outputFolder, this._host, this._port, singleTestId);
3452
3794
  } else if (this._options._mode === "test" && !!process.stdin.isTTY) {
3453
3795
  const packageManagerCommand = getPackageManagerExecCommand2();
3454
- const relativeReportPath = this._outputFolder === standaloneDefaultFolder() ? "" : " " + import_path8.default.relative(process.cwd(), this._outputFolder);
3796
+ const invocationDir = process.env.INIT_CWD || process.cwd();
3797
+ const isDefaultFolder = invocationDir === process.cwd() && this._outputFolder === standaloneDefaultFolder();
3798
+ const relativeReportPath = isDefaultFolder ? "" : " " + (import_path10.default.relative(invocationDir, this._outputFolder) || ".");
3455
3799
  const hostArg = this._host ? ` --host ${this._host}` : "";
3456
3800
  const portArg = this._port ? ` --port ${this._port}` : "";
3457
- writeLine("");
3458
- writeLine("To open last HTML report run:");
3459
- writeLine(colors2.cyan(`
3801
+ writeLine2("");
3802
+ writeLine2("To open last HTML report run:");
3803
+ writeLine2(colors2.cyan(`
3460
3804
  ${packageManagerCommand} playwright show-report${relativeReportPath}${hostArg}${portArg}
3461
3805
  `));
3462
3806
  }
@@ -3464,14 +3808,14 @@ var HtmlReporter = class {
3464
3808
  };
3465
3809
  function reportFolderFromEnv() {
3466
3810
  const envValue = process.env.PLAYWRIGHT_HTML_OUTPUT_DIR || process.env.PLAYWRIGHT_HTML_REPORT;
3467
- return envValue ? import_path8.default.resolve(envValue) : void 0;
3811
+ return envValue ? import_path10.default.resolve(envValue) : void 0;
3468
3812
  }
3469
3813
  function getHtmlReportOptionProcessEnv() {
3470
3814
  const htmlOpenEnv = process.env.PLAYWRIGHT_HTML_OPEN || process.env.PW_TEST_HTML_REPORT_OPEN;
3471
3815
  if (!htmlOpenEnv)
3472
3816
  return void 0;
3473
3817
  if (!isHtmlReportOption(htmlOpenEnv)) {
3474
- writeLine(colors2.red(`Configuration Error: HTML reporter Invalid value for PLAYWRIGHT_HTML_OPEN: ${htmlOpenEnv}. Valid values are: ${htmlReportOptions.join(", ")}`));
3818
+ writeLine2(colors2.red(`Configuration Error: HTML reporter Invalid value for PLAYWRIGHT_HTML_OPEN: ${htmlOpenEnv}. Valid values are: ${htmlReportOptions.join(", ")}`));
3475
3819
  return void 0;
3476
3820
  }
3477
3821
  return htmlOpenEnv;
@@ -3485,10 +3829,10 @@ function parseBooleanEnvVar(name) {
3485
3829
  return void 0;
3486
3830
  }
3487
3831
  function standaloneDefaultFolder() {
3488
- return reportFolderFromEnv() ?? (0, import_util8.resolveReporterOutputPath)("playwright-report", process.cwd(), void 0);
3832
+ return reportFolderFromEnv() ?? (0, import_util9.resolveReporterOutputPath)("playwright-report", process.cwd(), void 0);
3489
3833
  }
3490
3834
  async function resolveReportFolder(reportPath) {
3491
- const stat = await import_fs5.default.promises.stat(reportPath).catch(() => null);
3835
+ const stat = await import_fs7.default.promises.stat(reportPath).catch(() => null);
3492
3836
  if (!stat)
3493
3837
  throw new Error(`No report found at "${reportPath}"`);
3494
3838
  if (stat.isDirectory())
@@ -3498,10 +3842,10 @@ async function resolveReportFolder(reportPath) {
3498
3842
  throw new Error(`No report found at "${reportPath}"`);
3499
3843
  }
3500
3844
  async function extractReportZip(zipPath) {
3501
- const tempDir = await import_fs5.default.promises.mkdtemp(import_path8.default.join(import_os.default.tmpdir(), "playwright-show-report-"));
3845
+ const tempDir = await import_fs7.default.promises.mkdtemp(import_path10.default.join(import_os.default.tmpdir(), "playwright-show-report-"));
3502
3846
  const cleanup = () => {
3503
3847
  try {
3504
- import_fs5.default.rmSync(tempDir, { recursive: true, force: true });
3848
+ import_fs7.default.rmSync(tempDir, { recursive: true, force: true });
3505
3849
  } catch {
3506
3850
  }
3507
3851
  };
@@ -3512,7 +3856,7 @@ async function extractReportZip(zipPath) {
3512
3856
  cleanup();
3513
3857
  throw new Error(`Failed to extract report from "${zipPath}": ${e.message}`);
3514
3858
  }
3515
- const hasIndex = await import_fs5.default.promises.access(import_path8.default.join(tempDir, "index.html")).then(() => true, () => false);
3859
+ const hasIndex = await import_fs7.default.promises.access(import_path10.default.join(tempDir, "index.html")).then(() => true, () => false);
3516
3860
  if (!hasIndex) {
3517
3861
  cleanup();
3518
3862
  throw new Error(`No "index.html" found at the top level of "${zipPath}"`);
@@ -3525,15 +3869,15 @@ async function showHTMLReport(reportFolder, host = "localhost", port, testId) {
3525
3869
  try {
3526
3870
  folder = await resolveReportFolder(requestedPath);
3527
3871
  } catch (e) {
3528
- writeLine(colors2.red(e.message));
3872
+ writeLine2(colors2.red(e.message));
3529
3873
  gracefullyProcessExitDoNotHang(1);
3530
3874
  return;
3531
3875
  }
3532
3876
  const server = false ? await serveHtmlReportWithHMR(folder) : serveFolder(folder);
3533
3877
  await server.start({ port, host, preferredPort: port ? void 0 : 9323 });
3534
3878
  let url = server.urlPrefix("human-readable");
3535
- writeLine("");
3536
- writeLine(colors2.cyan(` Serving HTML report at ${url}. Press Ctrl+C to quit.`));
3879
+ writeLine2("");
3880
+ writeLine2(colors2.cyan(` Serving HTML report at ${url}. Press Ctrl+C to quit.`));
3537
3881
  if (testId)
3538
3882
  url += `#?testId=${testId}`;
3539
3883
  url = url.replace("0.0.0.0", "localhost");
@@ -3544,7 +3888,7 @@ async function showHTMLReport(reportFolder, host = "localhost", port, testId) {
3544
3888
  });
3545
3889
  }
3546
3890
  var HtmlBuilder = class {
3547
- constructor(yazl3, config2, outputDir, attachmentsBaseURL, doNotInlineAssets, options) {
3891
+ constructor(yazl3, config2, outputDir, attachmentsBaseURL, doNotInlineAssets, options, testFilter) {
3548
3892
  this._stepsInFile = new MultiMap();
3549
3893
  this._hasTraces = false;
3550
3894
  this._dataZipFile = new yazl3.ZipFile();
@@ -3552,14 +3896,15 @@ var HtmlBuilder = class {
3552
3896
  this._reportFolder = outputDir;
3553
3897
  this._options = options;
3554
3898
  this._doNotInlineAssets = doNotInlineAssets;
3555
- import_fs5.default.mkdirSync(this._reportFolder, { recursive: true });
3899
+ this._testFilter = testFilter;
3900
+ import_fs7.default.mkdirSync(this._reportFolder, { recursive: true });
3556
3901
  this._attachmentsBaseURL = attachmentsBaseURL;
3557
3902
  }
3558
3903
  async build(metadata, projectSuites, result, topLevelErrors, machines) {
3559
3904
  const data = /* @__PURE__ */ new Map();
3560
3905
  for (const projectSuite of projectSuites) {
3561
3906
  const projectName = projectSuite.project().name;
3562
- for (const fileSuite of projectSuite.suites) {
3907
+ for (const fileSuite of filterTests(projectSuite.suites, this._testFilter)) {
3563
3908
  const fileName = this._relativeLocation(fileSuite.location).file;
3564
3909
  this._createEntryForSuite(data, projectName, fileSuite, fileName, true);
3565
3910
  }
@@ -3620,60 +3965,60 @@ var HtmlBuilder = class {
3620
3965
  }
3621
3966
  const reportIndexFile = await this._writeStaticAssets();
3622
3967
  if (this._hasTraces) {
3623
- const traceViewerFolder = import_path8.default.join(require.resolve("playwright-core"), "..", "lib", "vite", "traceViewer");
3624
- const traceViewerTargetFolder = import_path8.default.join(this._reportFolder, "trace");
3625
- const traceViewerAssetsTargetFolder = import_path8.default.join(traceViewerTargetFolder, "assets");
3626
- import_fs5.default.mkdirSync(traceViewerAssetsTargetFolder, { recursive: true });
3627
- for (const file of import_fs5.default.readdirSync(traceViewerFolder)) {
3968
+ const traceViewerFolder = import_path10.default.join(require.resolve("playwright-core"), "..", "lib", "vite", "traceViewer");
3969
+ const traceViewerTargetFolder = import_path10.default.join(this._reportFolder, "trace");
3970
+ const traceViewerAssetsTargetFolder = import_path10.default.join(traceViewerTargetFolder, "assets");
3971
+ import_fs7.default.mkdirSync(traceViewerAssetsTargetFolder, { recursive: true });
3972
+ for (const file of import_fs7.default.readdirSync(traceViewerFolder)) {
3628
3973
  if (file.endsWith(".map") || file.includes("watch") || file.includes("assets"))
3629
3974
  continue;
3630
- await copyFileAndMakeWritable(import_path8.default.join(traceViewerFolder, file), import_path8.default.join(traceViewerTargetFolder, file));
3975
+ await copyFileAndMakeWritable(import_path10.default.join(traceViewerFolder, file), import_path10.default.join(traceViewerTargetFolder, file));
3631
3976
  }
3632
- for (const file of import_fs5.default.readdirSync(import_path8.default.join(traceViewerFolder, "assets"))) {
3977
+ for (const file of import_fs7.default.readdirSync(import_path10.default.join(traceViewerFolder, "assets"))) {
3633
3978
  if (file.endsWith(".map") || file.includes("xtermModule"))
3634
3979
  continue;
3635
- await copyFileAndMakeWritable(import_path8.default.join(traceViewerFolder, "assets", file), import_path8.default.join(traceViewerAssetsTargetFolder, file));
3980
+ await copyFileAndMakeWritable(import_path10.default.join(traceViewerFolder, "assets", file), import_path10.default.join(traceViewerAssetsTargetFolder, file));
3636
3981
  }
3637
3982
  }
3638
3983
  await this._writeReportData(reportIndexFile);
3639
3984
  return { ok, singleTestId };
3640
3985
  }
3641
3986
  async _writeStaticAssets() {
3642
- const appFolder = import_path8.default.join(require.resolve("playwright-core"), "..", "lib", "vite", "htmlReport");
3643
- const reportIndexFile = import_path8.default.join(this._reportFolder, "index.html");
3987
+ const appFolder = import_path10.default.join(require.resolve("playwright-core"), "..", "lib", "vite", "htmlReport");
3988
+ const reportIndexFile = import_path10.default.join(this._reportFolder, "index.html");
3644
3989
  if (this._doNotInlineAssets) {
3645
- const html = await import_fs5.default.promises.readFile(import_path8.default.join(appFolder, "index.html"), "utf-8");
3990
+ const html = await import_fs7.default.promises.readFile(import_path10.default.join(appFolder, "index.html"), "utf-8");
3646
3991
  await Promise.all([
3647
- import_fs5.default.promises.writeFile(reportIndexFile, html),
3648
- import_fs5.default.promises.copyFile(import_path8.default.join(appFolder, "report.js"), import_path8.default.join(this._reportFolder, "report.js")),
3649
- import_fs5.default.promises.copyFile(import_path8.default.join(appFolder, "report.css"), import_path8.default.join(this._reportFolder, "report.css"))
3992
+ import_fs7.default.promises.writeFile(reportIndexFile, html),
3993
+ import_fs7.default.promises.copyFile(import_path10.default.join(appFolder, "report.js"), import_path10.default.join(this._reportFolder, "report.js")),
3994
+ import_fs7.default.promises.copyFile(import_path10.default.join(appFolder, "report.css"), import_path10.default.join(this._reportFolder, "report.css"))
3650
3995
  ]);
3651
3996
  } else {
3652
- let html = await import_fs5.default.promises.readFile(import_path8.default.join(appFolder, "index.html"), "utf-8");
3997
+ let html = await import_fs7.default.promises.readFile(import_path10.default.join(appFolder, "index.html"), "utf-8");
3653
3998
  const [js, css] = await Promise.all([
3654
- import_fs5.default.promises.readFile(import_path8.default.join(appFolder, "report.js"), "utf-8"),
3655
- import_fs5.default.promises.readFile(import_path8.default.join(appFolder, "report.css"), "utf-8")
3999
+ import_fs7.default.promises.readFile(import_path10.default.join(appFolder, "report.js"), "utf-8"),
4000
+ import_fs7.default.promises.readFile(import_path10.default.join(appFolder, "report.css"), "utf-8")
3656
4001
  ]);
3657
4002
  html = html.replace(/<script type="module"[^>]*><\/script>/, () => `<script type="module">${js}</script>`);
3658
4003
  html = html.replace(/<link rel="stylesheet"[^>]*>/, () => `<style type='text/css'>${css}</style>`);
3659
- await import_fs5.default.promises.writeFile(reportIndexFile, html);
4004
+ await import_fs7.default.promises.writeFile(reportIndexFile, html);
3660
4005
  }
3661
4006
  return reportIndexFile;
3662
4007
  }
3663
4008
  async _writeReportData(filePath) {
3664
- import_fs5.default.appendFileSync(filePath, '<template id="playwrightReportBase64">data:application/zip;base64,');
4009
+ import_fs7.default.appendFileSync(filePath, '<template id="playwrightReportBase64">data:application/zip;base64,');
3665
4010
  await new Promise((resolve, reject) => {
3666
4011
  this._dataZipFile.end(void 0, () => {
3667
- this._dataZipFile.outputStream.pipe(new Base64Encoder()).pipe(import_fs5.default.createWriteStream(filePath, { flags: "a" })).on("close", resolve).on("error", reject);
4012
+ this._dataZipFile.outputStream.pipe(new Base64Encoder()).pipe(import_fs7.default.createWriteStream(filePath, { flags: "a" })).on("close", resolve).on("error", reject);
3668
4013
  });
3669
4014
  });
3670
- import_fs5.default.appendFileSync(filePath, "</template>");
4015
+ import_fs7.default.appendFileSync(filePath, "</template>");
3671
4016
  }
3672
4017
  _addDataFile(fileName, data) {
3673
4018
  this._dataZipFile.addBuffer(Buffer.from(JSON.stringify(data)), fileName);
3674
4019
  }
3675
4020
  _createEntryForSuite(data, projectName, suite, fileName, deep) {
3676
- const fileId = calculateSha12(fileName).slice(0, 20);
4021
+ const fileId = calculateSha13(fileName).slice(0, 20);
3677
4022
  let fileEntry = data.get(fileId);
3678
4023
  if (!fileEntry) {
3679
4024
  fileEntry = {
@@ -3690,19 +4035,19 @@ var HtmlBuilder = class {
3690
4035
  testFileSummary.tests.push(test.testCaseSummary);
3691
4036
  }
3692
4037
  }
3693
- _processSuite(suite, projectName, path20, deep, outTests) {
3694
- const newPath = [...path20, suite.title];
3695
- suite.entries().forEach((e) => {
4038
+ _processSuite(suite, projectName, path22, deep, outTests) {
4039
+ const newPath = [...path22, suite.title];
4040
+ filterTests(suite.entries(), this._testFilter).forEach((e) => {
3696
4041
  if (e.type === "test")
3697
4042
  outTests.push(this._createTestEntry(e, projectName, newPath));
3698
4043
  else if (deep)
3699
4044
  this._processSuite(e, projectName, newPath, deep, outTests);
3700
4045
  });
3701
4046
  }
3702
- _createTestEntry(test, projectName, path20) {
4047
+ _createTestEntry(test, projectName, path22) {
3703
4048
  const duration = test.results.reduce((a, r) => a + r.duration, 0);
3704
4049
  const location = this._relativeLocation(test.location);
3705
- path20 = path20.slice(1).filter((path21) => path21.length > 0);
4050
+ path22 = path22.slice(1).filter((path23) => path23.length > 0);
3706
4051
  const results = test.results.map((r) => this._createTestResult(test, r));
3707
4052
  return {
3708
4053
  testCase: {
@@ -3714,7 +4059,7 @@ var HtmlBuilder = class {
3714
4059
  annotations: this._serializeAnnotations(test.annotations),
3715
4060
  tags: [...new Set(test.tags)],
3716
4061
  outcome: test.outcome(),
3717
- path: path20,
4062
+ path: path22,
3718
4063
  results,
3719
4064
  repeatEachIndex: test.repeatEachIndex || void 0,
3720
4065
  // Do not include zero.
@@ -3729,7 +4074,7 @@ var HtmlBuilder = class {
3729
4074
  annotations: this._serializeAnnotations(test.annotations),
3730
4075
  tags: [...new Set(test.tags)],
3731
4076
  outcome: test.outcome(),
3732
- path: path20,
4077
+ path: path22,
3733
4078
  ok: test.outcome() === "expected" || test.outcome() === "flaky",
3734
4079
  repeatEachIndex: test.repeatEachIndex || void 0,
3735
4080
  // Do not include zero.
@@ -3748,23 +4093,23 @@ var HtmlBuilder = class {
3748
4093
  return attachments.map((a) => {
3749
4094
  if (a.name === "trace")
3750
4095
  this._hasTraces = true;
3751
- if ((a.name === "stdout" || a.name === "stderr") && a.contentType === "text/plain") {
4096
+ if ((a.name === "stdout" || a.name === "stderr") && a.contentType === "text/plain" && typeof a.body === "string") {
3752
4097
  if (lastAttachment && lastAttachment.name === a.name && lastAttachment.contentType === a.contentType) {
3753
- lastAttachment.body += (0, import_util8.stripAnsiEscapes)(a.body);
4098
+ lastAttachment.body += (0, import_util9.stripAnsiEscapes)(a.body);
3754
4099
  return null;
3755
4100
  }
3756
- a.body = (0, import_util8.stripAnsiEscapes)(a.body);
4101
+ a.body = (0, import_util9.stripAnsiEscapes)(a.body);
3757
4102
  lastAttachment = a;
3758
4103
  return a;
3759
4104
  }
3760
4105
  if (a.path) {
3761
4106
  let fileName = a.path;
3762
4107
  try {
3763
- const buffer = import_fs5.default.readFileSync(a.path);
3764
- const sha1 = calculateSha12(buffer) + import_path8.default.extname(a.path);
4108
+ const buffer = import_fs7.default.readFileSync(a.path);
4109
+ const sha1 = calculateSha13(buffer) + import_path10.default.extname(a.path);
3765
4110
  fileName = this._attachmentsBaseURL + sha1;
3766
- import_fs5.default.mkdirSync(import_path8.default.join(this._reportFolder, "data"), { recursive: true });
3767
- import_fs5.default.writeFileSync(import_path8.default.join(this._reportFolder, "data", sha1), buffer);
4111
+ import_fs7.default.mkdirSync(import_path10.default.join(this._reportFolder, "data"), { recursive: true });
4112
+ import_fs7.default.writeFileSync(import_path10.default.join(this._reportFolder, "data", sha1), buffer);
3768
4113
  } catch (e) {
3769
4114
  }
3770
4115
  return {
@@ -3787,10 +4132,10 @@ var HtmlBuilder = class {
3787
4132
  } catch (e) {
3788
4133
  }
3789
4134
  }
3790
- import_fs5.default.mkdirSync(import_path8.default.join(this._reportFolder, "data"), { recursive: true });
3791
- const extension = sanitizeForFilePath2(import_path8.default.extname(a.name).replace(/^\./, "")) || mime2.getExtension(a.contentType) || "dat";
3792
- const sha1 = calculateSha12(a.body) + "." + extension;
3793
- import_fs5.default.writeFileSync(import_path8.default.join(this._reportFolder, "data", sha1), a.body);
4135
+ import_fs7.default.mkdirSync(import_path10.default.join(this._reportFolder, "data"), { recursive: true });
4136
+ const extension = sanitizeForFilePath2(import_path10.default.extname(a.name).replace(/^\./, "")) || mime2.getExtension(a.contentType) || "dat";
4137
+ const sha1 = calculateSha13(a.body) + "." + extension;
4138
+ import_fs7.default.writeFileSync(import_path10.default.join(this._reportFolder, "data", sha1), a.body);
3794
4139
  return {
3795
4140
  name: a.name,
3796
4141
  contentType: a.contentType,
@@ -3845,6 +4190,7 @@ var HtmlBuilder = class {
3845
4190
  title = `${title} (skipped${skipped.description ? ": " + skipped.description : ""})`;
3846
4191
  const testStep = {
3847
4192
  title,
4193
+ subtitle: step.subtitle,
3848
4194
  startTime: step.startTime.toISOString(),
3849
4195
  duration,
3850
4196
  steps: dedupeSteps(step.steps).map((s) => this._createTestStep(s, result)),
@@ -3866,7 +4212,7 @@ var HtmlBuilder = class {
3866
4212
  _relativeLocation(location) {
3867
4213
  if (!location)
3868
4214
  return void 0;
3869
- const file = toPosixPath2(import_path8.default.relative(this._config.rootDir, location.file));
4215
+ const file = toPosixPath2(import_path10.default.relative(this._config.rootDir, location.file));
3870
4216
  return {
3871
4217
  file,
3872
4218
  line: location.line,
@@ -3930,7 +4276,7 @@ function dedupeSteps(steps) {
3930
4276
  for (const step of steps) {
3931
4277
  const canDedupe = !step.error && step.duration >= 0 && step.location?.file && !step.steps.length;
3932
4278
  const lastStep = lastResult?.step;
3933
- if (canDedupe && lastResult && lastStep && step.category === lastStep.category && step.title === lastStep.title && step.location?.file === lastStep.location?.file && step.location?.line === lastStep.location?.line && step.location?.column === lastStep.location?.column) {
4279
+ if (canDedupe && lastResult && lastStep && step.category === lastStep.category && step.title === lastStep.title && step.subtitle === lastStep.subtitle && step.location?.file === lastStep.location?.file && step.location?.line === lastStep.location?.line && step.location?.column === lastStep.location?.column) {
3934
4280
  ++lastResult.count;
3935
4281
  lastResult.duration += step.duration;
3936
4282
  continue;
@@ -3946,12 +4292,12 @@ function createSnippets(stepsInFile) {
3946
4292
  for (const file of stepsInFile.keys()) {
3947
4293
  let source;
3948
4294
  try {
3949
- source = import_fs5.default.readFileSync(file, "utf-8") + "\n//";
4295
+ source = import_fs7.default.readFileSync(file, "utf-8") + "\n//";
3950
4296
  } catch (e) {
3951
4297
  continue;
3952
4298
  }
3953
4299
  const lines = source.split("\n").length;
3954
- const highlighted = babel2.codeFrameColumns(source, { start: { line: lines, column: 1 } }, { highlightCode: true, linesAbove: lines, linesBelow: 0 });
4300
+ const highlighted = codeFrame2(source, { line: lines, column: 1 }, { colors: internalScreen.colors, linesAbove: lines, linesBelow: 0 });
3955
4301
  const highlightedLines = highlighted.split("\n");
3956
4302
  const lineWithArrow = highlightedLines[highlightedLines.length - 1];
3957
4303
  for (const step of stepsInFile.get(file)) {
@@ -3968,34 +4314,31 @@ function createSnippets(stepsInFile) {
3968
4314
  function createErrorCodeframe(message, location) {
3969
4315
  let source;
3970
4316
  try {
3971
- source = import_fs5.default.readFileSync(location.file, "utf-8") + "\n//";
4317
+ source = import_fs7.default.readFileSync(location.file, "utf-8") + "\n//";
3972
4318
  } catch (e) {
3973
4319
  return;
3974
4320
  }
3975
- return babel2.codeFrameColumns(
4321
+ return codeFrame2(
3976
4322
  source,
3977
4323
  {
3978
- start: {
3979
- line: location.line,
3980
- column: location.column
3981
- }
4324
+ line: location.line,
4325
+ column: location.column
3982
4326
  },
3983
4327
  {
3984
- highlightCode: false,
3985
4328
  linesAbove: 100,
3986
4329
  linesBelow: 100,
3987
- message: (0, import_util8.stripAnsiEscapes)(message).split("\n")[0] || void 0
4330
+ message: (0, import_util9.stripAnsiEscapes)(message).split("\n")[0] || void 0
3988
4331
  }
3989
4332
  );
3990
4333
  }
3991
- function writeLine(line) {
4334
+ function writeLine2(line) {
3992
4335
  process.stdout.write(line + "\n");
3993
4336
  }
3994
4337
  var html_default = HtmlReporter;
3995
4338
 
3996
4339
  // packages/playwright/src/reporters/json.ts
3997
- var import_fs6 = __toESM(require("fs"));
3998
- var import_path9 = __toESM(require("path"));
4340
+ var import_fs8 = __toESM(require("fs"));
4341
+ var import_path11 = __toESM(require("path"));
3999
4342
  var import_common5 = require("../common");
4000
4343
  var { MultiMap: MultiMap2 } = require("playwright-core/lib/coreBundle").iso;
4001
4344
  var { toPosixPath: toPosixPath3 } = require("playwright-core/lib/coreBundle").utils;
@@ -4003,6 +4346,7 @@ var JSONReporter = class {
4003
4346
  constructor(options) {
4004
4347
  this._errors = [];
4005
4348
  this._resolvedOutputFile = resolveOutputFile("JSON", options)?.outputFile;
4349
+ this._testFilter = createTestFilter(options, "JSON");
4006
4350
  }
4007
4351
  version() {
4008
4352
  return "v2";
@@ -4053,7 +4397,7 @@ var JSONReporter = class {
4053
4397
  flaky: 0
4054
4398
  }
4055
4399
  };
4056
- for (const test of this.suite.allTests())
4400
+ for (const test of visitTests(this.suite, this._testFilter))
4057
4401
  ++report.stats[test.outcome()];
4058
4402
  return report;
4059
4403
  }
@@ -4088,7 +4432,7 @@ var JSONReporter = class {
4088
4432
  if (!location)
4089
4433
  return { file: "", line: 0, column: 0 };
4090
4434
  return {
4091
- file: toPosixPath3(import_path9.default.relative(this.config.rootDir, location.file)),
4435
+ file: toPosixPath3(import_path11.default.relative(this.config.rootDir, location.file)),
4092
4436
  line: location.line,
4093
4437
  column: location.column
4094
4438
  };
@@ -4108,7 +4452,7 @@ var JSONReporter = class {
4108
4452
  }
4109
4453
  }
4110
4454
  for (const spec of from.specs || []) {
4111
- const toSpec = to.specs.find((s) => s.title === spec.title && s.file === toPosixPath3(import_path9.default.relative(this.config.rootDir, spec.file)) && s.line === spec.line && s.column === spec.column);
4455
+ const toSpec = to.specs.find((s) => s.title === spec.title && this._locationMatches(s, spec));
4112
4456
  if (toSpec)
4113
4457
  toSpec.tests.push(...spec.tests);
4114
4458
  else
@@ -4116,13 +4460,15 @@ var JSONReporter = class {
4116
4460
  }
4117
4461
  }
4118
4462
  _serializeSuite(projectId, projectName, suite) {
4119
- if (!suite.allTests().length)
4463
+ const entries = filterTests(suite.entries(), this._testFilter);
4464
+ const suites = entries.filter((entry) => entry.type !== "test").map((suite2) => this._serializeSuite(projectId, projectName, suite2)).filter((s) => s);
4465
+ const tests = entries.filter((entry) => entry.type === "test");
4466
+ if (!tests.length && !suites.length)
4120
4467
  return null;
4121
- const suites = suite.suites.map((suite2) => this._serializeSuite(projectId, projectName, suite2)).filter((s) => s);
4122
4468
  return {
4123
4469
  title: suite.title,
4124
4470
  ...this._relativeLocation(suite.location),
4125
- specs: suite.tests.map((test) => this._serializeTestSpec(projectId, projectName, test)),
4471
+ specs: tests.map((test) => this._serializeTestSpec(projectId, projectName, test)),
4126
4472
  suites: suites.length ? suites : void 0
4127
4473
  };
4128
4474
  }
@@ -4181,6 +4527,7 @@ var JSONReporter = class {
4181
4527
  const steps = step.steps.filter((s) => s.category === "test.step");
4182
4528
  return {
4183
4529
  title: step.title,
4530
+ subtitle: step.subtitle,
4184
4531
  duration: step.duration,
4185
4532
  error: step.error,
4186
4533
  steps: steps.length ? steps.map((s) => this._serializeTestStep(s)) : void 0
@@ -4190,8 +4537,8 @@ var JSONReporter = class {
4190
4537
  async function outputReport(report, resolvedOutputFile) {
4191
4538
  const reportString = JSON.stringify(report, void 0, 2);
4192
4539
  if (resolvedOutputFile) {
4193
- await import_fs6.default.promises.mkdir(import_path9.default.dirname(resolvedOutputFile), { recursive: true });
4194
- await import_fs6.default.promises.writeFile(resolvedOutputFile, reportString);
4540
+ await import_fs8.default.promises.mkdir(import_path11.default.dirname(resolvedOutputFile), { recursive: true });
4541
+ await import_fs8.default.promises.writeFile(resolvedOutputFile, reportString);
4195
4542
  } else {
4196
4543
  console.log(reportString);
4197
4544
  }
@@ -4212,10 +4559,10 @@ function serializePatterns(patterns) {
4212
4559
  var json_default = JSONReporter;
4213
4560
 
4214
4561
  // packages/playwright/src/reporters/junit.ts
4215
- var import_fs7 = __toESM(require("fs"));
4216
- var import_path10 = __toESM(require("path"));
4217
- var import_util9 = require("../util");
4218
- var { getAsBooleanFromENV } = require("playwright-core/lib/coreBundle").utils;
4562
+ var import_fs9 = __toESM(require("fs"));
4563
+ var import_path12 = __toESM(require("path"));
4564
+ var import_util10 = require("../util");
4565
+ var { getAsBooleanFromENV: getAsBooleanFromENV5 } = require("playwright-core/lib/coreBundle").utils;
4219
4566
  var JUnitReporter = class {
4220
4567
  constructor(options) {
4221
4568
  this.totalTests = 0;
@@ -4225,9 +4572,12 @@ var JUnitReporter = class {
4225
4572
  this.stripANSIControlSequences = false;
4226
4573
  this.includeProjectInTestName = false;
4227
4574
  this.includeRetries = false;
4228
- this.stripANSIControlSequences = getAsBooleanFromENV("PLAYWRIGHT_JUNIT_STRIP_ANSI", !!options.stripANSIControlSequences);
4229
- this.includeProjectInTestName = getAsBooleanFromENV("PLAYWRIGHT_JUNIT_INCLUDE_PROJECT_IN_TEST_NAME", !!options.includeProjectInTestName);
4230
- this.includeRetries = getAsBooleanFromENV("PLAYWRIGHT_JUNIT_INCLUDE_RETRIES", !!options.includeRetries);
4575
+ this.omitTags = false;
4576
+ this.testFilter = createTestFilter(options, "JUNIT");
4577
+ this.stripANSIControlSequences = getAsBooleanFromENV5("PLAYWRIGHT_JUNIT_STRIP_ANSI", !!options.stripANSIControlSequences);
4578
+ this.includeProjectInTestName = getAsBooleanFromENV5("PLAYWRIGHT_JUNIT_INCLUDE_PROJECT_IN_TEST_NAME", !!options.includeProjectInTestName);
4579
+ this.includeRetries = !!this.testFilter || getAsBooleanFromENV5("PLAYWRIGHT_JUNIT_INCLUDE_RETRIES", !!options.includeRetries);
4580
+ this.omitTags = getAsBooleanFromENV5("PLAYWRIGHT_JUNIT_OMIT_TAGS", !!options.omitTags);
4231
4581
  this.configDir = options.configDir;
4232
4582
  this.resolvedOutputFile = resolveOutputFile("JUNIT", options)?.outputFile;
4233
4583
  }
@@ -4247,7 +4597,7 @@ var JUnitReporter = class {
4247
4597
  async onEnd(result) {
4248
4598
  const children = [];
4249
4599
  for (const projectSuite of this.suite.suites) {
4250
- for (const fileSuite of projectSuite.suites)
4600
+ for (const fileSuite of filterTests(projectSuite.suites, this.testFilter))
4251
4601
  children.push(await this._buildTestSuite(projectSuite.title, fileSuite));
4252
4602
  }
4253
4603
  const tokens = [];
@@ -4268,8 +4618,8 @@ var JUnitReporter = class {
4268
4618
  serializeXML(root, tokens, this.stripANSIControlSequences);
4269
4619
  const reportString = tokens.join("\n");
4270
4620
  if (this.resolvedOutputFile) {
4271
- await import_fs7.default.promises.mkdir(import_path10.default.dirname(this.resolvedOutputFile), { recursive: true });
4272
- await import_fs7.default.promises.writeFile(this.resolvedOutputFile, reportString);
4621
+ await import_fs9.default.promises.mkdir(import_path12.default.dirname(this.resolvedOutputFile), { recursive: true });
4622
+ await import_fs9.default.promises.writeFile(this.resolvedOutputFile, reportString);
4273
4623
  } else {
4274
4624
  console.log(reportString);
4275
4625
  }
@@ -4282,7 +4632,7 @@ var JUnitReporter = class {
4282
4632
  let duration = 0;
4283
4633
  const children = [];
4284
4634
  const testCaseNamePrefix = projectName && this.includeProjectInTestName ? `[${projectName}] ` : "";
4285
- for (const test of suite.allTests()) {
4635
+ for (const test of visitTests(suite, this.testFilter)) {
4286
4636
  ++tests;
4287
4637
  if (test.outcome() === "skipped")
4288
4638
  ++skipped;
@@ -4380,17 +4730,17 @@ var JUnitReporter = class {
4380
4730
  entry.children.push({
4381
4731
  name: errorInfo.elementName,
4382
4732
  attributes: { message: errorInfo.message, type: errorInfo.type },
4383
- text: (0, import_util9.stripAnsiEscapes)(formatFailure(nonTerminalScreen, this.config, test))
4733
+ text: (0, import_util10.stripAnsiEscapes)(formatFailure(nonTerminalScreen, this.config, test, void 0, { omitTags: this.omitTags }))
4384
4734
  });
4385
4735
  return errorInfo.elementName;
4386
4736
  }
4387
4737
  entry.children.push({
4388
4738
  name: "failure",
4389
4739
  attributes: {
4390
- message: `${import_path10.default.basename(test.location.file)}:${test.location.line}:${test.location.column} ${test.title}`,
4740
+ message: `${import_path12.default.basename(test.location.file)}:${test.location.line}:${test.location.column} ${test.title}`,
4391
4741
  type: "FAILURE"
4392
4742
  },
4393
- text: (0, import_util9.stripAnsiEscapes)(formatFailure(nonTerminalScreen, this.config, test))
4743
+ text: (0, import_util10.stripAnsiEscapes)(formatFailure(nonTerminalScreen, this.config, test, void 0, { omitTags: this.omitTags }))
4394
4744
  });
4395
4745
  return "failure";
4396
4746
  }
@@ -4405,16 +4755,16 @@ var JUnitReporter = class {
4405
4755
  for (const attachment of result.attachments) {
4406
4756
  if (!attachment.path)
4407
4757
  continue;
4408
- let attachmentPath = import_path10.default.relative(this.configDir, attachment.path);
4758
+ let attachmentPath = import_path12.default.relative(this.configDir, attachment.path);
4409
4759
  try {
4410
4760
  if (this.resolvedOutputFile)
4411
- attachmentPath = import_path10.default.relative(import_path10.default.dirname(this.resolvedOutputFile), attachment.path);
4761
+ attachmentPath = import_path12.default.relative(import_path12.default.dirname(this.resolvedOutputFile), attachment.path);
4412
4762
  } catch {
4413
4763
  systemOut.push(`
4414
4764
  Warning: Unable to make attachment path ${attachment.path} relative to report output file ${this.resolvedOutputFile}`);
4415
4765
  }
4416
4766
  try {
4417
- await import_fs7.default.promises.access(attachment.path);
4767
+ await import_fs9.default.promises.access(attachment.path);
4418
4768
  systemOut.push(`
4419
4769
  [[ATTACHMENT|${attachmentPath}]]
4420
4770
  `);
@@ -4437,7 +4787,7 @@ Warning: attachment ${attachmentPath} is missing`);
4437
4787
  children: []
4438
4788
  };
4439
4789
  const stackTrace = result.error?.stack || result.error?.message || result.error?.value || "";
4440
- entry.children.push({ name: "stackTrace", text: (0, import_util9.stripAnsiEscapes)(stackTrace) });
4790
+ entry.children.push({ name: "stackTrace", text: (0, import_util10.stripAnsiEscapes)(stackTrace) });
4441
4791
  await this._appendStdIO(entry, [result]);
4442
4792
  return entry;
4443
4793
  }
@@ -4446,7 +4796,7 @@ function classifyResultError(result) {
4446
4796
  const error = result.error;
4447
4797
  if (!error)
4448
4798
  return null;
4449
- const rawMessage = (0, import_util9.stripAnsiEscapes)(error.message || error.value || "");
4799
+ const rawMessage = (0, import_util10.stripAnsiEscapes)(error.message || error.value || "");
4450
4800
  const nameMatch = rawMessage.match(/^(\w+): /);
4451
4801
  const errorName = nameMatch ? nameMatch[1] : "";
4452
4802
  const messageBody = nameMatch ? rawMessage.slice(nameMatch[0].length) : rawMessage;
@@ -4488,7 +4838,7 @@ function serializeXML(entry, tokens, stripANSIControlSequences) {
4488
4838
  var discouragedXMLCharacters = /[\u0000-\u0008\u000b-\u000c\u000e-\u001f\u007f-\u0084\u0086-\u009f]/g;
4489
4839
  function escape(text, stripANSIControlSequences, isCharacterData) {
4490
4840
  if (stripANSIControlSequences)
4491
- text = (0, import_util9.stripAnsiEscapes)(text);
4841
+ text = (0, import_util10.stripAnsiEscapes)(text);
4492
4842
  if (isCharacterData) {
4493
4843
  text = "<![CDATA[" + text.replace(/]]>/g, "]]&gt;") + "]]>";
4494
4844
  } else {
@@ -4501,9 +4851,10 @@ function escape(text, stripANSIControlSequences, isCharacterData) {
4501
4851
  var junit_default = JUnitReporter;
4502
4852
 
4503
4853
  // packages/playwright/src/reporters/line.ts
4854
+ var { getAsBooleanFromENV: getAsBooleanFromENV6 } = require("playwright-core/lib/coreBundle").utils;
4504
4855
  var LineReporter = class extends TerminalReporter {
4505
- constructor() {
4506
- super(...arguments);
4856
+ constructor(options) {
4857
+ super({ ...options, omitTags: getAsBooleanFromENV6("PLAYWRIGHT_LINE_OMIT_TAGS", options?.omitTags) });
4507
4858
  this._current = 0;
4508
4859
  this._failures = 0;
4509
4860
  this._didBegin = false;
@@ -4553,24 +4904,6 @@ var LineReporter = class extends TerminalReporter {
4553
4904
  if (this.screen.isTTY && step.category === "test.step")
4554
4905
  this._updateLine(test, result, step.parent);
4555
4906
  }
4556
- async onTestPaused(test, result) {
4557
- if (!process.stdin.isTTY && !process.env.PW_TEST_DEBUG_REPORTERS)
4558
- return;
4559
- if (!process.env.PW_TEST_DEBUG_REPORTERS)
4560
- this.screen.stdout.write(`\x1B[1A\x1B[2K`);
4561
- if (test.outcome() === "unexpected") {
4562
- this.writeLine(this.screen.colors.red(this.formatTestHeader(test, { indent: " ", index: ++this._failures })));
4563
- this.writeLine(this.formatResultErrors(test, result));
4564
- markErrorsAsReported(result);
4565
- this.writeLine(this.screen.colors.yellow(` Paused on error. Press Ctrl+C to end.`) + "\n\n");
4566
- } else {
4567
- this.writeLine(this.screen.colors.yellow(this.formatTestHeader(test, { indent: " " })));
4568
- this.writeLine(this.screen.colors.yellow(` Paused at test end. Press Ctrl+C to end.`) + "\n\n");
4569
- }
4570
- this._updateLine(test, result, void 0);
4571
- await new Promise(() => {
4572
- });
4573
- }
4574
4907
  onTestEnd(test, result) {
4575
4908
  super.onTestEnd(test, result);
4576
4909
  if (!this.willRetry(test) && (test.outcome() === "flaky" || test.outcome() === "unexpected" || result.status === "interrupted")) {
@@ -4610,15 +4943,16 @@ var LineReporter = class extends TerminalReporter {
4610
4943
  var line_default = LineReporter;
4611
4944
 
4612
4945
  // packages/playwright/src/reporters/list.ts
4613
- var import_util10 = require("../util");
4614
- var { msToString: msToString3 } = require("playwright-core/lib/coreBundle").iso;
4615
- var { getAsBooleanFromENV: getAsBooleanFromENV2 } = require("playwright-core/lib/coreBundle").utils;
4946
+ var import_util11 = require("../util");
4947
+ var { msToString: msToString4 } = require("playwright-core/lib/coreBundle").iso;
4948
+ var { getAsBooleanFromENV: getAsBooleanFromENV7 } = require("playwright-core/lib/coreBundle").utils;
4616
4949
  var DOES_NOT_SUPPORT_UTF8_IN_TERMINAL = process.platform === "win32" && process.env.TERM_PROGRAM !== "vscode" && !process.env.WT_SESSION;
4617
4950
  var POSITIVE_STATUS_MARK = DOES_NOT_SUPPORT_UTF8_IN_TERMINAL ? "ok" : "\u2713";
4618
4951
  var NEGATIVE_STATUS_MARK = DOES_NOT_SUPPORT_UTF8_IN_TERMINAL ? "x" : "\u2718";
4619
4952
  var ListReporter = class extends TerminalReporter {
4620
4953
  constructor(options) {
4621
- super(options);
4954
+ const printFailuresInline = getAsBooleanFromENV7("PLAYWRIGHT_LIST_PRINT_FAILURES_INLINE", options?.printFailuresInline);
4955
+ super({ ...options, omitTags: getAsBooleanFromENV7("PLAYWRIGHT_LIST_OMIT_TAGS", options?.omitTags), lastResult: printFailuresInline });
4622
4956
  this._lastRow = 0;
4623
4957
  this._lastColumn = 0;
4624
4958
  this._testRows = /* @__PURE__ */ new Map();
@@ -4626,10 +4960,9 @@ var ListReporter = class extends TerminalReporter {
4626
4960
  this._resultIndex = /* @__PURE__ */ new Map();
4627
4961
  this._stepIndex = /* @__PURE__ */ new Map();
4628
4962
  this._needNewLine = false;
4629
- this._failureIndex = 0;
4630
- this._paused = /* @__PURE__ */ new Set();
4631
- this._printSteps = getAsBooleanFromENV2("PLAYWRIGHT_LIST_PRINT_STEPS", options?.printSteps);
4632
- this._printFailuresInline = getAsBooleanFromENV2("PLAYWRIGHT_LIST_PRINT_FAILURES_INLINE", options?.printFailuresInline);
4963
+ this._failureIndex = /* @__PURE__ */ new Map();
4964
+ this._printSteps = getAsBooleanFromENV7("PLAYWRIGHT_LIST_PRINT_STEPS", options?.printSteps);
4965
+ this._printFailuresInline = printFailuresInline;
4633
4966
  }
4634
4967
  onBegin(suite) {
4635
4968
  super.onBegin(suite);
@@ -4700,7 +5033,7 @@ var ListReporter = class extends TerminalReporter {
4700
5033
  text = this.screen.colors.red(title);
4701
5034
  else
4702
5035
  text = title;
4703
- text += this.screen.colors.dim(` (${msToString3(step.duration)})`);
5036
+ text += this.screen.colors.dim(` (${msToString4(step.duration)})`);
4704
5037
  this._updateOrAppendLine(this._stepRows, step, text, prefix);
4705
5038
  }
4706
5039
  _maybeWriteNewLine() {
@@ -4735,34 +5068,21 @@ var ListReporter = class extends TerminalReporter {
4735
5068
  this._updateLineCountAndNewLineFlagForOutput(text);
4736
5069
  stream.write(chunk);
4737
5070
  }
4738
- async onTestPaused(test, result) {
4739
- if (!process.stdin.isTTY && !process.env.PW_TEST_DEBUG_REPORTERS)
4740
- return;
4741
- this._paused.add(result);
4742
- this._updateTestLine(test, result);
4743
- this._maybeWriteNewLine();
4744
- if (test.outcome() === "unexpected") {
4745
- const errors = this.formatResultErrors(test, result);
4746
- this.writeLine(errors);
4747
- this._updateLineCountAndNewLineFlagForOutput(errors);
4748
- markErrorsAsReported(result);
4749
- }
4750
- this._appendLine(this.screen.colors.yellow(`Paused ${test.outcome() === "unexpected" ? "on error" : "at test end"}. Press Ctrl+C to end.`), this._testPrefix("", ""));
4751
- await new Promise(() => {
4752
- });
4753
- }
4754
5071
  onTestEnd(test, result) {
4755
5072
  super.onTestEnd(test, result);
4756
- const wasPaused = this._paused.delete(result);
4757
- if (!wasPaused)
4758
- this._updateTestLine(test, result);
4759
- const isFailure = result.status !== "skipped" && result.status !== test.expectedStatus;
4760
- if (!wasPaused && this._printFailuresInline && isFailure)
5073
+ this._updateTestLine(test, result);
5074
+ const isFailure2 = result.status !== "skipped" && result.status !== test.expectedStatus;
5075
+ if (this._printFailuresInline && isFailure2)
4761
5076
  this._printFailure(test);
4762
5077
  }
4763
5078
  _printFailure(test) {
4764
5079
  this._maybeWriteNewLine();
4765
- const message = "\n" + this.formatFailure(test, ++this._failureIndex) + "\n";
5080
+ let index = this._failureIndex.get(test);
5081
+ if (index === void 0) {
5082
+ index = this._failureIndex.size + 1;
5083
+ this._failureIndex.set(test, index);
5084
+ }
5085
+ const message = "\n" + this.formatFailure(test, index) + "\n";
4766
5086
  this._updateLineCountAndNewLineFlagForOutput(message);
4767
5087
  this.screen.stdout.write(message);
4768
5088
  }
@@ -4787,7 +5107,7 @@ var ListReporter = class extends TerminalReporter {
4787
5107
  prefix = this._testPrefix(index, this.screen.colors.red(statusMark));
4788
5108
  text = this.screen.colors.red(title);
4789
5109
  }
4790
- text += this._retrySuffix(result) + this.screen.colors.dim(` (${msToString3(result.duration)})`);
5110
+ text += this._retrySuffix(result) + this.screen.colors.dim(` (${msToString4(result.duration)})`);
4791
5111
  }
4792
5112
  this._updateOrAppendLine(this._testRows, test, text, prefix);
4793
5113
  }
@@ -4828,7 +5148,7 @@ var ListReporter = class extends TerminalReporter {
4828
5148
  this.screen.stdout.write(`\x1B[${this._lastRow - row}E`);
4829
5149
  }
4830
5150
  _testPrefix(index, statusMark) {
4831
- const statusMarkLength = (0, import_util10.stripAnsiEscapes)(statusMark).length;
5151
+ const statusMarkLength = (0, import_util11.stripAnsiEscapes)(statusMark).length;
4832
5152
  const indexLength = Math.ceil(Math.log10(this.totalTestCount + 1));
4833
5153
  return " " + statusMark + " ".repeat(3 - statusMarkLength) + this.screen.colors.dim(index.padStart(indexLength) + " ");
4834
5154
  }
@@ -4852,7 +5172,7 @@ var lastStepOrdinalSymbol = /* @__PURE__ */ Symbol("lastStepOrdinal");
4852
5172
  var list_default = ListReporter;
4853
5173
 
4854
5174
  // packages/playwright/src/reporters/listModeReporter.ts
4855
- var import_path11 = __toESM(require("path"));
5175
+ var import_path13 = __toESM(require("path"));
4856
5176
  var ListModeReporter = class {
4857
5177
  constructor(options = {}) {
4858
5178
  this._options = options;
@@ -4870,7 +5190,7 @@ var ListModeReporter = class {
4870
5190
  const files = /* @__PURE__ */ new Set();
4871
5191
  for (const test of tests) {
4872
5192
  const [, projectName, , ...titles] = test.titlePath();
4873
- const location = `${import_path11.default.relative(this.config.rootDir, test.location.file)}:${test.location.line}:${test.location.column}`;
5193
+ const location = `${import_path13.default.relative(this.config.rootDir, test.location.file)}:${test.location.line}:${test.location.column}`;
4874
5194
  const testId = this._options.includeTestId ? `[id=${test.id}] ` : "";
4875
5195
  const projectLabel = this._options.includeTestId ? `project=` : "";
4876
5196
  const projectTitle = projectName ? `[${projectLabel}${projectName}] \u203A ` : "";
@@ -4888,28 +5208,290 @@ var ListModeReporter = class {
4888
5208
  };
4889
5209
  var listModeReporter_default = ListModeReporter;
4890
5210
 
5211
+ // packages/playwright/src/reporters/perfetto.ts
5212
+ var import_events2 = require("events");
5213
+ var import_fs10 = __toESM(require("fs"));
5214
+ var import_path14 = __toESM(require("path"));
5215
+ var import_zlib = __toESM(require("zlib"));
5216
+ var import_coreBundle2 = require("playwright-core/lib/coreBundle");
5217
+ var import_util12 = require("../util");
5218
+ var { toPosixPath: toPosixPath4 } = require("playwright-core/lib/coreBundle").utils;
5219
+ var kStatusColors = {
5220
+ passed: "good",
5221
+ failed: "bad",
5222
+ timedOut: "terrible",
5223
+ interrupted: "yellow",
5224
+ skipped: "grey"
5225
+ };
5226
+ var kProcessId = 1;
5227
+ var kRunThreadId = 0;
5228
+ var PerfettoReporter = class {
5229
+ constructor(options) {
5230
+ this._events = [];
5231
+ this._laneEndTime = /* @__PURE__ */ new Map();
5232
+ this._globalErrors = [];
5233
+ this._resolvedOutputFile = resolveOutputFile("PERFETTO", {
5234
+ ...options,
5235
+ default: {
5236
+ fileName: "perfetto.json",
5237
+ outputDir: "test-results"
5238
+ }
5239
+ }).outputFile;
5240
+ }
5241
+ version() {
5242
+ return "v2";
5243
+ }
5244
+ printsToStdio() {
5245
+ return false;
5246
+ }
5247
+ onConfigure(config2) {
5248
+ this._config = config2;
5249
+ }
5250
+ onBegin(suite) {
5251
+ this._suite = suite;
5252
+ }
5253
+ onError(error) {
5254
+ this._globalErrors.push({ error, timestamp: Date.now() });
5255
+ }
5256
+ async onEnd(result) {
5257
+ const entries = [];
5258
+ for (const test of this._suite?.allTests() ?? []) {
5259
+ for (const testResult of test.results)
5260
+ entries.push({ test, result: testResult });
5261
+ }
5262
+ entries.sort((a, b) => a.result.startTime.getTime() - b.result.startTime.getTime());
5263
+ for (const entry of entries)
5264
+ this._appendTestResult(entry.test, entry.result);
5265
+ for (const { error, timestamp } of this._globalErrors) {
5266
+ this._events.push({
5267
+ name: "error",
5268
+ cat: "error",
5269
+ ph: "i",
5270
+ s: "g",
5271
+ ts: timestamp,
5272
+ pid: kProcessId,
5273
+ tid: kRunThreadId,
5274
+ cname: "bad",
5275
+ args: { error: this._formatError(error) }
5276
+ });
5277
+ }
5278
+ await this._writeReport(result);
5279
+ }
5280
+ _appendTestResult(test, result) {
5281
+ const startMs = result.startTime.getTime();
5282
+ let endMs = startMs + Math.max(0, result.duration);
5283
+ for (const step of result.steps)
5284
+ endMs = Math.max(endMs, stepEndTime(step));
5285
+ const lane = this._allocateLane(result.parallelIndex, startMs);
5286
+ this._laneEndTime.set(lane, endMs);
5287
+ const tid = lane + 1;
5288
+ this._events.push({
5289
+ name: test.title,
5290
+ cat: "test",
5291
+ ph: "X",
5292
+ ts: startMs,
5293
+ dur: endMs - startMs,
5294
+ pid: kProcessId,
5295
+ tid,
5296
+ cname: kStatusColors[result.status],
5297
+ args: this._testArgs(test, result)
5298
+ });
5299
+ for (const step of result.steps)
5300
+ this._appendStep(step, tid, startMs, endMs);
5301
+ }
5302
+ _allocateLane(preferredLane, startMs) {
5303
+ const preferred = Math.max(0, preferredLane);
5304
+ if (!(this._laneEndTime.get(preferred) > startMs))
5305
+ return preferred;
5306
+ for (let lane = 0; ; ++lane) {
5307
+ if (!(this._laneEndTime.get(lane) > startMs))
5308
+ return lane;
5309
+ }
5310
+ }
5311
+ _appendStep(step, tid, parentStart, parentEnd) {
5312
+ const stepStart = step.startTime.getTime();
5313
+ const startMs = clamp(stepStart, parentStart, parentEnd);
5314
+ const endMs = clamp(step.duration >= 0 ? stepStart + step.duration : parentEnd, startMs, parentEnd);
5315
+ this._events.push({
5316
+ name: step.subtitle ? `${step.title} ${step.subtitle}` : step.title,
5317
+ cat: step.category,
5318
+ ph: "X",
5319
+ ts: startMs,
5320
+ dur: endMs - startMs,
5321
+ pid: kProcessId,
5322
+ tid,
5323
+ cname: step.error ? "bad" : void 0,
5324
+ args: this._stepArgs(step)
5325
+ });
5326
+ for (const child of step.steps)
5327
+ this._appendStep(child, tid, startMs, endMs);
5328
+ }
5329
+ _testArgs(test, result) {
5330
+ const [, projectName, , ...titles] = test.titlePath();
5331
+ const args = {
5332
+ status: result.status,
5333
+ expectedStatus: test.expectedStatus,
5334
+ testId: test.id,
5335
+ workerIndex: result.workerIndex,
5336
+ parallelIndex: result.parallelIndex,
5337
+ timeout: test.timeout,
5338
+ location: this._formatLocation(test.location)
5339
+ };
5340
+ if (titles.length > 1)
5341
+ args.title = titles.join(" \u203A ");
5342
+ if (projectName)
5343
+ args.project = projectName;
5344
+ if (result.retry)
5345
+ args.retry = result.retry;
5346
+ if (test.tags.length)
5347
+ args.tags = test.tags.join(" ");
5348
+ if (result.annotations.length)
5349
+ args.annotations = result.annotations.map((annotation) => formatAnnotation(annotation));
5350
+ if (result.attachments.length)
5351
+ args.attachments = result.attachments.map((attachment) => this._formatAttachment(attachment));
5352
+ if (result.errors.length)
5353
+ args.errors = result.errors.map((error) => this._formatError(error));
5354
+ const stdout = concatChunks(result.stdout);
5355
+ if (stdout)
5356
+ args.stdout = stdout;
5357
+ const stderr = concatChunks(result.stderr);
5358
+ if (stderr)
5359
+ args.stderr = stderr;
5360
+ return args;
5361
+ }
5362
+ _stepArgs(step) {
5363
+ const args = {};
5364
+ if (step.params)
5365
+ args.params = step.params;
5366
+ if (step.location)
5367
+ args.location = this._formatLocation(step.location);
5368
+ if (step.annotations.length)
5369
+ args.annotations = step.annotations.map((annotation) => formatAnnotation(annotation));
5370
+ if (step.attachments.length)
5371
+ args.attachments = step.attachments.map((attachment) => this._formatAttachment(attachment));
5372
+ if (step.error)
5373
+ args.error = this._formatError(step.error);
5374
+ return Object.keys(args).length ? args : void 0;
5375
+ }
5376
+ _formatAttachment(attachment) {
5377
+ return attachment.path ? this._relativePath(attachment.path) : attachment.name;
5378
+ }
5379
+ _formatLocation(location) {
5380
+ if (!location)
5381
+ return void 0;
5382
+ return `${this._relativePath(location.file)}:${location.line}:${location.column}`;
5383
+ }
5384
+ _formatError(error) {
5385
+ return (0, import_util12.stripAnsiEscapes)(formatError(nonTerminalScreen, error).message);
5386
+ }
5387
+ _relativePath(file) {
5388
+ return toPosixPath4(import_path14.default.relative(this._config.rootDir, file));
5389
+ }
5390
+ async _writeReport(result) {
5391
+ let timeOrigin2 = result.startTime.getTime();
5392
+ for (const event of this._events)
5393
+ timeOrigin2 = Math.min(timeOrigin2, event.ts);
5394
+ const metadataEvents = [
5395
+ { name: "process_name", cat: "__metadata", ph: "M", ts: 0, pid: kProcessId, tid: kRunThreadId, args: { name: "Playwright Test" } },
5396
+ { name: "process_sort_index", cat: "__metadata", ph: "M", ts: 0, pid: kProcessId, tid: kRunThreadId, args: { sort_index: 0 } }
5397
+ ];
5398
+ for (const lane of [...this._laneEndTime.keys()].sort((a, b) => a - b)) {
5399
+ metadataEvents.push({ name: "thread_name", cat: "__metadata", ph: "M", ts: 0, pid: kProcessId, tid: lane + 1, args: { name: `Worker ${lane}` } });
5400
+ metadataEvents.push({ name: "thread_sort_index", cat: "__metadata", ph: "M", ts: 0, pid: kProcessId, tid: lane + 1, args: { sort_index: lane + 1 } });
5401
+ }
5402
+ this._events.sort((a, b) => a.ts - b.ts);
5403
+ for (const event of this._events) {
5404
+ event.ts = Math.round((event.ts - timeOrigin2) * 1e3);
5405
+ if (event.dur !== void 0)
5406
+ event.dur = Math.round(event.dur * 1e3);
5407
+ }
5408
+ const metadata = {
5409
+ "playwright-version": (0, import_coreBundle2.getPlaywrightVersion)(),
5410
+ "start-time": result.startTime.toISOString(),
5411
+ "duration": result.duration,
5412
+ "status": result.status
5413
+ };
5414
+ await import_fs10.default.promises.mkdir(import_path14.default.dirname(this._resolvedOutputFile), { recursive: true });
5415
+ const writer = new ChunkWriter(this._resolvedOutputFile);
5416
+ await writer.write('{"traceEvents":[');
5417
+ let separator2 = "";
5418
+ for (const events of [metadataEvents, this._events]) {
5419
+ for (const event of events) {
5420
+ await writer.write(separator2 + JSON.stringify(event));
5421
+ separator2 = ",";
5422
+ }
5423
+ }
5424
+ await writer.write(`],"displayTimeUnit":"ms","metadata":${JSON.stringify(metadata)}}`);
5425
+ await writer.close();
5426
+ }
5427
+ };
5428
+ var ChunkWriter = class {
5429
+ constructor(file) {
5430
+ const fileStream = import_fs10.default.createWriteStream(file);
5431
+ const gzip = file.endsWith(".gz") ? import_zlib.default.createGzip() : void 0;
5432
+ gzip?.pipe(fileStream);
5433
+ this._stream = gzip ?? fileStream;
5434
+ if (gzip)
5435
+ fileStream.on("error", (error) => gzip.destroy(error));
5436
+ this._closed = new Promise((resolve) => fileStream.on("close", resolve));
5437
+ for (const stream of /* @__PURE__ */ new Set([this._stream, fileStream]))
5438
+ stream.on("error", (error) => this._error ??= error);
5439
+ }
5440
+ async write(chunk) {
5441
+ if (this._error)
5442
+ throw this._error;
5443
+ if (!this._stream.write(chunk))
5444
+ await (0, import_events2.once)(this._stream, "drain");
5445
+ }
5446
+ async close() {
5447
+ this._stream.end();
5448
+ await this._closed;
5449
+ if (this._error)
5450
+ throw this._error;
5451
+ }
5452
+ };
5453
+ function stepEndTime(step) {
5454
+ let end = step.startTime.getTime() + Math.max(0, step.duration);
5455
+ for (const child of step.steps)
5456
+ end = Math.max(end, stepEndTime(child));
5457
+ return end;
5458
+ }
5459
+ function formatAnnotation(annotation) {
5460
+ return annotation.description ? `${annotation.type}: ${annotation.description}` : annotation.type;
5461
+ }
5462
+ function clamp(value, min, max) {
5463
+ return Math.min(Math.max(value, min), max);
5464
+ }
5465
+ function concatChunks(chunks) {
5466
+ return chunks.map((chunk) => typeof chunk === "string" ? chunk : chunk.toString("utf8")).join("");
5467
+ }
5468
+ var perfetto_default = PerfettoReporter;
5469
+
4891
5470
  // packages/playwright/src/runner/reporters.ts
4892
- var { calculateSha1: calculateSha13 } = require("playwright-core/lib/coreBundle").utils;
5471
+ var { calculateSha1: calculateSha14 } = require("playwright-core/lib/coreBundle").utils;
4893
5472
  async function createReporters(config2, mode, descriptions, runOptions) {
4894
5473
  const defaultReporters = {
4895
- blob: BlobReporter,
4896
- dot: mode === "list" ? listModeReporter_default : dot_default,
4897
- line: mode === "list" ? listModeReporter_default : line_default,
4898
- list: mode === "list" ? listModeReporter_default : list_default,
4899
- github: github_default,
4900
- json: json_default,
4901
- junit: junit_default,
4902
- null: empty_default,
4903
- html: html_default
5474
+ "blob": BlobReporter,
5475
+ "perfetto": perfetto_default,
5476
+ "dot": mode === "list" ? listModeReporter_default : dot_default,
5477
+ "failures": mode === "list" ? listModeReporter_default : failures_default,
5478
+ "line": mode === "list" ? listModeReporter_default : line_default,
5479
+ "list": mode === "list" ? listModeReporter_default : list_default,
5480
+ "github": github_default,
5481
+ "json": json_default,
5482
+ "junit": junit_default,
5483
+ "null": empty_default,
5484
+ "html": html_default,
5485
+ "coverage": coverage_default
4904
5486
  };
4905
5487
  const reporters = [];
4906
5488
  descriptions ??= config2.config.reporter;
4907
- if (runOptions?.additionalReporters)
4908
- descriptions = [...descriptions, ...runOptions.additionalReporters];
4909
5489
  const reportOptions = reporterCommandOptions(config2, mode, runOptions);
4910
5490
  for (const r of descriptions) {
4911
5491
  const [name, arg] = r;
4912
5492
  const options = { ...reportOptions, ...arg };
5493
+ if (mode === "list")
5494
+ options.onlyFailures = false;
4913
5495
  if (name in defaultReporters) {
4914
5496
  reporters.push(new defaultReporters[name](options));
4915
5497
  } else {
@@ -4969,27 +5551,30 @@ function computeCommandHash(config2, runOptions) {
4969
5551
  if (config2.config.tags.length)
4970
5552
  command.tags = config2.config.tags.join(" ");
4971
5553
  if (runOptions?.testList)
4972
- command.testList = calculateSha13(import_fs8.default.readFileSync(runOptions.testList));
5554
+ command.testList = calculateSha14(import_fs11.default.readFileSync(runOptions.testList));
4973
5555
  if (runOptions?.testListInvert)
4974
- command.testListInvert = calculateSha13(import_fs8.default.readFileSync(runOptions.testListInvert));
5556
+ command.testListInvert = calculateSha14(import_fs11.default.readFileSync(runOptions.testListInvert));
4975
5557
  if (Object.keys(command).length)
4976
- parts.push(calculateSha13(JSON.stringify(command)).substring(0, 7));
5558
+ parts.push(calculateSha14(JSON.stringify(command)).substring(0, 7));
4977
5559
  return parts.join("-");
4978
5560
  }
4979
5561
 
4980
5562
  // packages/playwright/src/runner/tasks.ts
4981
- var import_fs11 = __toESM(require("fs"));
4982
- var import_path15 = __toESM(require("path"));
4983
- var import_util13 = require("util");
5563
+ var import_fs14 = __toESM(require("fs"));
5564
+ var import_path18 = __toESM(require("path"));
5565
+ var import_util15 = require("util");
5566
+
5567
+ // packages/playwright/src/runner/dispatcher.ts
5568
+ var import_buffer = require("buffer");
4984
5569
 
4985
5570
  // packages/playwright/src/runner/rebase.ts
4986
- var import_fs9 = __toESM(require("fs"));
4987
- var import_path12 = __toESM(require("path"));
4988
- var babel3 = __toESM(require("../transform/babelBundle"));
5571
+ var import_fs12 = __toESM(require("fs"));
5572
+ var import_path15 = __toESM(require("path"));
5573
+ var babel = __toESM(require("../transform/babelBundle"));
4989
5574
  var colors3 = require("playwright-core/lib/utilsBundle").colors;
4990
5575
  var diff = require("playwright-core/lib/utilsBundle").diff;
4991
5576
  var { MultiMap: MultiMap3 } = require("playwright-core/lib/coreBundle").iso;
4992
- var t = babel3.types;
5577
+ var t = babel.types;
4993
5578
  var suggestedRebaselines = new MultiMap3();
4994
5579
  function addSuggestedRebaseline(location, suggestedRebaseline) {
4995
5580
  suggestedRebaselines.set(location.file, { location, code: suggestedRebaseline });
@@ -5008,16 +5593,16 @@ async function applySuggestedRebaselines(config2, reporter, filteredProjects) {
5008
5593
  const patches = [];
5009
5594
  const files = [];
5010
5595
  const gitCache = /* @__PURE__ */ new Map();
5011
- const patchFile = import_path12.default.join(project.project.outputDir, "rebaselines.patch");
5596
+ const patchFile = import_path15.default.join(project.project.outputDir, "rebaselines.patch");
5012
5597
  for (const fileName of [...suggestedRebaselines.keys()].sort()) {
5013
- const source = await import_fs9.default.promises.readFile(fileName, "utf8");
5598
+ const source = await import_fs12.default.promises.readFile(fileName, "utf8");
5014
5599
  const lines = source.split("\n");
5015
5600
  const replacements = suggestedRebaselines.get(fileName);
5016
- const fileNode = babel3.babelParse(source, fileName, true);
5601
+ const fileNode = babel.babelParse(source, fileName, true);
5017
5602
  const ranges = [];
5018
- babel3.traverse(fileNode, {
5019
- CallExpression: (path20) => {
5020
- const node = path20.node;
5603
+ babel.traverse(fileNode, {
5604
+ CallExpression: (path22) => {
5605
+ const node = path22.node;
5021
5606
  if (node.arguments.length < 1)
5022
5607
  return;
5023
5608
  if (!t.isMemberExpression(node.callee))
@@ -5044,15 +5629,15 @@ async function applySuggestedRebaselines(config2, reporter, filteredProjects) {
5044
5629
  let result = source;
5045
5630
  for (const range of ranges)
5046
5631
  result = result.substring(0, range.start) + range.newText + result.substring(range.end);
5047
- const relativeName = import_path12.default.relative(process.cwd(), fileName);
5632
+ const relativeName = import_path15.default.relative(process.cwd(), fileName);
5048
5633
  files.push(relativeName);
5049
5634
  if (config2.config.updateSourceMethod === "overwrite") {
5050
- await import_fs9.default.promises.writeFile(fileName, result);
5635
+ await import_fs12.default.promises.writeFile(fileName, result);
5051
5636
  } else if (config2.config.updateSourceMethod === "3way") {
5052
- await import_fs9.default.promises.writeFile(fileName, applyPatchWithConflictMarkers(source, result));
5637
+ await import_fs12.default.promises.writeFile(fileName, applyPatchWithConflictMarkers(source, result));
5053
5638
  } else {
5054
- const gitFolder = findGitRoot(import_path12.default.dirname(fileName), gitCache);
5055
- const relativeToGit = import_path12.default.relative(gitFolder || process.cwd(), fileName);
5639
+ const gitFolder = findGitRoot(import_path15.default.dirname(fileName), gitCache);
5640
+ const relativeToGit = import_path15.default.relative(gitFolder || process.cwd(), fileName);
5056
5641
  patches.push(createPatch(relativeToGit, source, result));
5057
5642
  }
5058
5643
  }
@@ -5063,10 +5648,10 @@ New baselines created for:
5063
5648
  ${fileList}
5064
5649
  `);
5065
5650
  if (config2.config.updateSourceMethod === "patch") {
5066
- await import_fs9.default.promises.mkdir(import_path12.default.dirname(patchFile), { recursive: true });
5067
- await import_fs9.default.promises.writeFile(patchFile, patches.join("\n"));
5651
+ await import_fs12.default.promises.mkdir(import_path15.default.dirname(patchFile), { recursive: true });
5652
+ await import_fs12.default.promises.writeFile(patchFile, patches.join("\n"));
5068
5653
  reporter.onStdErr(`
5069
- ` + colors3.cyan("git apply " + import_path12.default.relative(process.cwd(), patchFile)) + "\n");
5654
+ ` + colors3.cyan("git apply " + import_path15.default.relative(process.cwd(), patchFile)) + "\n");
5070
5655
  }
5071
5656
  }
5072
5657
  function createPatch(fileName, before, after) {
@@ -5083,12 +5668,12 @@ function findGitRoot(dir, cache) {
5083
5668
  const result = cache.get(dir);
5084
5669
  if (result !== void 0)
5085
5670
  return result;
5086
- const gitPath = import_path12.default.join(dir, ".git");
5087
- if (import_fs9.default.existsSync(gitPath) && import_fs9.default.lstatSync(gitPath).isDirectory()) {
5671
+ const gitPath = import_path15.default.join(dir, ".git");
5672
+ if (import_fs12.default.existsSync(gitPath) && import_fs12.default.lstatSync(gitPath).isDirectory()) {
5088
5673
  cache.set(dir, dir);
5089
5674
  return dir;
5090
5675
  }
5091
- const parentDir = import_path12.default.dirname(dir);
5676
+ const parentDir = import_path15.default.dirname(dir);
5092
5677
  if (dir === parentDir) {
5093
5678
  cache.set(dir, null);
5094
5679
  return null;
@@ -5132,8 +5717,8 @@ function applyPatchWithConflictMarkers(oldText, newText) {
5132
5717
  }
5133
5718
 
5134
5719
  // packages/playwright/src/runner/workerHost.ts
5135
- var import_fs10 = __toESM(require("fs"));
5136
- var import_path13 = __toESM(require("path"));
5720
+ var import_fs13 = __toESM(require("fs"));
5721
+ var import_path16 = __toESM(require("path"));
5137
5722
  var import_common6 = require("../common");
5138
5723
 
5139
5724
  // packages/playwright/src/isomorphic/folders.ts
@@ -5162,13 +5747,13 @@ var WorkerHost = class extends ProcessHost {
5162
5747
  repeatEachIndex: testGroup.repeatEachIndex,
5163
5748
  projectId: testGroup.projectId,
5164
5749
  config: options.config,
5165
- artifactsDir: import_path13.default.join(options.outputDir, artifactsFolderName(workerIndex)),
5750
+ artifactsDir: import_path16.default.join(options.outputDir, artifactsFolderName(workerIndex)),
5166
5751
  pauseOnError: options.pauseOnError,
5167
5752
  pauseAtEnd: options.pauseAtEnd
5168
5753
  };
5169
5754
  }
5170
5755
  async start() {
5171
- await import_fs10.default.promises.mkdir(this._params.artifactsDir, { recursive: true });
5756
+ await import_fs13.default.promises.mkdir(this._params.artifactsDir, { recursive: true });
5172
5757
  return await this.startRunner(this._params, {
5173
5758
  onStdOut: (chunk) => this.emit("stdOut", import_common6.ipc.stdioChunkToParams(chunk)),
5174
5759
  onStdErr: (chunk) => this.emit("stdErr", import_common6.ipc.stdioChunkToParams(chunk))
@@ -5188,9 +5773,6 @@ var WorkerHost = class extends ProcessHost {
5188
5773
  async sendCustomMessage(payload) {
5189
5774
  return await this.sendMessage({ method: "customMessage", params: payload });
5190
5775
  }
5191
- sendResume(payload) {
5192
- this.sendMessageNoReply({ method: "resume", params: payload });
5193
- }
5194
5776
  hash() {
5195
5777
  return this._hash;
5196
5778
  }
@@ -5204,16 +5786,16 @@ var WorkerHost = class extends ProcessHost {
5204
5786
 
5205
5787
  // packages/playwright/src/runner/dispatcher.ts
5206
5788
  var import_common7 = require("../common");
5207
- var import_util11 = require("../util");
5789
+ var import_util13 = require("../util");
5208
5790
  var colors4 = require("playwright-core/lib/utilsBundle").colors;
5209
5791
  var { ManualPromise: ManualPromise3 } = require("playwright-core/lib/coreBundle").iso;
5210
5792
  var { eventsHelper } = require("playwright-core/lib/coreBundle").utils;
5793
+ var exclusiveLock = "-exclusive-";
5211
5794
  var Dispatcher = class {
5212
5795
  constructor(testRun, options = {}) {
5213
5796
  // Worker slot is claimed when it has jobDispatcher assigned.
5214
5797
  this._workerSlots = [];
5215
5798
  this._queue = [];
5216
- this._isolatedJobs = /* @__PURE__ */ new Set();
5217
5799
  this._workerLimitPerProjectId = /* @__PURE__ */ new Map();
5218
5800
  this._queuedOrRunningHashCount = /* @__PURE__ */ new Map();
5219
5801
  this._finished = new ManualPromise3();
@@ -5227,10 +5809,24 @@ var Dispatcher = class {
5227
5809
  this._workerLimitPerProjectId.set(project.id, project.workers);
5228
5810
  }
5229
5811
  }
5812
+ _heldLocks() {
5813
+ const heldLocks = /* @__PURE__ */ new Set();
5814
+ for (const slot of this._workerSlots) {
5815
+ for (const lock of slot.jobDispatcher?.job.locks || [])
5816
+ heldLocks.add(lock);
5817
+ }
5818
+ return heldLocks;
5819
+ }
5230
5820
  _findFirstJobToRun() {
5821
+ const heldLocks = this._heldLocks();
5822
+ if (heldLocks.has(exclusiveLock))
5823
+ return -1;
5824
+ const hasRunningJobs = this._workerSlots.some((w) => !!w.jobDispatcher);
5231
5825
  for (let index = 0; index < this._queue.length; index++) {
5232
5826
  const job = this._queue[index];
5233
- if (this._isolatedJobs.has(job) && this._workerSlots.some((w) => !!w.jobDispatcher))
5827
+ if (hasRunningJobs && job.locks.includes(exclusiveLock))
5828
+ continue;
5829
+ if (job.locks.some((lock) => heldLocks.has(lock)))
5234
5830
  continue;
5235
5831
  const projectIdWorkerLimit = this._workerLimitPerProjectId.get(job.projectId);
5236
5832
  if (!projectIdWorkerLimit)
@@ -5241,18 +5837,22 @@ var Dispatcher = class {
5241
5837
  }
5242
5838
  return -1;
5243
5839
  }
5840
+ _scheduleJobs() {
5841
+ while (this._scheduleJob()) {
5842
+ }
5843
+ }
5244
5844
  _scheduleJob() {
5245
- if (this._isStopped)
5246
- return;
5845
+ if (this._isStopped || !this._workerSlots.some((w) => !w.jobDispatcher))
5846
+ return false;
5247
5847
  const jobIndex = this._findFirstJobToRun();
5248
5848
  if (jobIndex === -1)
5249
- return;
5849
+ return false;
5250
5850
  const job = this._queue[jobIndex];
5251
5851
  let workerIndex = this._workerSlots.findIndex((w) => !w.jobDispatcher && w.worker && w.worker.hash() === job.workerHash && !w.worker.didSendStop());
5252
5852
  if (workerIndex === -1)
5253
5853
  workerIndex = this._workerSlots.findIndex((w) => !w.jobDispatcher);
5254
5854
  if (workerIndex === -1) {
5255
- return;
5855
+ return false;
5256
5856
  }
5257
5857
  this._queue.splice(jobIndex, 1);
5258
5858
  const jobDispatcher = new JobDispatcher(job, this._testRun, this._ignoreMaxFailures ? void 0 : () => this.stop().catch(() => {
@@ -5261,8 +5861,9 @@ var Dispatcher = class {
5261
5861
  void this._runJobInWorker(workerIndex, jobDispatcher).then(() => {
5262
5862
  this._workerSlots[workerIndex].jobDispatcher = void 0;
5263
5863
  this._checkFinished();
5264
- this._scheduleJob();
5864
+ this._scheduleJobs();
5265
5865
  });
5866
+ return true;
5266
5867
  }
5267
5868
  async _runJobInWorker(index, jobDispatcher) {
5268
5869
  const job = jobDispatcher.job;
@@ -5303,7 +5904,6 @@ var Dispatcher = class {
5303
5904
  this._updateCounterForWorkerHash(result.remainingJob.workerHash, 1);
5304
5905
  }
5305
5906
  if (result.isolatedRetriesJob) {
5306
- this._isolatedJobs.add(result.isolatedRetriesJob);
5307
5907
  this._queue.push(result.isolatedRetriesJob);
5308
5908
  this._updateCounterForWorkerHash(result.isolatedRetriesJob.workerHash, 1);
5309
5909
  }
@@ -5340,8 +5940,7 @@ var Dispatcher = class {
5340
5940
  void this.stop();
5341
5941
  for (let i = 0; i < this._testRun.config.config.workers; i++)
5342
5942
  this._workerSlots.push({});
5343
- for (let i = 0; i < this._workerSlots.length; i++)
5344
- this._scheduleJob();
5943
+ this._scheduleJobs();
5345
5944
  this._checkFinished();
5346
5945
  await this._finished;
5347
5946
  }
@@ -5459,8 +6058,8 @@ var JobDispatcher = class {
5459
6058
  test.annotations = [...params.annotations];
5460
6059
  test.expectedStatus = params.expectedStatus;
5461
6060
  test.timeout = params.timeout;
5462
- const isFailure = result.status !== "skipped" && result.status !== test.expectedStatus;
5463
- if (isFailure)
6061
+ const isFailure2 = result.status !== "skipped" && result.status !== test.expectedStatus;
6062
+ if (isFailure2)
5464
6063
  this._failedTests.add(test);
5465
6064
  if (params.hasNonRetriableError)
5466
6065
  this._addNonretriableTestAndSerialModeParents(test);
@@ -5483,12 +6082,14 @@ var JobDispatcher = class {
5483
6082
  const parentStep = params.parentStepId ? steps.get(params.parentStepId) : void 0;
5484
6083
  const step = {
5485
6084
  title: params.title,
6085
+ subtitle: params.subtitle,
5486
6086
  titlePath: () => {
5487
6087
  const parentPath = parentStep?.titlePath() || [];
5488
6088
  return [...parentPath, params.title];
5489
6089
  },
5490
6090
  parent: parentStep,
5491
6091
  category: params.category,
6092
+ params: params.params,
5492
6093
  startTime: new Date(params.wallTime),
5493
6094
  duration: -1,
5494
6095
  steps: [],
@@ -5628,7 +6229,7 @@ var JobDispatcher = class {
5628
6229
  }
5629
6230
  }
5630
6231
  const remainingJob = remaining.length ? { ...this.job, tests: remaining } : void 0;
5631
- const isolatedRetriesJob = isolatedRetries.length ? { ...this.job, tests: isolatedRetries } : void 0;
6232
+ const isolatedRetriesJob = isolatedRetries.length ? { ...this.job, tests: isolatedRetries, locks: [.../* @__PURE__ */ new Set([...this.job.locks, exclusiveLock])] } : void 0;
5632
6233
  this._finished({ didFail: true, remainingJob, isolatedRetriesJob });
5633
6234
  }
5634
6235
  onExit(data) {
@@ -5666,7 +6267,7 @@ var JobDispatcher = class {
5666
6267
  const data = this._dataByTestId.get(params.testId);
5667
6268
  if (!data)
5668
6269
  return;
5669
- const { result, test } = data;
6270
+ const { test } = data;
5670
6271
  const sendMessage = async (message) => {
5671
6272
  try {
5672
6273
  if (this.jobResult.isDone())
@@ -5676,18 +6277,14 @@ var JobDispatcher = class {
5676
6277
  addLocationAndSnippetToError(this._testRun.config.config, response.error);
5677
6278
  return response;
5678
6279
  } catch (e) {
5679
- const error = (0, import_util11.serializeError)(e);
6280
+ const error = (0, import_util13.serializeError)(e);
5680
6281
  addLocationAndSnippetToError(this._testRun.config.config, error);
5681
6282
  return { response: void 0, error };
5682
6283
  }
5683
6284
  };
5684
- result.status = params.status;
5685
- result.errors = params.errors;
5686
- result.error = result.errors[0];
5687
- void this._testRun.reporter.onTestPaused?.(test, result).then(() => {
5688
- worker.sendResume({});
5689
- });
5690
- this._testRun.onTestPaused({ ...params, sendMessage });
6285
+ for (const error of params.errors)
6286
+ addLocationAndSnippetToError(this._testRun.config.config, error, test.location.file);
6287
+ this._testRun.onTestPaused({ errors: params.errors, sendMessage });
5691
6288
  }
5692
6289
  skipWholeJob() {
5693
6290
  const allTestsSkipped = this.job.tests.every((test) => test.expectedStatus === "skipped");
@@ -5720,7 +6317,8 @@ var JobDispatcher = class {
5720
6317
  function chunkFromParams(params) {
5721
6318
  if (typeof params.text === "string")
5722
6319
  return params.text;
5723
- return Buffer.from(params.buffer, "base64");
6320
+ const buffer = Buffer.from(params.buffer, "base64");
6321
+ return (0, import_buffer.isUtf8)(buffer) ? buffer.toString("utf8") : buffer;
5724
6322
  }
5725
6323
 
5726
6324
  // packages/playwright/src/runner/sigIntWatcher.ts
@@ -5795,11 +6393,11 @@ var FixedNodeSIGINTHandler = class {
5795
6393
  };
5796
6394
 
5797
6395
  // packages/playwright/src/runner/taskRunner.ts
5798
- var import_util12 = require("../util");
6396
+ var import_util14 = require("../util");
5799
6397
  var colors5 = require("playwright-core/lib/utilsBundle").colors;
5800
6398
  var debug4 = require("playwright-core/lib/utilsBundle").debug;
5801
6399
  var { ManualPromise: ManualPromise4 } = require("playwright-core/lib/coreBundle").iso;
5802
- var { monotonicTime: monotonicTime5 } = require("playwright-core/lib/coreBundle").iso;
6400
+ var { monotonicTime: monotonicTime4 } = require("playwright-core/lib/coreBundle").iso;
5803
6401
  var TaskRunner = class _TaskRunner {
5804
6402
  constructor(reporter, globalTimeoutForError) {
5805
6403
  this._tasks = [];
@@ -5836,7 +6434,7 @@ var TaskRunner = class _TaskRunner {
5836
6434
  await task.setup?.(context, errors, softErrors);
5837
6435
  } catch (e) {
5838
6436
  debug4("pw:test:task")(`error in "${task.title}": `, e);
5839
- errors.push((0, import_util12.serializeError)(e));
6437
+ errors.push((0, import_util14.serializeError)(e));
5840
6438
  } finally {
5841
6439
  for (const error of [...softErrors, ...errors])
5842
6440
  this._reporter.onError?.(error);
@@ -5878,7 +6476,7 @@ var TimeoutWatcher = class {
5878
6476
  this.promise = new ManualPromise4();
5879
6477
  if (!deadline)
5880
6478
  return;
5881
- if (deadline - monotonicTime5() <= 0) {
6479
+ if (deadline - monotonicTime4() <= 0) {
5882
6480
  this._timedOut = true;
5883
6481
  this.promise.resolve();
5884
6482
  return;
@@ -5886,7 +6484,7 @@ var TimeoutWatcher = class {
5886
6484
  this._timer = setTimeout(() => {
5887
6485
  this._timedOut = true;
5888
6486
  this.promise.resolve();
5889
- }, deadline - monotonicTime5());
6487
+ }, deadline - monotonicTime4());
5890
6488
  }
5891
6489
  timedOut() {
5892
6490
  return this._timedOut;
@@ -5898,16 +6496,16 @@ var TimeoutWatcher = class {
5898
6496
 
5899
6497
  // packages/playwright/src/runner/vcs.ts
5900
6498
  var import_child_process2 = __toESM(require("child_process"));
5901
- var import_path14 = __toESM(require("path"));
6499
+ var import_path17 = __toESM(require("path"));
5902
6500
  var import_common8 = require("../common");
5903
6501
  async function detectChangedTestFiles(baseCommit, configDir) {
5904
- function gitFileList(args) {
6502
+ function gitFileList(args, separator2 = "\n") {
5905
6503
  try {
5906
6504
  return import_child_process2.default.execFileSync(
5907
6505
  "git",
5908
6506
  args,
5909
6507
  { encoding: "utf-8", stdio: "pipe", cwd: configDir }
5910
- ).split("\n").filter(Boolean);
6508
+ ).split(separator2).filter(Boolean);
5911
6509
  } catch (_error) {
5912
6510
  const error = _error;
5913
6511
  const unknownRevision = error.output.some((line) => line?.includes("unknown revision"));
@@ -5928,20 +6526,20 @@ async function detectChangedTestFiles(baseCommit, configDir) {
5928
6526
  ].join("\n"));
5929
6527
  }
5930
6528
  }
5931
- const untrackedFiles = gitFileList(["ls-files", "--others", "--exclude-standard"]).map((file) => import_path14.default.join(configDir, file));
6529
+ const untrackedFiles = gitFileList(["ls-files", "--others", "--exclude-standard", "-z"], "\0").map((file) => import_path17.default.join(configDir, file));
5932
6530
  const [gitRoot] = gitFileList(["rev-parse", "--show-toplevel"]);
5933
- const trackedFilesWithChanges = gitFileList(["diff", baseCommit, "--name-only"]).map((file) => import_path14.default.join(gitRoot, file));
6531
+ const trackedFilesWithChanges = gitFileList(["diff", baseCommit, "--name-only", "-z"], "\0").map((file) => import_path17.default.join(gitRoot, file));
5934
6532
  return new Set(import_common8.cc.affectedTestFiles([...untrackedFiles, ...trackedFilesWithChanges]));
5935
6533
  }
5936
6534
 
5937
6535
  // packages/playwright/src/runner/tasks.ts
5938
6536
  var import_common9 = require("../common");
5939
- var import_util14 = require("../util");
6537
+ var import_util16 = require("../util");
5940
6538
  var debug5 = require("playwright-core/lib/utilsBundle").debug;
5941
6539
  var { ManualPromise: ManualPromise5 } = require("playwright-core/lib/coreBundle").iso;
5942
- var { monotonicTime: monotonicTime6 } = require("playwright-core/lib/coreBundle").iso;
6540
+ var { monotonicTime: monotonicTime5 } = require("playwright-core/lib/coreBundle").iso;
5943
6541
  var { removeFolders: removeFolders4 } = require("playwright-core/lib/coreBundle").utils;
5944
- var readDirAsync2 = (0, import_util13.promisify)(import_fs11.default.readdir);
6542
+ var readDirAsync2 = (0, import_util15.promisify)(import_fs14.default.readdir);
5945
6543
  var TestRun = class {
5946
6544
  constructor(config2, reporter, options) {
5947
6545
  this.rootSuite = void 0;
@@ -5951,13 +6549,15 @@ var TestRun = class {
5951
6549
  this.topLevelProjects = [];
5952
6550
  this.hasWorkerErrors = false;
5953
6551
  this.failedTestCount = 0;
6552
+ this.testCountBeforeSharding = 0;
5954
6553
  this.loadFileFilters = [];
5955
6554
  this.preOnlyTestFilters = [];
5956
6555
  this.postShardTestFilters = [];
5957
6556
  this.config = config2;
5958
6557
  this.options = options ?? {};
5959
6558
  this.reporter = reporter;
5960
- this.filteredProjects = filterProjects(config2.projects, this.options.projectFilter);
6559
+ this.filteredProjects = filterProjects(config2.projects, this.options.projectFilter, this.options.includeNonDefaultProjects);
6560
+ config2.config.filteredProjects = this.filteredProjects.map((p) => p.project);
5961
6561
  }
5962
6562
  onTestPaused(params) {
5963
6563
  this.options.onTestPaused?.(params);
@@ -5973,7 +6573,7 @@ var TestRun = class {
5973
6573
  }
5974
6574
  };
5975
6575
  async function runTasks(testRun, tasks, globalTimeout, cancelPromise) {
5976
- const deadline = globalTimeout ? monotonicTime6() + globalTimeout : 0;
6576
+ const deadline = globalTimeout ? monotonicTime5() + globalTimeout : 0;
5977
6577
  const taskRunner = new TaskRunner(testRun.reporter, globalTimeout || 0);
5978
6578
  for (const task of tasks)
5979
6579
  taskRunner.addTask(task);
@@ -6012,7 +6612,6 @@ function createRunTestsTasks(config2) {
6012
6612
  return [
6013
6613
  createPhasesTask(),
6014
6614
  createReportBeginTask(),
6015
- ...config2.plugins.map((plugin) => createPluginBeginTask(plugin)),
6016
6615
  createRunTestsTask()
6017
6616
  ];
6018
6617
  }
@@ -6020,9 +6619,7 @@ function createClearCacheTask(config2) {
6020
6619
  return {
6021
6620
  title: "clear cache",
6022
6621
  setup: async () => {
6023
- await (0, import_util14.removeDirAndLogToConsole)(import_common9.cc.cacheDir);
6024
- for (const plugin of config2.plugins)
6025
- await plugin.instance?.clearCache?.();
6622
+ await (0, import_util16.removeDirAndLogToConsole)(import_common9.cc.cacheDir);
6026
6623
  }
6027
6624
  };
6028
6625
  }
@@ -6051,17 +6648,6 @@ function createPluginSetupTasks(config2) {
6051
6648
  }
6052
6649
  }));
6053
6650
  }
6054
- function createPluginBeginTask(plugin) {
6055
- return {
6056
- title: "plugin begin",
6057
- setup: async (testRun) => {
6058
- await plugin.instance?.begin?.(testRun.rootSuite);
6059
- },
6060
- teardown: async () => {
6061
- await plugin.instance?.end?.();
6062
- }
6063
- };
6064
- }
6065
6651
  function createGlobalSetupTask(file, config2) {
6066
6652
  let title = "global setup";
6067
6653
  if (config2.globalSetups.length > 1)
@@ -6104,7 +6690,7 @@ function createRemoveOutputDirsTask() {
6104
6690
  return;
6105
6691
  if (error.code === "EBUSY") {
6106
6692
  const entries = await readDirAsync2(outputDir).catch((e) => []);
6107
- await Promise.all(entries.map((entry) => removeFolders4([import_path15.default.join(outputDir, entry)])));
6693
+ await Promise.all(entries.map((entry) => removeFolders4([import_path18.default.join(outputDir, entry)])));
6108
6694
  } else {
6109
6695
  throw error;
6110
6696
  }
@@ -6123,7 +6709,7 @@ function createListFilesTask() {
6123
6709
  projectSuite._fullProject = project;
6124
6710
  testRun.rootSuite._addSuite(projectSuite);
6125
6711
  const suites = files.map((file) => {
6126
- const title = import_path15.default.relative(testRun.config.config.rootDir, file);
6712
+ const title = import_path18.default.relative(testRun.config.config.rootDir, file);
6127
6713
  const suite = new import_common9.test.Suite(title, "file");
6128
6714
  suite.location = { file, line: 0, column: 0 };
6129
6715
  projectSuite._addSuite(suite);
@@ -6153,8 +6739,8 @@ function createLoadTask(mode, options) {
6153
6739
  testRun.preOnlyTestFilters.push((test) => !testFilter(test));
6154
6740
  }
6155
6741
  if (testRun.options.grep || testRun.options.grepInvert) {
6156
- const grepMatcher = testRun.options.grep ? (0, import_util14.createTitleMatcher)((0, import_util14.forceRegExp)(testRun.options.grep)) : () => true;
6157
- const grepInvertMatcher = testRun.options.grepInvert ? (0, import_util14.createTitleMatcher)((0, import_util14.forceRegExp)(testRun.options.grepInvert)) : () => false;
6742
+ const grepMatcher = testRun.options.grep ? (0, import_util16.createTitleMatcher)((0, import_util16.forceRegExp)(testRun.options.grep)) : () => true;
6743
+ const grepInvertMatcher = testRun.options.grepInvert ? (0, import_util16.createTitleMatcher)((0, import_util16.forceRegExp)(testRun.options.grepInvert)) : () => false;
6158
6744
  testRun.preOnlyTestFilters.push((test) => {
6159
6745
  const grepTitle = test._grepTitleWithTags();
6160
6746
  return !grepInvertMatcher(grepTitle) && grepMatcher(grepTitle);
@@ -6166,16 +6752,13 @@ function createLoadTask(mode, options) {
6166
6752
  }
6167
6753
  await collectProjectsAndTestFiles(testRun, !!options.doNotRunDepsOutsideProjectFilter);
6168
6754
  await loadFileSuites(testRun, mode, options.failOnLoadErrors ? errors : softErrors);
6169
- if (testRun.options.onlyChanged || options.populateDependencies) {
6170
- for (const plugin of testRun.config.plugins)
6171
- await plugin.instance?.populateDependencies?.();
6172
- }
6173
6755
  if (testRun.options.onlyChanged) {
6174
6756
  const changedFiles = await detectChangedTestFiles(testRun.options.onlyChanged, testRun.config.configDir);
6175
6757
  testRun.preOnlyTestFilters.push((test) => changedFiles.has(test.location.file));
6176
6758
  }
6177
6759
  await createRootSuite(testRun, options.failOnLoadErrors ? errors : softErrors, !!options.filterOnly);
6178
- if (options.failOnLoadErrors && !testRun.rootSuite?.allTests().length && !testRun.options.passWithNoTests && !testRun.config.config.shard && !testRun.options.onlyChanged && !testRun.options.testList && !testRun.options.testListInvert) {
6760
+ const testCount = testRun.config.config.shard ? testRun.testCountBeforeSharding : testRun.rootSuite?.allTests().length;
6761
+ if (options.failOnLoadErrors && !testCount && !testRun.options.passWithNoTests && !testRun.options.onlyChanged && !testRun.options.testList && !testRun.options.testListInvert) {
6179
6762
  if (testRun.options.locations?.length) {
6180
6763
  throw new Error([
6181
6764
  `No tests found.`,
@@ -6245,6 +6828,8 @@ function createPhasesTask() {
6245
6828
  }
6246
6829
  }
6247
6830
  testRun.config.config.metadata.actualWorkers = Math.min(testRun.config.config.workers, maxConcurrentTestGroups);
6831
+ if (testRun.config.configCLIOverrides.shuffle)
6832
+ testRun.config.config.metadata.shuffleSeed = testRun.config.configCLIOverrides.shuffle;
6248
6833
  }
6249
6834
  };
6250
6835
  }
@@ -6268,6 +6853,8 @@ function createRunTestsTask() {
6268
6853
  if (!hasFailedDeps)
6269
6854
  phaseTestGroups.push(...testGroups);
6270
6855
  }
6856
+ if (testRun.config.configCLIOverrides.shuffle)
6857
+ shuffleTestGroups(phaseTestGroups, testRun.config.configCLIOverrides.shuffle);
6271
6858
  if (phaseTestGroups.length) {
6272
6859
  await dispatcher.run(phaseTestGroups, extraEnvByProjectId);
6273
6860
  await dispatcher.stop();
@@ -6293,25 +6880,32 @@ function createRunTestsTask() {
6293
6880
  }
6294
6881
 
6295
6882
  // packages/playwright/src/runner/lastRun.ts
6296
- var import_fs12 = __toESM(require("fs"));
6297
- var import_path16 = __toESM(require("path"));
6883
+ var import_fs15 = __toESM(require("fs"));
6884
+ var import_path19 = __toESM(require("path"));
6885
+ function didNotRun(test) {
6886
+ if (test.outcome() !== "skipped")
6887
+ return false;
6888
+ if (test.results.some((result) => result.status === "interrupted"))
6889
+ return false;
6890
+ return !test.results.length || test.expectedStatus !== "skipped";
6891
+ }
6298
6892
  var LastRunReporter = class {
6299
6893
  constructor(filteredProjects, listMode, lastFailedFileOverride) {
6300
6894
  this._listMode = !!listMode;
6301
6895
  const override = lastFailedFileOverride ?? process.env.PLAYWRIGHT_LAST_RUN_OUTPUT_FILE;
6302
6896
  if (override) {
6303
- this._lastRunFile = import_path16.default.resolve(process.cwd(), override);
6897
+ this._lastRunFile = import_path19.default.resolve(process.cwd(), override);
6304
6898
  } else {
6305
6899
  const [project] = filteredProjects;
6306
6900
  if (project)
6307
- this._lastRunFile = import_path16.default.join(project.project.outputDir, ".last-run.json");
6901
+ this._lastRunFile = import_path19.default.join(project.project.outputDir, ".last-run.json");
6308
6902
  }
6309
6903
  }
6310
6904
  async filterLastFailed() {
6311
6905
  if (!this._lastRunFile)
6312
6906
  return void 0;
6313
6907
  try {
6314
- const lastRunInfo = JSON.parse(await import_fs12.default.promises.readFile(this._lastRunFile, "utf8"));
6908
+ const lastRunInfo = JSON.parse(await import_fs15.default.promises.readFile(this._lastRunFile, "utf8"));
6315
6909
  return lastRunInfo.failedTests;
6316
6910
  } catch {
6317
6911
  return void 0;
@@ -6331,10 +6925,10 @@ var LastRunReporter = class {
6331
6925
  return;
6332
6926
  const lastRunInfo = {
6333
6927
  status: result.status,
6334
- failedTests: this._suite?.allTests().filter((t2) => !t2.ok()).map((t2) => t2.id) || []
6928
+ failedTests: this._suite?.allTests().filter((t2) => !t2.ok() || didNotRun(t2)).map((t2) => t2.id) || []
6335
6929
  };
6336
- await import_fs12.default.promises.mkdir(import_path16.default.dirname(this._lastRunFile), { recursive: true });
6337
- await import_fs12.default.promises.writeFile(this._lastRunFile, JSON.stringify(lastRunInfo, void 0, 2));
6930
+ await import_fs15.default.promises.mkdir(import_path19.default.dirname(this._lastRunFile), { recursive: true });
6931
+ await import_fs15.default.promises.writeFile(this._lastRunFile, JSON.stringify(lastRunInfo, void 0, 2));
6338
6932
  }
6339
6933
  };
6340
6934
 
@@ -6346,7 +6940,7 @@ var TestRunnerEvent = {
6346
6940
  TestFilesChanged: "testFilesChanged",
6347
6941
  TestPaused: "testPaused"
6348
6942
  };
6349
- var TestRunner = class extends import_events2.default {
6943
+ var TestRunner = class extends import_events3.default {
6350
6944
  constructor(configLocation, configCLIOverrides) {
6351
6945
  super();
6352
6946
  this._watchedProjectDirs = /* @__PURE__ */ new Set();
@@ -6354,20 +6948,18 @@ var TestRunner = class extends import_events2.default {
6354
6948
  this._watchedTestDependencies = /* @__PURE__ */ new Set();
6355
6949
  this._queue = Promise.resolve();
6356
6950
  this._watchTestDirs = false;
6357
- this._populateDependenciesOnList = false;
6358
6951
  this._startingEnv = {};
6359
6952
  this.configLocation = configLocation;
6360
6953
  this._configCLIOverrides = configCLIOverrides;
6361
- this._watcher = new FSWatcher((events) => {
6954
+ this._watcher = new FSWatcher((files) => {
6362
6955
  const collector = /* @__PURE__ */ new Set();
6363
- events.forEach((f) => import_common10.cc.collectAffectedTestFiles(f.file, collector));
6956
+ files.forEach((file) => import_common10.cc.collectAffectedTestFiles(file, collector));
6364
6957
  this.emit(TestRunnerEvent.TestFilesChanged, [...collector]);
6365
6958
  });
6366
6959
  }
6367
6960
  async initialize(params) {
6368
6961
  setPlaywrightTestProcessEnv();
6369
6962
  this._watchTestDirs = !!params.watchTestDirs;
6370
- this._populateDependenciesOnList = !!params.populateDependenciesOnList;
6371
6963
  this._startingEnv = { ...process.env };
6372
6964
  }
6373
6965
  resizeTerminal(params) {
@@ -6379,7 +6971,7 @@ var TestRunner = class extends import_events2.default {
6379
6971
  hasSomeBrowsers() {
6380
6972
  for (const browserName of ["chromium", "webkit", "firefox"]) {
6381
6973
  try {
6382
- import_coreBundle2.registry.registry.findExecutable(browserName).executablePathOrDie("javascript");
6974
+ import_coreBundle3.registry.registry.findExecutable(browserName).executablePathOrDie("javascript");
6383
6975
  return true;
6384
6976
  } catch {
6385
6977
  }
@@ -6387,8 +6979,8 @@ var TestRunner = class extends import_events2.default {
6387
6979
  return false;
6388
6980
  }
6389
6981
  async installBrowsers() {
6390
- const executables = import_coreBundle2.registry.registry.defaultExecutables();
6391
- await import_coreBundle2.registry.registry.install(executables);
6982
+ const executables = import_coreBundle3.registry.registry.defaultExecutables();
6983
+ await import_coreBundle3.registry.registry.install(executables);
6392
6984
  }
6393
6985
  async loadConfig() {
6394
6986
  const { config: config2, error } = await this._loadConfig(this._configCLIOverrides);
@@ -6428,7 +7020,6 @@ var TestRunner = class extends import_events2.default {
6428
7020
  if (!config2)
6429
7021
  return { status: "failed" };
6430
7022
  const status = await runTasks(new TestRun(config2, reporter), [
6431
- ...createPluginSetupTasks(config2),
6432
7023
  createClearCacheTask(config2)
6433
7024
  ]);
6434
7025
  return { status };
@@ -6438,7 +7029,7 @@ var TestRunner = class extends import_events2.default {
6438
7029
  const config2 = await this._loadConfigOrReportError(reporter);
6439
7030
  if (!config2)
6440
7031
  return { status: "failed" };
6441
- const options = { projectFilter: projects?.length ? projects : void 0 };
7032
+ const options = { projectFilter: projects?.length ? projects : void 0, includeNonDefaultProjects: true };
6442
7033
  const status = await runTasks(new TestRun(config2, reporter, options), [
6443
7034
  createListFilesTask(),
6444
7035
  createReportBeginTask()
@@ -6471,11 +7062,13 @@ var TestRunner = class extends import_events2.default {
6471
7062
  grep: params.grep,
6472
7063
  grepInvert: params.grepInvert,
6473
7064
  projectFilter: params.projects?.length ? params.projects : void 0,
7065
+ // Non-default projects are listed so that they can be selected by name.
7066
+ includeNonDefaultProjects: true,
6474
7067
  onlyChanged: params.onlyChanged ? "HEAD" : void 0,
6475
7068
  listMode: true
6476
7069
  };
6477
7070
  const status = await runTasks(new TestRun(config2, reporter, options), [
6478
- createLoadTask("out-of-process", { failOnLoadErrors: false, filterOnly: false, populateDependencies: this._populateDependenciesOnList }),
7071
+ createLoadTask("out-of-process", { failOnLoadErrors: false, filterOnly: false }),
6479
7072
  createReportBeginTask()
6480
7073
  ]);
6481
7074
  return { config: config2, status };
@@ -6487,16 +7080,14 @@ var TestRunner = class extends import_events2.default {
6487
7080
  this._watchedProjectDirs.add(p.project.testDir);
6488
7081
  this._ignoredProjectOutputs.add(p.project.outputDir);
6489
7082
  }
6490
- const result = await resolveCtDirs(config2);
6491
- if (result) {
6492
- this._watchedProjectDirs.add(result.templateDir);
6493
- this._ignoredProjectOutputs.add(result.outDir);
6494
- }
6495
7083
  if (this._watchTestDirs)
6496
7084
  await this._updateWatcher(false);
6497
7085
  }
6498
7086
  async _updateWatcher(reportPending) {
6499
- await this._watcher.update([...this._watchedProjectDirs, ...this._watchedTestDependencies], [...this._ignoredProjectOutputs], reportPending);
7087
+ await this._watcher.update({
7088
+ paths: [...this._watchedProjectDirs, ...this._watchedTestDependencies],
7089
+ ignoredFolders: [...this._ignoredProjectOutputs]
7090
+ }, reportPending);
6500
7091
  }
6501
7092
  async runTests(userReporter, params) {
6502
7093
  let result = { status: "passed" };
@@ -6582,7 +7173,7 @@ var TestRunner = class extends import_events2.default {
6582
7173
  return { errors: errorReporter.errors(), testFiles: [] };
6583
7174
  const status = await runTasks(new TestRun(config2, reporter), [
6584
7175
  ...createPluginSetupTasks(config2),
6585
- createLoadTask("out-of-process", { failOnLoadErrors: true, filterOnly: false, populateDependencies: true })
7176
+ createLoadTask("out-of-process", { failOnLoadErrors: true, filterOnly: false })
6586
7177
  ]);
6587
7178
  if (status !== "passed")
6588
7179
  return { errors: errorReporter.errors(), testFiles: [] };
@@ -6611,7 +7202,7 @@ var TestRunner = class extends import_events2.default {
6611
7202
  this._lastLoadedConfig = config2;
6612
7203
  return { config: config2 };
6613
7204
  } catch (e) {
6614
- return { config: null, error: (0, import_util15.serializeError)(e) };
7205
+ return { config: null, error: (0, import_util17.serializeError)(e) };
6615
7206
  }
6616
7207
  }
6617
7208
  lastLoadedConfig() {
@@ -6631,18 +7222,6 @@ var TestRunner = class extends import_events2.default {
6631
7222
  function printInternalError(e) {
6632
7223
  console.error("Internal error:", e);
6633
7224
  }
6634
- async function resolveCtDirs(config2) {
6635
- const use = config2.config.projects[0].use;
6636
- const relativeTemplateDir = use.ctTemplateDir || "playwright";
6637
- const templateDir = await import_fs13.default.promises.realpath(import_path17.default.normalize(import_path17.default.join(config2.configDir, relativeTemplateDir))).catch(() => void 0);
6638
- if (!templateDir)
6639
- return null;
6640
- const outDir = use.ctCacheDir ? import_path17.default.resolve(config2.configDir, use.ctCacheDir) : import_path17.default.resolve(templateDir, ".cache");
6641
- return {
6642
- outDir,
6643
- templateDir
6644
- };
6645
- }
6646
7225
  async function runAllTestsWithConfig(config2, options) {
6647
7226
  setPlaywrightTestProcessEnv();
6648
7227
  addGitCommitInfoPlugin(config2);
@@ -6665,7 +7244,7 @@ async function runAllTestsWithConfig(config2, options) {
6665
7244
  createLoadTask("in-process", { filterOnly: true, failOnLoadErrors: true }),
6666
7245
  ...createRunTestsTasks(config2)
6667
7246
  ];
6668
- const testRun = new TestRun(config2, reporter, { ...options, pauseAtEnd: config2.configCLIOverrides.pause, pauseOnError: config2.configCLIOverrides.pause });
7247
+ const testRun = new TestRun(config2, reporter, options);
6669
7248
  const status = await runTasks(testRun, tasks, config2.config.globalTimeout);
6670
7249
  await new Promise((resolve) => process.stdout.write("", () => resolve()));
6671
7250
  await new Promise((resolve) => process.stderr.write("", () => resolve()));
@@ -6679,8 +7258,8 @@ __export(testServer_exports, {
6679
7258
  runTestServer: () => runTestServer,
6680
7259
  runUIMode: () => runUIMode
6681
7260
  });
6682
- var import_util16 = __toESM(require("util"));
6683
- var import_coreBundle3 = require("playwright-core/lib/coreBundle");
7261
+ var import_util18 = __toESM(require("util"));
7262
+ var import_coreBundle4 = require("playwright-core/lib/coreBundle");
6684
7263
  var import_common11 = require("../common");
6685
7264
 
6686
7265
  // packages/playwright/src/runner/uiModeReporter.ts
@@ -6709,7 +7288,7 @@ var TestServer = class {
6709
7288
  }
6710
7289
  async start(options) {
6711
7290
  this._dispatcher = new TestServerDispatcher(this._configLocation, this._configCLIOverrides);
6712
- return await import_coreBundle3.server.startTraceViewerServer({
7291
+ return await import_coreBundle4.server.startTraceViewerServer({
6713
7292
  host: options.host,
6714
7293
  port: options.port,
6715
7294
  allowedFileRoots: () => this._allowedFileRoots(),
@@ -6839,7 +7418,7 @@ var TestServerDispatcher = class {
6839
7418
  if (interceptStdio) {
6840
7419
  if (debug6.log === originalDebugLog) {
6841
7420
  debug6.log = (...args) => {
6842
- const string = import_util16.default.format(...args) + "\n";
7421
+ const string = import_util18.default.format(...args) + "\n";
6843
7422
  return originalStderrWrite.apply(process.stderr, [string]);
6844
7423
  };
6845
7424
  }
@@ -6865,12 +7444,13 @@ var TestServerDispatcher = class {
6865
7444
  async function runUIMode(configFile, configCLIOverrides, options) {
6866
7445
  const configLocation = import_common11.configLoader.resolveConfigLocation(configFile);
6867
7446
  return await innerRunTestServer(configLocation, configCLIOverrides, options, async (server, cancelPromise) => {
6868
- await import_coreBundle3.server.installRootRedirect(server, void 0, { ...options, webApp: "uiMode.html" });
7447
+ const uiModePath = import_coreBundle4.server.traceViewerPath(void 0, { ...options, webApp: "uiMode.html" });
6869
7448
  if (options.host !== void 0 || options.port !== void 0) {
6870
- await import_coreBundle3.server.openTraceInBrowser(server.urlPrefix("human-readable"));
7449
+ server.installRootRedirect(uiModePath);
7450
+ await import_coreBundle4.server.openTraceInBrowser(server.rootUrl("human-readable"));
6871
7451
  } else {
6872
7452
  const channel = await installedChromiumChannelForUI(configLocation, configCLIOverrides);
6873
- const page = await import_coreBundle3.server.openTraceViewerApp(server.urlPrefix("precise"), "chromium", {
7453
+ const page = await import_coreBundle4.server.openTraceViewerApp(server.urlPrefix("precise") + uiModePath, "chromium", {
6874
7454
  headless: isUnderTest() && process.env.PWTEST_HEADED_FOR_TEST !== "1",
6875
7455
  persistentContextOptions: {
6876
7456
  handleSIGINT: false,
@@ -6896,7 +7476,7 @@ async function installedChromiumChannelForUI(configLocation, configCLIOverrides)
6896
7476
  async function runTestServer(configFile, configCLIOverrides, options) {
6897
7477
  const configLocation = import_common11.configLoader.resolveConfigLocation(configFile);
6898
7478
  return await innerRunTestServer(configLocation, configCLIOverrides, options, async (server) => {
6899
- console.log("Listening on " + server.urlPrefix("precise").replace("http:", "ws:") + "/" + server.wsGuid());
7479
+ console.log("Listening on " + server.urlPrefix("precise").replace("http:", "ws:") + "/ws");
6900
7480
  });
6901
7481
  }
6902
7482
  async function innerRunTestServer(configLocation, configCLIOverrides, options, openUI) {
@@ -6932,10 +7512,10 @@ var watchMode_exports = {};
6932
7512
  __export(watchMode_exports, {
6933
7513
  runWatchModeLoop: () => runWatchModeLoop
6934
7514
  });
6935
- var import_path18 = __toESM(require("path"));
7515
+ var import_path20 = __toESM(require("path"));
6936
7516
  var import_readline = __toESM(require("readline"));
6937
- var import_events3 = require("events");
6938
- var import_coreBundle4 = require("playwright-core/lib/coreBundle");
7517
+ var import_events4 = require("events");
7518
+ var import_coreBundle5 = require("playwright-core/lib/coreBundle");
6939
7519
 
6940
7520
  // packages/playwright/src/isomorphic/testTree.ts
6941
7521
  var statusEx = /* @__PURE__ */ Symbol("statusEx");
@@ -7281,7 +7861,7 @@ var { ManualPromise: ManualPromise8 } = require("playwright-core/lib/coreBundle"
7281
7861
  var { createGuid: createGuid3 } = require("playwright-core/lib/coreBundle").utils;
7282
7862
  var { getPackageManagerExecCommand: getPackageManagerExecCommand3 } = require("playwright-core/lib/coreBundle").utils;
7283
7863
  var { eventsHelper: eventsHelper2 } = require("playwright-core/lib/coreBundle").utils;
7284
- var InMemoryTransport = class extends import_events3.EventEmitter {
7864
+ var InMemoryTransport = class extends import_events4.EventEmitter {
7285
7865
  constructor(send) {
7286
7866
  super();
7287
7867
  this._send = send;
@@ -7324,7 +7904,7 @@ async function runWatchModeLoop(configLocation, initialOptions) {
7324
7904
  };
7325
7905
  const testServerConnection = new TestServerConnection(transport);
7326
7906
  transport.emit("open");
7327
- const teleSuiteUpdater = new TeleSuiteUpdater({ pathSeparator: import_path18.default.sep, onUpdate() {
7907
+ const teleSuiteUpdater = new TeleSuiteUpdater({ pathSeparator: import_path20.default.sep, onUpdate() {
7328
7908
  } });
7329
7909
  const dirtyTestFiles = /* @__PURE__ */ new Set();
7330
7910
  const dirtyTestIds = /* @__PURE__ */ new Set();
@@ -7354,8 +7934,7 @@ async function runWatchModeLoop(configLocation, initialOptions) {
7354
7934
  testServerConnection.onReport((report2) => teleSuiteUpdater.processTestReportEvent(report2));
7355
7935
  await testServerConnection.initialize({
7356
7936
  interceptStdio: false,
7357
- watchTestDirs: true,
7358
- populateDependenciesOnList: true
7937
+ watchTestDirs: true
7359
7938
  });
7360
7939
  await testServerConnection.runGlobalSetup({});
7361
7940
  const { report } = await testServerConnection.listTests({});
@@ -7601,7 +8180,7 @@ function printBufferPrompt(dirtyTestFiles, rootDir) {
7601
8180
 
7602
8181
  `);
7603
8182
  for (const file of dirtyTestFiles)
7604
- process.stdout.write(` \xB7 ${import_path18.default.relative(rootDir, file)}
8183
+ process.stdout.write(` \xB7 ${import_path20.default.relative(rootDir, file)}
7605
8184
  `);
7606
8185
  process.stdout.write(`
7607
8186
  ${colors6.dim(`Press`)} ${colors6.bold("enter")} ${colors6.dim("to run")}, ${colors6.bold("q")} ${colors6.dim("to quit or")} ${colors6.bold("h")} ${colors6.dim("for more options.")}
@@ -7617,7 +8196,7 @@ ${colors6.dim("Waiting for file changes. Press")} ${colors6.bold("enter")} ${col
7617
8196
  }
7618
8197
  async function toggleShowBrowser() {
7619
8198
  if (!showBrowserServer) {
7620
- showBrowserServer = new import_coreBundle4.remote.PlaywrightServer({ mode: "extension", path: "/" + createGuid3(), maxConnections: 1 });
8199
+ showBrowserServer = new import_coreBundle5.remote.PlaywrightServer({ mode: "extension", path: "/" + createGuid3(), maxConnections: 1 });
7621
8200
  connectWsEndpoint = await showBrowserServer.listen();
7622
8201
  process.stdout.write(`${colors6.dim("Show & reuse browser:")} ${colors6.bold("on")}
7623
8202
  `);
@@ -7635,8 +8214,8 @@ var merge_exports = {};
7635
8214
  __export(merge_exports, {
7636
8215
  createMergedReport: () => createMergedReport
7637
8216
  });
7638
- var import_fs14 = __toESM(require("fs"));
7639
- var import_path19 = __toESM(require("path"));
8217
+ var import_fs16 = __toESM(require("fs"));
8218
+ var import_path21 = __toESM(require("path"));
7640
8219
 
7641
8220
  // packages/playwright/src/isomorphic/stringInternPool.ts
7642
8221
  var StringInternPool = class {
@@ -7681,9 +8260,9 @@ var JsonStringInternalizer = class {
7681
8260
  };
7682
8261
 
7683
8262
  // packages/playwright/src/reporters/merge.ts
7684
- var import_util17 = require("../util");
8263
+ var import_util19 = require("../util");
7685
8264
  var { isPathInside } = require("playwright-core/lib/coreBundle").utils;
7686
- var { ZipFile } = require("playwright-core/lib/coreBundle").utils;
8265
+ var { ZipFile: ZipFile2 } = require("playwright-core/lib/coreBundle").utils;
7687
8266
  async function createMergedReport(config2, dir, reporterDescriptions, rootDirOverride) {
7688
8267
  const reporters = await createReporters(config2, "merge", reporterDescriptions);
7689
8268
  const multiplexer = new Multiplexer(reporters);
@@ -7698,8 +8277,8 @@ async function createMergedReport(config2, dir, reporterDescriptions, rootDirOve
7698
8277
  if (shardFiles.length === 0)
7699
8278
  throw new Error(`No report files found in ${dir}`);
7700
8279
  const eventData = await mergeEvents(dir, shardFiles, stringPool, printStatus, rootDirOverride);
7701
- const pathSeparator = rootDirOverride ? import_path19.default.sep : eventData.pathSeparatorFromMetadata ?? import_path19.default.sep;
7702
- const pathPackage = pathSeparator === "/" ? import_path19.default.posix : import_path19.default.win32;
8280
+ const pathSeparator = rootDirOverride ? import_path21.default.sep : eventData.pathSeparatorFromMetadata ?? import_path21.default.sep;
8281
+ const pathPackage = pathSeparator === "/" ? import_path21.default.posix : import_path21.default.win32;
7703
8282
  const receiver = new TeleReporterReceiver(multiplexer, {
7704
8283
  mergeProjects: false,
7705
8284
  mergeTestCases: false,
@@ -7727,7 +8306,7 @@ async function createMergedReport(config2, dir, reporterDescriptions, rootDirOve
7727
8306
  reportPath: zipFile,
7728
8307
  config: asFullConfig(config3)
7729
8308
  });
7730
- const reportJsonl = await import_fs14.default.promises.readFile(reportFile);
8309
+ const reportJsonl = await import_fs16.default.promises.readFile(reportFile);
7731
8310
  const events = parseTestEvents(reportJsonl);
7732
8311
  new JsonStringInternalizer(stringPool).traverse(events);
7733
8312
  eventPatchers.patchers.push(new AttachmentPathPatcher(dir));
@@ -7773,15 +8352,15 @@ function splitBufferLines(buffer) {
7773
8352
  }
7774
8353
  async function extractAndParseReports(dir, shardFiles, internalizer, printStatus) {
7775
8354
  const shardEvents = [];
7776
- await import_fs14.default.promises.mkdir(import_path19.default.join(dir, "resources"), { recursive: true });
8355
+ await import_fs16.default.promises.mkdir(import_path21.default.join(dir, "resources"), { recursive: true });
7777
8356
  const reportNames = new UniqueFileNameGenerator();
7778
8357
  for (const file of shardFiles) {
7779
- const absolutePath = import_path19.default.join(dir, file);
7780
- printStatus(`extracting: ${(0, import_util17.relativeFilePath)(absolutePath)}`);
7781
- const zipFile = new ZipFile(absolutePath);
8358
+ const absolutePath = import_path21.default.join(dir, file);
8359
+ printStatus(`extracting: ${(0, import_util19.relativeFilePath)(absolutePath)}`);
8360
+ const zipFile = new ZipFile2(absolutePath);
7782
8361
  const entryNames = await zipFile.entries();
7783
8362
  for (const entryName of entryNames.sort()) {
7784
- let reportFile = import_path19.default.join(dir, entryName);
8363
+ let reportFile = import_path21.default.join(dir, entryName);
7785
8364
  const content = await zipFile.read(entryName);
7786
8365
  if (entryName.endsWith(".jsonl")) {
7787
8366
  reportFile = reportNames.makeUnique(reportFile);
@@ -7796,7 +8375,7 @@ async function extractAndParseReports(dir, shardFiles, internalizer, printStatus
7796
8375
  parsedEvents
7797
8376
  });
7798
8377
  }
7799
- await import_fs14.default.promises.writeFile(reportFile, content);
8378
+ await import_fs16.default.promises.writeFile(reportFile, content);
7800
8379
  }
7801
8380
  zipFile.close();
7802
8381
  }
@@ -7963,7 +8542,7 @@ function mergeEndEvents(endEvents) {
7963
8542
  };
7964
8543
  }
7965
8544
  async function sortedShardFiles(dir) {
7966
- const files = await import_fs14.default.promises.readdir(dir);
8545
+ const files = await import_fs16.default.promises.readdir(dir);
7967
8546
  return files.filter((file) => file.endsWith(".zip")).sort();
7968
8547
  }
7969
8548
  function printStatusToStdout(message) {
@@ -7979,7 +8558,7 @@ var UniqueFileNameGenerator = class {
7979
8558
  this._usedNames.add(name);
7980
8559
  return name;
7981
8560
  }
7982
- const extension = import_path19.default.extname(name);
8561
+ const extension = import_path21.default.extname(name);
7983
8562
  name = name.substring(0, name.length - extension.length);
7984
8563
  let index = 0;
7985
8564
  while (true) {
@@ -8062,11 +8641,11 @@ var AttachmentPathPatcher = class {
8062
8641
  this._patchAttachments(event.params.result.attachments ?? []);
8063
8642
  }
8064
8643
  _patchAttachments(attachments) {
8065
- const resourceRoot = import_path19.default.resolve(this._resourceDir);
8644
+ const resourceRoot = import_path21.default.resolve(this._resourceDir);
8066
8645
  for (const attachment of attachments) {
8067
8646
  if (!attachment.path)
8068
8647
  continue;
8069
- const joined = import_path19.default.resolve(resourceRoot, attachment.path);
8648
+ const joined = import_path21.default.resolve(resourceRoot, attachment.path);
8070
8649
  if (!isPathInside(resourceRoot, joined)) {
8071
8650
  attachment.path = void 0;
8072
8651
  continue;
@@ -8077,8 +8656,8 @@ var AttachmentPathPatcher = class {
8077
8656
  };
8078
8657
  var PathSeparatorPatcher = class {
8079
8658
  constructor(from) {
8080
- this._from = from ?? (import_path19.default.sep === "/" ? "\\" : "/");
8081
- this._to = import_path19.default.sep;
8659
+ this._from = from ?? (import_path21.default.sep === "/" ? "\\" : "/");
8660
+ this._to = import_path21.default.sep;
8082
8661
  }
8083
8662
  patchEvent(jsonEvent) {
8084
8663
  if (this._from === this._to)