@piwitests/reporter 0.65.0 → 0.67.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.
package/dist/cli/index.js CHANGED
@@ -602,8 +602,14 @@ function hasBlockingFindings(findings) {
602
602
  var import_node_child_process = require("child_process");
603
603
  var fs3 = __toESM(require("fs"));
604
604
  var import_node_module = require("module");
605
+ var os = __toESM(require("os"));
605
606
  var path5 = __toESM(require("path"));
606
607
  var COULD_NOT_START = 2;
608
+ function childExitCode(code, signal) {
609
+ if (code !== null) return code;
610
+ const number = signal ? os.constants.signals[signal] : void 0;
611
+ return number === void 0 ? COULD_NOT_START : 128 + number;
612
+ }
607
613
  function resolvePlaywrightCli(cwd = process.cwd()) {
608
614
  const require2 = (0, import_node_module.createRequire)(path5.join(cwd, "noop.js"));
609
615
  for (const id of ["playwright/cli", "@playwright/test/cli", "playwright/lib/cli/cli"]) {
@@ -658,7 +664,10 @@ function spawnPlaywright(playwrightArgs2, env, options = {}) {
658
664
  console.error(`${label}: could not start Playwright \u2014 ${err.message}`);
659
665
  done(COULD_NOT_START);
660
666
  });
661
- child.on("exit", (code) => done(code ?? COULD_NOT_START));
667
+ child.on("exit", (code, signal) => {
668
+ if (signal) console.error(`${label}: Playwright was stopped by ${signal}`);
669
+ done(childExitCode(code, signal));
670
+ });
662
671
  });
663
672
  }
664
673
  function runPackageManager(command, args, cwd) {
@@ -797,10 +806,10 @@ var path8 = __toESM(require("path"));
797
806
 
798
807
  // src/internal/config/desktop.ts
799
808
  var fs4 = __toESM(require("fs"));
800
- var os = __toESM(require("os"));
809
+ var os2 = __toESM(require("os"));
801
810
  var path7 = __toESM(require("path"));
802
811
  function defaultDesktopConfigPath() {
803
- return path7.join(os.homedir(), ".piwi", "desktop.json");
812
+ return path7.join(os2.homedir(), ".piwi", "desktop.json");
804
813
  }
805
814
  function processAlive(pid) {
806
815
  try {
@@ -877,6 +886,35 @@ function detectCi(env) {
877
886
  );
878
887
  }
879
888
 
889
+ // ../core/src/rerun-args.ts
890
+ var RERUN_ARGS_ENV = "PIWI_RERUN_ARGS";
891
+ var WHITESPACE = /[ \t\r\n]/;
892
+ function splitRerunArgs(text) {
893
+ const words = [];
894
+ let word = "";
895
+ let inWord = false;
896
+ let quoted2 = false;
897
+ for (const ch of text) {
898
+ if (quoted2) {
899
+ if (ch === '"') quoted2 = false;
900
+ else word += ch;
901
+ } else if (ch === '"') {
902
+ quoted2 = true;
903
+ inWord = true;
904
+ } else if (WHITESPACE.test(ch)) {
905
+ if (inWord) words.push(word);
906
+ word = "";
907
+ inWord = false;
908
+ } else {
909
+ word += ch;
910
+ inWord = true;
911
+ }
912
+ }
913
+ if (quoted2) throw new Error("a double quote is not closed");
914
+ if (inWord) words.push(word);
915
+ return words;
916
+ }
917
+
880
918
  // src/internal/config/env.ts
881
919
  var DEFAULTS = {
882
920
  projectName: "default-project",
@@ -1115,6 +1153,7 @@ function resolveCliConnection(flags, env, dirs, command = "piwi") {
1115
1153
  var EXIT_OK2 = 0;
1116
1154
  var EXIT_RUN_FAILED = 1;
1117
1155
  var EXIT_ERROR2 = 2;
1156
+ var STOPPED_BY_SIGNAL = 128;
1118
1157
  var REQUEST_TIMEOUT_MS = 3e4;
1119
1158
  var USAGE2 = `
1120
1159
  piwi bug \u2014 a bug report's failing test, from the dashboard
@@ -1137,8 +1176,9 @@ Options:
1137
1176
 
1138
1177
  Exit codes: 0 printed or written (and, when run, the test behaved as its
1139
1178
  test.fail() expects: the bug reproduces), 1 the run did not (the bug may be
1140
- fixed, or a step no longer matches the page), 2 the report could not be read
1141
- or the file could not be written.
1179
+ fixed, or a step no longer matches the page), 2 the report could not be read,
1180
+ the file could not be written, or Playwright could not start or was stopped
1181
+ by a signal.
1142
1182
  `.trim();
1143
1183
  var VALUE_FLAGS = /* @__PURE__ */ new Set(["--out", "--server-url", "--api-key"]);
1144
1184
  function readOption2(argv, name) {
@@ -1275,6 +1315,7 @@ ${USAGE2}`);
1275
1315
  if (!args.run) return EXIT_OK2;
1276
1316
  const code = await runPlaywright(file, cwd, args.id, env);
1277
1317
  if (code === EXIT_ERROR2 && !resolvePlaywrightCli(cwd)) return EXIT_ERROR2;
1318
+ if (code >= STOPPED_BY_SIGNAL) return EXIT_ERROR2;
1278
1319
  if (code === 0) {
1279
1320
  console.error(
1280
1321
  args.mode === "commit" ? `piwi bug: the bug reproduces \u2014 the spec fails on it, as test.fail() expects. Commit ${shown}; remove test.fail() with the fix.` : "piwi bug: the spec passed \u2014 the bug does not show here."
@@ -3343,6 +3384,31 @@ function errorMessage(error) {
3343
3384
  return String(error);
3344
3385
  }
3345
3386
 
3387
+ // ../core/src/run-view.ts
3388
+ var MAX_VIEW_FRAME = 384 * 1024;
3389
+ var MAX_VIEW_FRAME_BASE64 = 4 * Math.ceil(MAX_VIEW_FRAME / 3);
3390
+
3391
+ // ../core/src/run-channel.ts
3392
+ var RUN_INTENTS = ["pick", "record", "assert", "assert-region"];
3393
+ var RUN_TAKES = [
3394
+ ...RUN_INTENTS,
3395
+ "requests",
3396
+ "mock",
3397
+ "locator",
3398
+ "view",
3399
+ "input",
3400
+ "input-clicks",
3401
+ "pick-at",
3402
+ "agent",
3403
+ "events",
3404
+ "bind",
3405
+ "end",
3406
+ "share"
3407
+ ];
3408
+ var MAX_KEPT_BODY = 256 * 1024;
3409
+ var MAX_REGION_SNAPSHOT = 1024 * 1024;
3410
+ var MAX_AGENT_SNAPSHOT = 1024 * 1024;
3411
+
3346
3412
  // src/internal/support/test-paths.ts
3347
3413
  var path12 = __toESM(require("path"));
3348
3414
 
@@ -4363,7 +4429,7 @@ ${USAGE4}`);
4363
4429
  // src/cli/flake.ts
4364
4430
  var import_node_child_process6 = require("child_process");
4365
4431
  var fs12 = __toESM(require("fs"));
4366
- var os2 = __toESM(require("os"));
4432
+ var os3 = __toESM(require("os"));
4367
4433
  var path17 = __toESM(require("path"));
4368
4434
 
4369
4435
  // ../core/src/error-parse.ts
@@ -4943,7 +5009,7 @@ function printHeader(plan, commit, estimate, budgetMs) {
4943
5009
  out.push("");
4944
5010
  const estimateText = estimate != null ? `up to ${formatDuration(estimate)}` : "unknown (no passing run on record)";
4945
5011
  out.push(`Estimate: ${estimateText} \xB7 budget ${formatDuration(budgetMs)}`);
4946
- out.push(`Lab \xB7 ${os2.hostname()} \xB7 HEAD ${short(commit)} \xB7 ${plan.test.project ?? "default project"} \xB7 retries off`);
5012
+ out.push(`Lab \xB7 ${os3.hostname()} \xB7 HEAD ${short(commit)} \xB7 ${plan.test.project ?? "default project"} \xB7 retries off`);
4947
5013
  if (commitsDiffer(commit, plan.failureCommit)) {
4948
5014
  out.push(`warning: this checkout is ${short(commit)}; the latest failure ran on ${short(plan.failureCommit)}.`);
4949
5015
  }
@@ -4984,7 +5050,7 @@ async function loadPlan(args, commit) {
4984
5050
  const params = new URLSearchParams({
4985
5051
  kind: args.verify ? "verify" : "reproduce",
4986
5052
  source: args.source ?? (process.env.CI ? "ci" : "cli"),
4987
- machine: os2.hostname(),
5053
+ machine: os3.hostname(),
4988
5054
  record: String(args.upload)
4989
5055
  });
4990
5056
  if (commit) params.set("commit", commit);
@@ -5047,7 +5113,7 @@ async function runFlake(argv, runner) {
5047
5113
  if (!args.json) {
5048
5114
  printHeader(plan, commit, estimate, args.budgetMs);
5049
5115
  }
5050
- const dir = fs12.mkdtempSync(path17.join(os2.tmpdir(), "piwi-flake-"));
5116
+ const dir = fs12.mkdtempSync(path17.join(os3.tmpdir(), "piwi-flake-"));
5051
5117
  const log = path17.join(dir, "playwright.log");
5052
5118
  let session;
5053
5119
  try {
@@ -5681,11 +5747,8 @@ function ensureGitignoreEntry(existing, entry = ".env") {
5681
5747
  var fs15 = __toESM(require("fs"));
5682
5748
  var path19 = __toESM(require("path"));
5683
5749
 
5684
- // ../core/src/skill-stamp.ts
5685
- var SKILL_VERSION_KEY = "piwi-version";
5686
- var SKILL_HASH_KEY = "piwi-hash";
5687
- var FRONT_MATTER = /^---\r?\n([\s\S]*?)\r?\n---/;
5688
- function fnv32(input, seed) {
5750
+ // ../core/src/hash.ts
5751
+ function fnv1a32(input, seed = 2166136261) {
5689
5752
  let h = seed >>> 0;
5690
5753
  for (let i = 0; i < input.length; i++) {
5691
5754
  h ^= input.charCodeAt(i);
@@ -5693,8 +5756,13 @@ function fnv32(input, seed) {
5693
5756
  }
5694
5757
  return (h >>> 0).toString(16).padStart(8, "0");
5695
5758
  }
5759
+
5760
+ // ../core/src/skill-stamp.ts
5761
+ var SKILL_VERSION_KEY = "piwi-version";
5762
+ var SKILL_HASH_KEY = "piwi-hash";
5763
+ var FRONT_MATTER = /^---\r?\n([\s\S]*?)\r?\n---/;
5696
5764
  function hash16(input) {
5697
- return fnv32(input, 2166136261) + fnv32(input, 16777619);
5765
+ return fnv1a32(input) + fnv1a32(input, 16777619);
5698
5766
  }
5699
5767
  function withoutHashLine(markdown) {
5700
5768
  return markdown.replace(new RegExp(`^${SKILL_HASH_KEY}:.*\\r?\\n`, "m"), "");
@@ -7322,7 +7390,9 @@ Behavior:
7322
7390
  --json Print the full resolution as JSON (select only)
7323
7391
  -h, --help Show this help
7324
7392
 
7325
- Exit codes: 0 ok, 1 the test run failed (run only), 2 could not resolve.
7393
+ Exit codes: 0 ok, 1 the test run failed (run only), 128 plus the signal's
7394
+ number when the runner stops Playwright (run only; 143 for SIGTERM),
7395
+ 2 could not resolve or Playwright could not start.
7326
7396
  `.trim();
7327
7397
  var IMPACT_KEY = "impact";
7328
7398
  var NOTHING_TO_RUN_ARGS = ["--pass-with-no-tests", "--grep-invert", "."];
@@ -8169,7 +8239,7 @@ async function runPreflight(argv, env = process.env, cwd = process.cwd()) {
8169
8239
 
8170
8240
  // src/cli/probe.ts
8171
8241
  var fs20 = __toESM(require("fs"));
8172
- var os3 = __toESM(require("os"));
8242
+ var os4 = __toESM(require("os"));
8173
8243
  var path24 = __toESM(require("path"));
8174
8244
  var EXIT_OK8 = 0;
8175
8245
  var EXIT_ERROR9 = 2;
@@ -8251,7 +8321,7 @@ async function runProbe(argv) {
8251
8321
  return EXIT_OK8;
8252
8322
  }
8253
8323
  console.error(`piwi probe: ${plan.items.length} pair(s) to probe (budget ${plan.budget}).`);
8254
- const dir = fs20.mkdtempSync(path24.join(os3.tmpdir(), "piwi-probe-"));
8324
+ const dir = fs20.mkdtempSync(path24.join(os4.tmpdir(), "piwi-probe-"));
8255
8325
  const planFile = path24.join(dir, "plan.json");
8256
8326
  const resultsFile = path24.join(dir, "results.jsonl");
8257
8327
  const runOutputFile = path24.join(dir, "run.json");
@@ -8451,8 +8521,51 @@ async function runQualityReport(argv) {
8451
8521
  }
8452
8522
  }
8453
8523
 
8454
- // src/cli/index.ts
8524
+ // src/cli/rerun.ts
8525
+ var EXIT_ERROR11 = 2;
8455
8526
  var USAGE13 = `
8527
+ piwi rerun \u2014 run the tests a CI re-run from the dashboard asked for
8528
+
8529
+ Usage:
8530
+ npx @piwitests/reporter rerun [--] [playwright args]
8531
+
8532
+ Runs playwright test with the arguments of ${RERUN_ARGS_ENV}, split as the
8533
+ dashboard quoted them and never read by a shell, followed by the arguments
8534
+ given here (after an optional --). Declare ${RERUN_ARGS_ENV} in the CI job: set and empty, the whole
8535
+ suite runs; unset, the command fails rather than run it.
8536
+
8537
+ Options:
8538
+ -h, --help Show this help (as the first argument only)
8539
+
8540
+ Exit codes: Playwright's own, 128 plus the signal's number when the runner
8541
+ stops Playwright (143 for SIGTERM), or 2 when ${RERUN_ARGS_ENV} is unset or
8542
+ cannot be read, or Playwright cannot start.
8543
+ `.trim();
8544
+ async function runRerun(argv, env = process.env) {
8545
+ if (argv[0] === "-h" || argv[0] === "--help") {
8546
+ console.log(USAGE13);
8547
+ return 0;
8548
+ }
8549
+ const text = env[RERUN_ARGS_ENV];
8550
+ if (text === void 0) {
8551
+ console.error(
8552
+ `piwi rerun: ${RERUN_ARGS_ENV} is not set. Declare it in the job (a pipeline variable or build parameter) so the dashboard's arguments reach it.`
8553
+ );
8554
+ return EXIT_ERROR11;
8555
+ }
8556
+ let words;
8557
+ try {
8558
+ words = splitRerunArgs(text);
8559
+ } catch (e) {
8560
+ console.error(`piwi rerun: ${RERUN_ARGS_ENV} cannot be read: ${e.message}.`);
8561
+ return EXIT_ERROR11;
8562
+ }
8563
+ const extra = argv[0] === "--" ? argv.slice(1) : argv;
8564
+ return spawnPlaywright([...words, ...extra], env, { command: "piwi rerun" });
8565
+ }
8566
+
8567
+ // src/cli/index.ts
8568
+ var USAGE14 = `
8456
8569
  piwi \u2014 companion commands for the Piwi Dashboard reporter
8457
8570
 
8458
8571
  Usage:
@@ -8466,6 +8579,7 @@ Commands:
8466
8579
  coverage Upload a unit-test (or other) coverage report of a commit (coverage upload)
8467
8580
  select Print the Playwright args for a saved test selection
8468
8581
  run Run a saved test selection with playwright test
8582
+ rerun Run the tests a CI re-run from the dashboard asked for (PIWI_RERUN_ARGS)
8469
8583
  probe Run the dashboard's probe plan and record what the suite noticed
8470
8584
  flake Make a flaky test fail on demand under its suspects' conditions, then verify the fix
8471
8585
  ai Manage committed natural-language AI-step artifacts
@@ -8494,6 +8608,8 @@ async function main() {
8494
8608
  return runSelect(rest);
8495
8609
  case "run":
8496
8610
  return runRun(rest);
8611
+ case "rerun":
8612
+ return runRerun(rest);
8497
8613
  case "probe":
8498
8614
  return runProbe(rest);
8499
8615
  case "flake":
@@ -8509,12 +8625,12 @@ async function main() {
8509
8625
  case void 0:
8510
8626
  case "-h":
8511
8627
  case "--help":
8512
- console.log(USAGE13);
8628
+ console.log(USAGE14);
8513
8629
  return 0;
8514
8630
  default:
8515
8631
  console.error(`piwi: unknown command "${command}"
8516
8632
  `);
8517
- console.error(USAGE13);
8633
+ console.error(USAGE14);
8518
8634
  return 2;
8519
8635
  }
8520
8636
  }
@@ -220,6 +220,7 @@ var PIWI_ENV_KEYS = {
220
220
  };
221
221
  var PIWI_DESKTOP_CONFIG_ENV = "PIWI_DESKTOP_CONFIG";
222
222
  var PIWI_SHARD_ENV = "PIWI_SHARD";
223
+ var PIWI_RUN_LOG_ENV = "PIWI_RUN_LOG";
223
224
  function readBool(val) {
224
225
  if (val === void 0) return void 0;
225
226
  return ["true", "1", "yes", "on"].includes(val.trim().toLowerCase());
@@ -446,6 +447,7 @@ var HttpClient = class {
446
447
  this.inFlight = /* @__PURE__ */ new Set();
447
448
  /** Set by `close`: every later request fails with this reason. */
448
449
  this.closedReason = null;
450
+ this.loginAnnounced = false;
449
451
  this.warnIfInsecureTransport();
450
452
  }
451
453
  /**
@@ -494,7 +496,9 @@ var HttpClient = class {
494
496
  async resolveAuth(options) {
495
497
  if (options.apiKey) return options.apiKey;
496
498
  if (options.username && options.password) {
497
- this.logger.info(`Authenticating as ${options.username}...`);
499
+ if (this.loginAnnounced) this.logger.debug(`Authenticating as ${options.username} again...`);
500
+ else this.logger.info(`Authenticating as ${options.username}...`);
501
+ this.loginAnnounced = true;
498
502
  return this.login(options.username, options.password);
499
503
  }
500
504
  return null;
@@ -713,6 +717,31 @@ function resolveShardInfo(config, env = process.env) {
713
717
  var import_node_child_process = require("child_process");
714
718
  var import_node_util = require("util");
715
719
 
720
+ // ../core/src/run-view.ts
721
+ var MAX_VIEW_FRAME = 384 * 1024;
722
+ var MAX_VIEW_FRAME_BASE64 = 4 * Math.ceil(MAX_VIEW_FRAME / 3);
723
+
724
+ // ../core/src/run-channel.ts
725
+ var RUN_INTENTS = ["pick", "record", "assert", "assert-region"];
726
+ var RUN_TAKES = [
727
+ ...RUN_INTENTS,
728
+ "requests",
729
+ "mock",
730
+ "locator",
731
+ "view",
732
+ "input",
733
+ "input-clicks",
734
+ "pick-at",
735
+ "agent",
736
+ "events",
737
+ "bind",
738
+ "end",
739
+ "share"
740
+ ];
741
+ var MAX_KEPT_BODY = 256 * 1024;
742
+ var MAX_REGION_SNAPSHOT = 1024 * 1024;
743
+ var MAX_AGENT_SNAPSHOT = 1024 * 1024;
744
+
716
745
  // src/internal/support/test-paths.ts
717
746
  var path3 = __toESM(require("path"));
718
747
  function configDirFromConfig(config) {
@@ -856,6 +885,16 @@ function privateTempDir() {
856
885
  }
857
886
  var NO_FOLLOW = fs3.constants.O_NOFOLLOW ?? 0;
858
887
  var NO_WAIT = fs3.constants.O_NONBLOCK ?? 0;
888
+ function untrustedReason(stat) {
889
+ if (stat.isSymbolicLink()) return "it is a symbolic link";
890
+ if (!stat.isFile()) return "it is not a regular file";
891
+ if (typeof process.getuid === "function") {
892
+ if (stat.uid !== process.getuid()) return "another user owns it";
893
+ if (stat.mode & 18) return "other users may write to it";
894
+ if (stat.nlink > 1) return "it has another name";
895
+ }
896
+ return null;
897
+ }
859
898
  function writePrivateFile(file, text) {
860
899
  const temp = `${file}.${process.pid}.${crypto2.randomBytes(6).toString("hex")}.tmp`;
861
900
  try {
@@ -866,6 +905,20 @@ function writePrivateFile(file, text) {
866
905
  throw error;
867
906
  }
868
907
  }
908
+ function readPrivateFile(file) {
909
+ const found = fs3.lstatSync(file, { throwIfNoEntry: false });
910
+ if (!found) return null;
911
+ const reason = untrustedReason(found);
912
+ if (reason) return { untrusted: reason };
913
+ const fd = fs3.openSync(file, fs3.constants.O_RDONLY | NO_FOLLOW | NO_WAIT);
914
+ try {
915
+ const opened = untrustedReason(fs3.fstatSync(fd));
916
+ if (opened) return { untrusted: opened };
917
+ return { text: fs3.readFileSync(fd, "utf8") };
918
+ } finally {
919
+ fs3.closeSync(fd);
920
+ }
921
+ }
869
922
 
870
923
  // src/internal/support/setup-file.ts
871
924
  var logger = new Logger();
@@ -875,6 +928,13 @@ function getSetupFilePath(projectName, pid = process.pid) {
875
928
  function writeSetupInfo(info) {
876
929
  writePrivateFile(getSetupFilePath(info.projectName), JSON.stringify(info));
877
930
  }
931
+ function writeSetupFailure(projectName, failed) {
932
+ const failure = { projectName, failed };
933
+ try {
934
+ writePrivateFile(getSetupFilePath(projectName), JSON.stringify(failure));
935
+ } catch {
936
+ }
937
+ }
878
938
 
879
939
  // src/internal/support/aria-sampling.ts
880
940
  var path6 = __toESM(require("path"));
@@ -1138,8 +1198,8 @@ var MAX_MANIFEST_BYTES = 4 * 1024 * 1024;
1138
1198
  function instrumentationManifestUrls(baseUrl) {
1139
1199
  const base = new URL(baseUrl);
1140
1200
  const root = new URL(INSTRUMENTATION_MANIFEST_PATH, base).toString();
1141
- const path11 = base.pathname.replace(/\/+$/, "");
1142
- return path11 ? [new URL(`${path11}${INSTRUMENTATION_MANIFEST_PATH}`, base).toString(), root] : [root];
1201
+ const path12 = base.pathname.replace(/\/+$/, "");
1202
+ return path12 ? [new URL(`${path12}${INSTRUMENTATION_MANIFEST_PATH}`, base).toString(), root] : [root];
1143
1203
  }
1144
1204
  async function fetchInstrumentationManifest(baseUrl, fetchImpl = fetch) {
1145
1205
  try {
@@ -1235,7 +1295,42 @@ function getReporterVersion() {
1235
1295
  return cachedVersion;
1236
1296
  }
1237
1297
 
1298
+ // src/internal/support/run-log.ts
1299
+ var import_node_crypto = require("crypto");
1300
+ var fs9 = __toESM(require("fs"));
1301
+ var path11 = __toESM(require("path"));
1302
+ var READ_MS = 1e3;
1303
+ function relayRunLog(print, env = process.env) {
1304
+ const file = path11.join(privateTempDir(), `piwi-run-log-${(0, import_node_crypto.randomBytes)(12).toString("hex")}.txt`);
1305
+ writePrivateFile(file, "");
1306
+ env[PIWI_RUN_LOG_ENV] = file;
1307
+ let printed = 0;
1308
+ const flush = () => {
1309
+ let text;
1310
+ try {
1311
+ const found = readPrivateFile(file);
1312
+ if (!found || !("text" in found)) return;
1313
+ text = found.text;
1314
+ } catch {
1315
+ return;
1316
+ }
1317
+ const end = text.lastIndexOf("\n") + 1;
1318
+ if (end <= printed) return;
1319
+ const lines = text.slice(printed, end).split("\n");
1320
+ printed = end;
1321
+ for (const line of lines) if (line) print(line);
1322
+ };
1323
+ const timer = setInterval(flush, READ_MS);
1324
+ timer.unref();
1325
+ return () => {
1326
+ clearInterval(timer);
1327
+ flush();
1328
+ fs9.rmSync(file, { force: true });
1329
+ };
1330
+ }
1331
+
1238
1332
  // src/public/global-setup.ts
1333
+ var relaying = false;
1239
1334
  function createGlobalSetup(options, userSetup) {
1240
1335
  return async function globalSetupFn(config) {
1241
1336
  const configDir = configDirFromConfig(config);
@@ -1280,9 +1375,14 @@ function createGlobalSetup(options, userSetup) {
1280
1375
  return;
1281
1376
  }
1282
1377
  const httpClient = new HttpClient(opts.serverUrl, logger2);
1378
+ const registers = opts.streaming !== false;
1379
+ let registered = false;
1283
1380
  try {
1284
1381
  const auth = await httpClient.resolveAuth(opts);
1285
- if (opts.streaming !== false) await registerRun(httpClient, auth, opts, config, logger2);
1382
+ if (registers) {
1383
+ await registerRun(httpClient, auth, opts, config, logger2);
1384
+ registered = true;
1385
+ }
1286
1386
  if (opts.projectName) clearAriaSampleFile(opts.projectName);
1287
1387
  const wantsAria = opts.sampleAriaOnPass !== false && !!opts.projectName;
1288
1388
  const committedManifest = opts.uploadManifest !== false ? readCommittedManifest(configDirFromConfig(config)) : null;
@@ -1321,6 +1421,7 @@ function createGlobalSetup(options, userSetup) {
1321
1421
  }
1322
1422
  } catch (error) {
1323
1423
  logger2.warn(`Could not register global setup: ${errorMessage(error)}`);
1424
+ if (registers && !registered && opts.projectName) writeSetupFailure(opts.projectName, errorMessage(error));
1324
1425
  }
1325
1426
  if (userSetup) return userSetup(config);
1326
1427
  };
@@ -1348,16 +1449,26 @@ async function registerRun(httpClient, auth, opts, config, logger2) {
1348
1449
  },
1349
1450
  auth
1350
1451
  );
1351
- if (response?.runId && response?.setupToken) {
1352
- const liveViewKey = response.liveView?.key;
1353
- writeSetupInfo({
1354
- runId: response.runId,
1355
- setupToken: response.setupToken,
1356
- projectName: opts.projectName,
1357
- ...isLiveViewKey(liveViewKey) ? { liveViewKey } : {},
1358
- ...response.liveView?.refused === "local" ? { liveViewLocal: true } : {}
1359
- });
1360
- logger2.debug(`Global setup: initializing run #${response.runId}`);
1452
+ if (!response?.runId || !response?.setupToken) {
1453
+ throw new Error("the answer to /api/test-runs/setup names no run");
1454
+ }
1455
+ const liveViewKey = response.liveView?.key;
1456
+ writeSetupInfo({
1457
+ runId: response.runId,
1458
+ setupToken: response.setupToken,
1459
+ projectName: opts.projectName,
1460
+ ...isLiveViewKey(liveViewKey) ? { liveViewKey } : {},
1461
+ ...response.liveView?.refused === "local" ? { liveViewLocal: true } : {}
1462
+ });
1463
+ logger2.debug(`Global setup: initializing run #${response.runId}`);
1464
+ if (isLiveViewKey(liveViewKey) && detectCi(process.env) && !relaying) {
1465
+ try {
1466
+ const stopRelay = relayRunLog((line) => logger2.info(line));
1467
+ relaying = true;
1468
+ process.once("exit", stopRelay);
1469
+ } catch (error) {
1470
+ logger2.debug(`Global setup: the live view's lines go to no file (${errorMessage(error)})`);
1471
+ }
1361
1472
  }
1362
1473
  }
1363
1474
 
package/dist/index.d.ts CHANGED
@@ -256,16 +256,20 @@ interface PiwiDashboardOptions {
256
256
  * `trace` options on the top-level `use` block so a failing test keeps a
257
257
  * screenshot (`'only-on-failure'`) and a trace (`'retain-on-failure'`) even
258
258
  * without the capture fixtures — the trace alone unlocks the DOM snapshot,
259
- * full call stack, full network with bodies and the visual diff. On Playwright
260
- * 1.63 or later the trace default also turns on the per-action aria tree
261
- * (`snapshots: { dom: true, aria: true }`), which adds the accessibility tree
262
- * before and after each action at negligible size. The `screen` snapshot kind
263
- * (a PNG per action, the trace's biggest cost) stays opt-in — set it yourself
264
- * with `use: { trace: { mode: 'retain-on-failure', snapshots: { dom: true,
265
- * aria: true, screen: true } } }`. Only fills options the config leaves unset;
266
- * an explicit value (including `'off'`) and per-project `use` blocks are never
267
- * touched. Defaults to `true`. Set to `false` (or `PIWI_DEFAULT_CAPTURE=false`)
268
- * to opt out and let Playwright's own defaults stand.
259
+ * full call stack, full network with bodies and the visual diff. The trace
260
+ * records DOM snapshots, not ARIA snapshots. To record those too (Playwright
261
+ * 1.63+), for the in-execution page diff and the accessibility tree at the
262
+ * failing action, set the trace yourself: `use: { trace: { mode: 'retain-on-failure',
263
+ * snapshots: { dom: true, aria: true } } }`. They cost run time on every
264
+ * attempt, passing ones included: Playwright waits for up to three ARIA
265
+ * snapshots per input action, each hundreds of milliseconds on a large page
266
+ * (ten clicks on a 1,000-row table took 8,967 ms with them against 1,021 ms
267
+ * without, on Playwright 1.64.1 and Chromium). Add `screen: true` for a PNG
268
+ * per action, the trace's biggest storage cost. Only fills options the config
269
+ * leaves unset; an explicit value (including `'off'`) and per-project `use`
270
+ * blocks are never touched. Defaults to `true`. Set to `false` (or
271
+ * `PIWI_DEFAULT_CAPTURE=false`) to opt out and let Playwright's own defaults
272
+ * stand.
269
273
  */
270
274
  defaultCapture?: boolean;
271
275
  /**
@@ -488,8 +492,8 @@ declare function createGlobalSetup(options?: PiwiDashboardOptions, userSetup?: (
488
492
  *
489
493
  * The top-level `use` block's `screenshot` and `trace` are defaulted to
490
494
  * `'only-on-failure'` / `'retain-on-failure'` when unset so failure evidence is
491
- * captured without the fixtures; on Playwright 1.63 or later `trace` also turns
492
- * on the per-action aria tree (`snapshots: { dom: true, aria: true }`). An
495
+ * captured without the fixtures; the trace records DOM snapshots, not ARIA
496
+ * snapshots (set `trace` yourself to record them, see `defaultCapture`). An
493
497
  * explicit value (including `'off'`) is kept. Opt out with `defaultCapture:
494
498
  * false` (or `PIWI_DEFAULT_CAPTURE=false`).
495
499
  *
@@ -529,8 +533,13 @@ declare class PiwiDashboardReporter {
529
533
  private plannedTests;
530
534
  /** Ids of tests that actually reported via `onTestEnd`, to find the ones that never ran. */
531
535
  private reportedTestIds;
532
- /** The spec files said to have run without the capture fixtures in a run that can stop (`noteUncaptured`). */
536
+ /**
537
+ * The spec files said to have run without the capture fixtures in a run that can stop, or whose workers stream to
538
+ * the instance's live view (`noteUncaptured`).
539
+ */
533
540
  private uncapturedSpecs;
541
+ /** Whether the run is a CI run whose workers stream to the instance's live view, set in `onBegin`. */
542
+ private liveViewOn;
534
543
  /** The live steps begun and not ended, by step, sent again when someone opens the run (`onWatched`). */
535
544
  private openSteps;
536
545
  /**
@@ -559,6 +568,8 @@ declare class PiwiDashboardReporter {
559
568
  * finalizing a run would create an empty phantom run and upload an empty report.
560
569
  */
561
570
  private readonly listMode;
571
+ /** True under `playwright merge-reports`, which replays blob reports: no test runs and nothing of the run is live. */
572
+ private readonly mergingReports;
562
573
  /** True when the server URL and API key came from the desktop app, not from config. */
563
574
  private viaDesktopApp;
564
575
  /** The configured server `desktopApp: 'prefer'` set aside for the desktop app, if any. */
@@ -627,9 +638,12 @@ declare class PiwiDashboardReporter {
627
638
  * environment: the key the instance gave the global setup, for a project that turned its live view on, for this run
628
639
  * alone. A CI run's workers stream with it at once; a run outside CI's hold it until a person shares the run (Share
629
640
  * live), and such a run without a key names why instead, for the surfaces that would share it; a CI run without one
630
- * says why in its log (`ciLiveViewNote`). Read before the stream starts, which takes the setup file.
641
+ * says why in its log (`ciLiveViewNote`). Read before the stream starts, which takes the setup file. A run that
642
+ * merges blob reports starts no worker and is not live: it says nothing of the live view.
631
643
  */
632
644
  private shareLiveView;
645
+ /** Why the run holds no live view key, from what its global setup left (`setup`, its registration, if any). */
646
+ private liveViewMissing;
633
647
  /**
634
648
  * Settle each planned test's external ID before any test runs, name the IDs two tests share, and record them on
635
649
  * the run so the dashboard lists them too.
@@ -655,21 +669,31 @@ declare class PiwiDashboardReporter {
655
669
  /** Step categories streamed live while the run executes. */
656
670
  private static readonly LIVE_STEP_CATEGORIES;
657
671
  /**
658
- * Whether a step streams live: its category is in `LIVE_STEP_CATEGORIES`
659
- * and no ancestor is an `expect` step. The steps inside an assertion are its
660
- * polling — every `expect.poll` attempt and `toPass` retry — not a step a
661
- * human watches; the meaningful readout is the assertion around them.
672
+ * Whether a step streams live: its category is in `LIVE_STEP_CATEGORIES`,
673
+ * no ancestor is an `expect` step, and neither it nor an ancestor is Piwi's
674
+ * own (`isCaptureStep`: its fixtures, its attachments, its page reads). The
675
+ * steps inside an assertion are its polling — every `expect.poll` attempt and
676
+ * `toPass` retry — not a step a human watches; the meaningful readout is the
677
+ * assertion around them.
662
678
  */
663
679
  private static isLiveStep;
680
+ /** Whether a step is Piwi's own, by core's rule for a stored step. */
681
+ private static isOwnStep;
664
682
  /**
665
- * In a run that can stop (breakpoints, or a run channel to an editor or the desktop app), say of the first spec file
666
- * whose test made Playwright calls without the capture fixtures, where the stops happen, that it never stops at a
667
- * breakpoint nor at Pause, which nothing else says; the others are named in one line as the run ends
683
+ * Say of the first spec file whose test made Playwright calls without the capture fixtures what it misses in this
684
+ * run, which nothing else says: in a run that can stop (breakpoints, or a run channel to an editor or the desktop
685
+ * app, where the stops happen), its tests never stop at a breakpoint nor at Pause; in a CI run whose workers stream
686
+ * to the instance's live view, nobody can watch them. The others are named in one line as the run ends
668
687
  * (`noteOtherUncaptured`).
669
688
  */
670
689
  private noteUncaptured;
671
690
  /** The spec files past the first that ran without the capture fixtures, in one line (`noteUncaptured`). */
672
691
  private noteOtherUncaptured;
692
+ /**
693
+ * What a spec file that runs without the capture fixtures misses in this run, said of one file and of several: the
694
+ * live view only for a test with a page (`page`).
695
+ */
696
+ private uncapturedCosts;
673
697
  /** Playwright reporter hook: called when a step (including hook/fixture) begins */
674
698
  onStepBegin(test: TestCase | undefined, _result: TestResult | undefined, step: any): void;
675
699
  /** Playwright reporter hook: called when a step (including hook/fixture) ends */