@plune-ai/playwright 0.2.5 → 0.2.6

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/README.md CHANGED
@@ -34,10 +34,13 @@ That is the whole setup. Options, if you want them:
34
34
  batchSize: 100, // results per request (max 500)
35
35
  fallbackPath: '.plune/pending-results.jsonl',
36
36
  apiUrl: 'https://beta-api.plune.ai', // or PLUNE_API_URL
37
- token: process.env.PLUNE_TOKEN, // or whatever `plune login` saved
38
37
  }]
39
38
  ```
40
39
 
40
+ Keep the token out of this list: it comes from `PLUNE_TOKEN` or what `plune login` saved. Playwright
41
+ writes every reporter's options into its JSON and blob reports, so a token set here travels with any
42
+ report a CI job keeps as an artifact.
43
+
41
44
  ## From CI, without editing the config
42
45
 
43
46
  A committed config cannot know the run key of a job that does not exist yet, so the environment
package/dist/index.cjs CHANGED
@@ -34,16 +34,23 @@ __export(src_exports, {
34
34
  });
35
35
  module.exports = __toCommonJS(src_exports);
36
36
  var import_node_fs = require("fs");
37
+ var import_node_util = require("util");
37
38
 
38
39
  // ../../dist/reporter-core.js
39
40
  var import_crypto = require("crypto");
40
41
  var import_fs = require("fs");
41
42
  var import_os = require("os");
42
43
  var import_path = require("path");
44
+ var import_http = require("http");
45
+ var import_https = require("https");
43
46
  var path = __toESM(require("path"), 1);
44
47
  var fs = __toESM(require("fs"), 1);
45
48
  var path2 = __toESM(require("path"), 1);
46
49
  var import_crypto2 = require("crypto");
50
+ var import_fs2 = require("fs");
51
+ var import_os2 = require("os");
52
+ var import_path2 = require("path");
53
+ var import_util = require("util");
47
54
  var DEFAULT_API_URL = "https://beta-api.plune.ai";
48
55
  function resolveApiUrl(explicit) {
49
56
  const raw = explicit ?? process.env["PLUNE_API_URL"] ?? DEFAULT_API_URL;
@@ -54,6 +61,8 @@ function credentialsFile() {
54
61
  return (0, import_path.join)(base, "plune", "credentials.json");
55
62
  }
56
63
  function loadToken() {
64
+ const fromEnv = process.env["PLUNE_TOKEN"]?.trim();
65
+ if (fromEnv !== void 0 && fromEnv !== "") return fromEnv;
57
66
  try {
58
67
  const parsed = JSON.parse((0, import_fs.readFileSync)(credentialsFile(), "utf-8"));
59
68
  return typeof parsed.token === "string" && parsed.token.length > 0 ? parsed.token : null;
@@ -62,6 +71,36 @@ function loadToken() {
62
71
  }
63
72
  }
64
73
  var RETRY_DELAYS_MS = [300, 900];
74
+ var IDLE_MS = 3e5;
75
+ function nodeTransport(url, init, idleMs = IDLE_MS) {
76
+ return new Promise((resolve2, reject) => {
77
+ const target = new URL(url);
78
+ const send = target.protocol === "https:" ? import_https.request : import_http.request;
79
+ const req = send(target, { method: init.method, headers: init.headers }, (res) => {
80
+ const chunks = [];
81
+ res.on("data", (chunk2) => chunks.push(chunk2));
82
+ res.on("error", reject);
83
+ res.on("end", () => {
84
+ const status = res.statusCode ?? 0;
85
+ const text = Buffer.concat(chunks).toString("utf8");
86
+ resolve2({
87
+ ok: status >= 200 && status <= 299,
88
+ status,
89
+ headers: {
90
+ get: (name) => {
91
+ const value2 = res.headers[name.toLowerCase()];
92
+ return value2 === void 0 ? null : Array.isArray(value2) ? value2.join(", ") : value2;
93
+ }
94
+ },
95
+ json: async () => JSON.parse(text)
96
+ });
97
+ });
98
+ });
99
+ req.setTimeout(idleMs, () => req.destroy(new Error(`no answer from ${target.origin} in ${idleMs} ms`)));
100
+ req.on("error", reject);
101
+ req.end(init.body);
102
+ });
103
+ }
65
104
  var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
66
105
  async function detailOf(res) {
67
106
  try {
@@ -85,7 +124,7 @@ function classify(status) {
85
124
  return "other";
86
125
  }
87
126
  function createClient(opts) {
88
- const doFetch = opts.fetchImpl ?? fetch;
127
+ const doFetch = opts.fetchImpl ?? nodeTransport;
89
128
  const wait = opts.wait ?? sleep;
90
129
  const base = opts.apiUrl.replace(/\/+$/, "");
91
130
  const scrub = (text) => opts.token === "" ? text : text.split(opts.token).join("***");
@@ -219,6 +258,25 @@ function boundKey(key) {
219
258
  function boundTitle(title) {
220
259
  return title.length <= TITLE_MAX ? title : `${title.slice(0, TITLE_MAX - 1)}\u2026`;
221
260
  }
261
+ var BATCH_BYTES = 8 * 1024 * 1024;
262
+ var ENVELOPE_BYTES = Buffer.byteLength(JSON.stringify({ results: [] }));
263
+ function packed(results) {
264
+ const out = [];
265
+ let part = [];
266
+ let bytes = ENVELOPE_BYTES;
267
+ for (const result of results) {
268
+ const size = Buffer.byteLength(JSON.stringify(result));
269
+ if (part.length > 0 && bytes + 1 + size > BATCH_BYTES) {
270
+ out.push(part);
271
+ part = [];
272
+ bytes = ENVELOPE_BYTES;
273
+ }
274
+ bytes += (part.length > 0 ? 1 : 0) + size;
275
+ part.push(result);
276
+ }
277
+ if (part.length > 0) out.push(part);
278
+ return out;
279
+ }
222
280
  function chunk(items, size) {
223
281
  const out = [];
224
282
  for (let i = 0; i < items.length; i += size) out.push(items.slice(i, i + size));
@@ -232,7 +290,7 @@ function warnIfDropped(sent, run, log) {
232
290
  `plune: this deployment stored none of ${names.join(", ")} \u2014 it is older than the fields. The run is otherwise reported in full.`
233
291
  );
234
292
  }
235
- async function startRun(passed, declared) {
293
+ async function startRun(passed, declared2) {
236
294
  const env = readEnv();
237
295
  const stated = Object.fromEntries(Object.entries(passed).filter(([, v]) => v !== void 0));
238
296
  const cfg = { ...env.config, ...stated };
@@ -281,7 +339,7 @@ async function startRun(passed, declared) {
281
339
  return fit;
282
340
  });
283
341
  }
284
- const expected = declared?.map(bound);
342
+ const expected = declared2?.map(bound);
285
343
  if (offline) {
286
344
  log('plune: no API token \u2014 run "plune login" first. Results will be written to the fallback file.');
287
345
  }
@@ -420,27 +478,32 @@ async function startRun(passed, declared) {
420
478
  progress();
421
479
  return;
422
480
  }
423
- const out = await client.post(
424
- `/v1/runs/${runId}/results`,
425
- { results: submissions }
426
- );
427
- if (out.ok) {
428
- stats.accepted += out.body.counts.accepted ?? 0;
429
- stats.duplicate += out.body.counts.duplicate ?? 0;
430
- stats.conflict += out.body.counts.conflict ?? 0;
431
- stats.rejected += out.body.counts.rejected ?? 0;
432
- progress();
433
- return;
434
- }
435
- if (out.kind === "auth") {
436
- log('plune: the API token was refused \u2014 run "plune login" with a fresh one.');
437
- offline = true;
438
- } else if (out.kind === "conflict") {
439
- log(`plune: this run is closed \u2014 ${out.detail}`);
440
- } else {
441
- log(`plune: could not send results (${out.detail || out.kind}).`);
481
+ for (const part of packed(submissions)) {
482
+ if (offline) {
483
+ defer(part);
484
+ continue;
485
+ }
486
+ const out = await client.post(`/v1/runs/${runId}/results`, {
487
+ results: part
488
+ });
489
+ if (out.ok) {
490
+ stats.accepted += out.body.counts.accepted ?? 0;
491
+ stats.duplicate += out.body.counts.duplicate ?? 0;
492
+ stats.conflict += out.body.counts.conflict ?? 0;
493
+ stats.rejected += out.body.counts.rejected ?? 0;
494
+ progress();
495
+ continue;
496
+ }
497
+ if (out.kind === "auth") {
498
+ log('plune: the API token was refused \u2014 run "plune login" with a fresh one.');
499
+ offline = true;
500
+ } else if (out.kind === "conflict") {
501
+ log(`plune: this run is closed \u2014 ${out.detail}`);
502
+ } else {
503
+ log(`plune: could not send results (${out.detail || out.kind}).`);
504
+ }
505
+ defer(part);
442
506
  }
443
- defer(submissions);
444
507
  }
445
508
  function progress() {
446
509
  const total = expected?.length ?? 0;
@@ -456,9 +519,12 @@ async function startRun(passed, declared) {
456
519
  if (stats.unresolved > 0) parts.push(`${stats.unresolved} with no matching test case`);
457
520
  if (stats.offered > 0) parts.push(`${stats.offered} offered for review`);
458
521
  if (stats.created > 0) parts.push(`${stats.created} added as cases (trusted source)`);
459
- if (stats.deferred > 0) parts.push(`${stats.deferred} written to ${fallbackPath}`);
522
+ if (stats.deferred > 0) parts.push(`${stats.deferred} not delivered \u2014 written to ${fallbackPath}`);
460
523
  if (shortened.size > 0) parts.push(`${shortened.size} test name(s) shortened to fit a key`);
461
524
  log(`plune: ${parts.join(" \xB7 ")}`);
525
+ if (stats.deferred > 0 && process.env["GITHUB_ACTIONS"] === "true") {
526
+ log(`::warning::${stats.deferred} result(s) were not delivered to Plune \u2014 see the reporting step's log.`);
527
+ }
462
528
  }
463
529
  return {
464
530
  get runId() {
@@ -513,10 +579,120 @@ function resultKey(testId, retry) {
513
579
  const plain = `${testId}#${retry}`;
514
580
  return plain.length <= RESULT_KEY_MAX ? plain : `${sha256(testId).slice(0, HASH_CHARS)}#${retry}`;
515
581
  }
582
+ function failureOf(attempt) {
583
+ const error = chosen(attempt);
584
+ const headline = error === void 0 ? void 0 : firstLine(error.text);
585
+ const steps = chainOf(attempt.steps);
586
+ const location = error === void 0 ? void 0 : fromRoot(placeOf(error, attempt.testFile), attempt.repoRoot);
587
+ const artifacts = attempt.attachments.filter((a) => a.path !== void 0 && a.name !== "" && !a.name.startsWith("_") && a.contentType !== METADATA_TYPE).map(({ name, contentType }) => contentType === void 0 ? { name } : { name, contentType });
588
+ const ciUrl = webLink(attempt.buildHref);
589
+ const failure = {
590
+ ...headline !== void 0 ? { headline } : {},
591
+ ...steps.length > 0 ? { steps } : {},
592
+ ...location !== void 0 ? { location } : {},
593
+ ...artifacts.length > 0 ? { artifacts } : {},
594
+ ...ciUrl !== void 0 ? { ciUrl } : {}
595
+ };
596
+ return Object.keys(failure).length === 0 ? void 0 : failure;
597
+ }
598
+ function repoRootOf(dir, stopAt) {
599
+ for (let here = (0, import_path2.resolve)(dir); ; here = (0, import_path2.dirname)(here)) {
600
+ if ((0, import_fs2.existsSync)((0, import_path2.join)(here, ".git"))) return here;
601
+ if (here === stopAt || (0, import_path2.dirname)(here) === here) return void 0;
602
+ }
603
+ }
604
+ function errorContextOf(attempt, home = (0, import_os2.homedir)()) {
605
+ let text = (0, import_util.stripVTControlCharacters)(
606
+ attempt.errors.map((e) => e.text).filter((t) => t !== "").join("\n\n")
607
+ ).replaceAll("\x1B", "");
608
+ const root = attempt.repoRoot === void 0 ? void 0 : pathIn(attempt.repoRoot);
609
+ if (root !== void 0) text = text.replace(new RegExp(`${root.source}[\\\\/]`, root.flags), "");
610
+ const own = pathIn(home);
611
+ if (own !== void 0) text = text.replace(new RegExp(`${own.source}(?![\\w.-])`, own.flags), "~");
612
+ if (attempt.repoRoot === void 0) text = text.replace(ANY_HOME, "~");
613
+ return cut(text);
614
+ }
615
+ var TEXT_LIMIT = 524288;
616
+ var ANY_HOME = /(?<=^|[\s'"`(=,[])(?:file:\/\/\/?)?(?:\/home\/|\/Users\/|[A-Za-z]:[\\/]Users[\\/])[^\\/\s'"`:*?<>|]+/g;
617
+ function pathIn(path3) {
618
+ const parts = path3.split(/[\\/]+/);
619
+ while (parts.length > 1 && parts.at(-1) === "") parts.pop();
620
+ if (!parts.some((part) => part !== "" && !/^[A-Za-z]:$/.test(part))) return void 0;
621
+ const escaped = parts.map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("[\\\\/]");
622
+ return new RegExp(`(?:file:\\/\\/\\/?)?${escaped}`, /^[A-Za-z]:$/.test(parts[0]) ? "gi" : "g");
623
+ }
624
+ function cut(text) {
625
+ if (Buffer.byteLength(text) <= TEXT_LIMIT) return text;
626
+ const lines = text.split("\n");
627
+ const size = lines.map((line) => Buffer.byteLength(line) + 1);
628
+ const budget = TEXT_LIMIT - Buffer.byteLength(omitted(lines.length));
629
+ let used = 0;
630
+ let head = 0;
631
+ let tail = lines.length;
632
+ while (head < tail && used + size[head] <= budget / 2) used += size[head++];
633
+ while (tail > head && used + size[tail - 1] <= budget) used += size[--tail];
634
+ return [...lines.slice(0, head), omitted(tail - head), ...lines.slice(tail)].join("\n");
635
+ }
636
+ var omitted = (lines) => `\u2026[omitted ${lines} lines]\u2026`;
637
+ var METADATA_TYPE = "application/plune.metadata+json";
638
+ var REPO_RELATIVE = /^(?![A-Za-z][A-Za-z0-9+.-]*:)(?![\\/~])(?!(?:.*[\\/])?\.\.(?:[\\/]|$)).+$/;
639
+ var FRAME = /^\s+at (?:.*? \()?(.+?):(\d+):(\d+)\)?$/;
640
+ var firstLine = (text) => (0, import_util.stripVTControlCharacters)(text).split("\n").map((line) => line.trim()).find((line) => line !== "");
641
+ function chosen({ status, errors }) {
642
+ if (status === "timedOut") {
643
+ const timeout = errors.findIndex((e) => firstLine(e.text)?.startsWith("Test timeout of ") === true);
644
+ if (timeout !== -1 && timeout + 1 < errors.length) return errors[timeout + 1];
645
+ }
646
+ return errors[0];
647
+ }
648
+ function chainOf(steps) {
649
+ const chain = [];
650
+ for (let failed = steps.find((s) => s.failed); failed !== void 0; failed = failed.steps.find((s) => s.failed)) {
651
+ chain.push(failed.title);
652
+ }
653
+ return chain;
654
+ }
655
+ function placeOf(error, testFile) {
656
+ const own = normal(testFile);
657
+ let first;
658
+ for (const line of (0, import_util.stripVTControlCharacters)(error.text).split("\n")) {
659
+ const frame = FRAME.exec(line);
660
+ if (frame === null) continue;
661
+ const place = { file: fileOf(frame[1]), line: Number(frame[2]), column: Number(frame[3]) };
662
+ if (normal(place.file) === own) return place;
663
+ if (first === void 0 && !normal(place.file).includes("/node_modules/")) first = place;
664
+ }
665
+ return error.location ?? first;
666
+ }
667
+ function fileOf(raw) {
668
+ if (!raw.startsWith("file://")) return raw;
669
+ const path3 = decodeURIComponent(raw.slice("file://".length));
670
+ return /^\/[A-Za-z]:\//.test(path3) ? path3.slice(1) : path3;
671
+ }
672
+ var normal = (path3) => import_path2.posix.normalize(path3.replace(/\\/g, "/")).replace(/^([a-z]):/, (_, drive) => `${drive.toUpperCase()}:`);
673
+ function fromRoot(place, root) {
674
+ if (place === void 0 || root === void 0 || !Number.isInteger(place.line) || place.line < 1) return void 0;
675
+ const base = normal(root).replace(/\/+$/, "");
676
+ const file = normal(place.file);
677
+ if (!file.startsWith(`${base}/`)) return void 0;
678
+ const relative = file.slice(base.length + 1);
679
+ if (!REPO_RELATIVE.test(relative)) return void 0;
680
+ const column = place.column !== void 0 && Number.isInteger(place.column) && place.column >= 1 ? place.column : void 0;
681
+ return column === void 0 ? { file: relative, line: place.line } : { file: relative, line: place.line, column };
682
+ }
683
+ function webLink(href) {
684
+ if (href === void 0) return void 0;
685
+ try {
686
+ const { protocol } = new URL(href);
687
+ return protocol === "http:" || protocol === "https:" ? href : void 0;
688
+ } catch {
689
+ return void 0;
690
+ }
691
+ }
516
692
 
517
693
  // src/index.ts
518
694
  var SOURCE = "playwright";
519
- function fileOf(test) {
695
+ function fileOf2(test) {
520
696
  for (let suite = test.parent; suite !== void 0; suite = suite.parent) {
521
697
  if (suite.type === "file") return suite.title.replace(/\\/g, "/");
522
698
  }
@@ -532,13 +708,13 @@ function titlesOf(test) {
532
708
  function keysFor(test) {
533
709
  return [
534
710
  { kind: "playwright-id", value: test.id },
535
- { kind: "path-title", value: [fileOf(test), ...titlesOf(test)].join("#") }
711
+ { kind: "path-title", value: [fileOf2(test), ...titlesOf(test)].join("#") }
536
712
  ];
537
713
  }
538
- var METADATA_TYPE = "application/plune.metadata+json";
714
+ var METADATA_TYPE2 = "application/plune.metadata+json";
539
715
  var TOKEN = /@P([A-Za-z0-9_-]+)/;
540
716
  function metadataOf(result) {
541
- const found = result.attachments.find((a) => a.contentType === METADATA_TYPE);
717
+ const found = result.attachments.find((a) => a.contentType === METADATA_TYPE2);
542
718
  if (found === void 0) return void 0;
543
719
  try {
544
720
  const raw = found.body !== void 0 ? found.body.toString("utf8") : found.path !== void 0 ? (0, import_node_fs.readFileSync)(found.path, "utf8") : void 0;
@@ -554,14 +730,43 @@ function statedIdOf(test, metadata) {
554
730
  if (token !== void 0) return token;
555
731
  return metadata?.id !== void 0 && metadata.id !== "" ? metadata.id : void 0;
556
732
  }
557
- function errorTextOf(result) {
558
- return result.errors.map((e) => e.stack ?? e.message ?? e.value ?? "").filter((text) => text !== "").join("\n\n");
733
+ var NOT_FAILED = /* @__PURE__ */ new Set(["passed", "skipped"]);
734
+ function textOf(error) {
735
+ const message = error.message || error.value || "";
736
+ if (!error.stack && !error.location) return message;
737
+ const lines = error.stack?.split("\n") ?? [];
738
+ const at = lines.findIndex((line) => line.startsWith(" at "));
739
+ const tokens = [(at === -1 ? lines : lines.slice(0, at)).join("\n") || message];
740
+ if (error.snippet) tokens.push("", (0, import_node_util.stripVTControlCharacters)(error.snippet));
741
+ if (at !== -1) tokens.push(lines.slice(at).join("\n"));
742
+ if (error.cause) tokens.push(`[cause]: ${textOf(error.cause)}`);
743
+ return tokens.join("\n");
744
+ }
745
+ function declared(steps) {
746
+ return steps.filter((step) => step.category === "test.step").map((step) => ({ title: step.title, failed: step.error !== void 0, steps: declared(step.steps) }));
747
+ }
748
+ function attemptOf(test, result, ctx) {
749
+ return {
750
+ status: result.status,
751
+ errors: result.errors.map((e) => ({ text: textOf(e), ...e.location !== void 0 ? { location: e.location } : {} })),
752
+ steps: declared(result.steps ?? []),
753
+ attachments: result.attachments.map(({ name, contentType, path: path3 }) => ({
754
+ name,
755
+ contentType,
756
+ ...path3 !== void 0 ? { path: path3 } : {}
757
+ })),
758
+ ...ctx.buildHref !== void 0 ? { buildHref: ctx.buildHref } : {},
759
+ testFile: test.location.file,
760
+ ...ctx.repoRoot !== void 0 ? { repoRoot: ctx.repoRoot } : {}
761
+ };
559
762
  }
560
- function pendingFrom(test, result) {
763
+ function pendingFrom(test, result, ctx) {
561
764
  const metadata = metadataOf(result);
562
765
  const pluneId = statedIdOf(test, metadata);
563
766
  const expected = test.expectedStatus;
564
- const errorContext = errorTextOf(result);
767
+ const attempt = attemptOf(test, result, ctx);
768
+ const errorContext = errorContextOf(attempt);
769
+ const failure = NOT_FAILED.has(result.status) ? void 0 : failureOf(attempt);
565
770
  const startedAt = result.startTime;
566
771
  return {
567
772
  resultKey: resultKey(test.id, result.retry),
@@ -575,7 +780,7 @@ function pendingFrom(test, result) {
575
780
  title: titlesOf(test).join(" \u203A "),
576
781
  // The line as well as the file. A reviewer's first move on an unknown test is to open it, and
577
782
  // `specRef` is the only thing the entry carries that can take them there.
578
- specRef: `${fileOf(test)}:${test.location.line}`,
783
+ specRef: `${fileOf2(test)}:${test.location.line}`,
579
784
  source: SOURCE,
580
785
  // The runner's own word, untouched. Mapping it is the platform's job and a project's setting.
581
786
  rawStatus: result.status,
@@ -589,7 +794,8 @@ function pendingFrom(test, result) {
589
794
  retry: result.retry,
590
795
  worker: String(result.workerIndex)
591
796
  },
592
- ...errorContext !== "" ? { errorContext } : {}
797
+ ...errorContext !== "" ? { errorContext } : {},
798
+ ...failure !== void 0 ? { failure } : {}
593
799
  };
594
800
  }
595
801
  var PluneReporter = class {
@@ -601,6 +807,9 @@ var PluneReporter = class {
601
807
  chain = Promise.resolve();
602
808
  keepOpen = false;
603
809
  complained = false;
810
+ /** Kept whole: `metadata.ci` is written into it after `onConfigure`, so it is read at the run's opening. */
811
+ config = null;
812
+ context = {};
604
813
  constructor(options = {}) {
605
814
  this.options = options;
606
815
  }
@@ -614,6 +823,9 @@ var PluneReporter = class {
614
823
  }
615
824
  onConfigure(config) {
616
825
  this.keepOpen = config.shard !== null && config.shard !== void 0 || readEnv().keepOpen;
826
+ this.config = config;
827
+ const repoRoot = config.rootDir === void 0 ? void 0 : repoRootOf(config.rootDir);
828
+ if (repoRoot !== void 0) this.context = { repoRoot };
617
829
  }
618
830
  /**
619
831
  * Only the list is taken here; the run opens on the first result. `onBegin` also fires for
@@ -627,6 +839,10 @@ var PluneReporter = class {
627
839
  }
628
840
  open() {
629
841
  if (this.session === null) {
842
+ const ci = this.config?.metadata?.["ci"];
843
+ const buildHref = typeof ci === "object" && ci !== null ? ci.buildHref : void 0;
844
+ if (typeof buildHref === "string") this.context = { ...this.context, buildHref };
845
+ const ciUrl = webLink(this.context.buildHref);
630
846
  this.session = startRun(
631
847
  {
632
848
  ...this.options.apiUrl !== void 0 ? { apiUrl: this.options.apiUrl } : {},
@@ -634,7 +850,7 @@ var PluneReporter = class {
634
850
  ...this.options.externalKey !== void 0 ? { externalKey: this.options.externalKey } : {},
635
851
  ...this.options.batchSize !== void 0 ? { batchSize: this.options.batchSize } : {},
636
852
  ...this.options.fallbackPath !== void 0 ? { fallbackPath: this.options.fallbackPath } : {},
637
- meta: { runner: SOURCE }
853
+ meta: { runner: SOURCE, ...ciUrl !== void 0 ? { ciUrl } : {} }
638
854
  },
639
855
  this.declared
640
856
  );
@@ -644,7 +860,7 @@ var PluneReporter = class {
644
860
  onTestEnd(test, result) {
645
861
  const session = this.open();
646
862
  this.chain = this.chain.then(async () => {
647
- (await session).add(pendingFrom(test, result));
863
+ (await session).add(pendingFrom(test, result, this.context));
648
864
  }).catch((err) => this.giveUp(err));
649
865
  }
650
866
  async onEnd(_result) {
package/dist/index.d.cts CHANGED
@@ -24,6 +24,9 @@ declare class PluneReporter {
24
24
  private chain;
25
25
  private keepOpen;
26
26
  private complained;
27
+ /** Kept whole: `metadata.ci` is written into it after `onConfigure`, so it is read at the run's opening. */
28
+ private config;
29
+ private context;
27
30
  constructor(options?: PluneReporterOptions);
28
31
  /** Playwright reads this to pick the v2 calling convention (`onConfigure` + `onBegin(suite)`). */
29
32
  version(): 'v2';
package/dist/index.d.ts CHANGED
@@ -24,6 +24,9 @@ declare class PluneReporter {
24
24
  private chain;
25
25
  private keepOpen;
26
26
  private complained;
27
+ /** Kept whole: `metadata.ci` is written into it after `onConfigure`, so it is read at the run's opening. */
28
+ private config;
29
+ private context;
27
30
  constructor(options?: PluneReporterOptions);
28
31
  /** Playwright reads this to pick the v2 calling convention (`onConfigure` + `onBegin(suite)`). */
29
32
  version(): 'v2';
package/dist/index.js CHANGED
@@ -1,15 +1,22 @@
1
1
  // src/index.ts
2
2
  import { readFileSync as readFileSync2 } from "fs";
3
+ import { stripVTControlCharacters as stripVTControlCharacters2 } from "util";
3
4
 
4
5
  // ../../dist/reporter-core.js
5
6
  import { createHash } from "crypto";
6
7
  import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "fs";
7
8
  import { homedir } from "os";
8
9
  import { dirname, join } from "path";
10
+ import { request as httpRequest } from "http";
11
+ import { request as httpsRequest } from "https";
9
12
  import * as path from "path";
10
13
  import * as fs from "fs";
11
14
  import * as path2 from "path";
12
15
  import { createHash as createHash2 } from "crypto";
16
+ import { existsSync as existsSync2 } from "fs";
17
+ import { homedir as homedir2 } from "os";
18
+ import { dirname as dirname3, join as join3, posix, resolve } from "path";
19
+ import { stripVTControlCharacters } from "util";
13
20
  var DEFAULT_API_URL = "https://beta-api.plune.ai";
14
21
  function resolveApiUrl(explicit) {
15
22
  const raw = explicit ?? process.env["PLUNE_API_URL"] ?? DEFAULT_API_URL;
@@ -20,6 +27,8 @@ function credentialsFile() {
20
27
  return join(base, "plune", "credentials.json");
21
28
  }
22
29
  function loadToken() {
30
+ const fromEnv = process.env["PLUNE_TOKEN"]?.trim();
31
+ if (fromEnv !== void 0 && fromEnv !== "") return fromEnv;
23
32
  try {
24
33
  const parsed = JSON.parse(readFileSync(credentialsFile(), "utf-8"));
25
34
  return typeof parsed.token === "string" && parsed.token.length > 0 ? parsed.token : null;
@@ -28,6 +37,36 @@ function loadToken() {
28
37
  }
29
38
  }
30
39
  var RETRY_DELAYS_MS = [300, 900];
40
+ var IDLE_MS = 3e5;
41
+ function nodeTransport(url, init, idleMs = IDLE_MS) {
42
+ return new Promise((resolve2, reject) => {
43
+ const target = new URL(url);
44
+ const send = target.protocol === "https:" ? httpsRequest : httpRequest;
45
+ const req = send(target, { method: init.method, headers: init.headers }, (res) => {
46
+ const chunks = [];
47
+ res.on("data", (chunk2) => chunks.push(chunk2));
48
+ res.on("error", reject);
49
+ res.on("end", () => {
50
+ const status = res.statusCode ?? 0;
51
+ const text = Buffer.concat(chunks).toString("utf8");
52
+ resolve2({
53
+ ok: status >= 200 && status <= 299,
54
+ status,
55
+ headers: {
56
+ get: (name) => {
57
+ const value2 = res.headers[name.toLowerCase()];
58
+ return value2 === void 0 ? null : Array.isArray(value2) ? value2.join(", ") : value2;
59
+ }
60
+ },
61
+ json: async () => JSON.parse(text)
62
+ });
63
+ });
64
+ });
65
+ req.setTimeout(idleMs, () => req.destroy(new Error(`no answer from ${target.origin} in ${idleMs} ms`)));
66
+ req.on("error", reject);
67
+ req.end(init.body);
68
+ });
69
+ }
31
70
  var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
32
71
  async function detailOf(res) {
33
72
  try {
@@ -51,7 +90,7 @@ function classify(status) {
51
90
  return "other";
52
91
  }
53
92
  function createClient(opts) {
54
- const doFetch = opts.fetchImpl ?? fetch;
93
+ const doFetch = opts.fetchImpl ?? nodeTransport;
55
94
  const wait = opts.wait ?? sleep;
56
95
  const base = opts.apiUrl.replace(/\/+$/, "");
57
96
  const scrub = (text) => opts.token === "" ? text : text.split(opts.token).join("***");
@@ -185,6 +224,25 @@ function boundKey(key) {
185
224
  function boundTitle(title) {
186
225
  return title.length <= TITLE_MAX ? title : `${title.slice(0, TITLE_MAX - 1)}\u2026`;
187
226
  }
227
+ var BATCH_BYTES = 8 * 1024 * 1024;
228
+ var ENVELOPE_BYTES = Buffer.byteLength(JSON.stringify({ results: [] }));
229
+ function packed(results) {
230
+ const out = [];
231
+ let part = [];
232
+ let bytes = ENVELOPE_BYTES;
233
+ for (const result of results) {
234
+ const size = Buffer.byteLength(JSON.stringify(result));
235
+ if (part.length > 0 && bytes + 1 + size > BATCH_BYTES) {
236
+ out.push(part);
237
+ part = [];
238
+ bytes = ENVELOPE_BYTES;
239
+ }
240
+ bytes += (part.length > 0 ? 1 : 0) + size;
241
+ part.push(result);
242
+ }
243
+ if (part.length > 0) out.push(part);
244
+ return out;
245
+ }
188
246
  function chunk(items, size) {
189
247
  const out = [];
190
248
  for (let i = 0; i < items.length; i += size) out.push(items.slice(i, i + size));
@@ -198,7 +256,7 @@ function warnIfDropped(sent, run, log) {
198
256
  `plune: this deployment stored none of ${names.join(", ")} \u2014 it is older than the fields. The run is otherwise reported in full.`
199
257
  );
200
258
  }
201
- async function startRun(passed, declared) {
259
+ async function startRun(passed, declared2) {
202
260
  const env = readEnv();
203
261
  const stated = Object.fromEntries(Object.entries(passed).filter(([, v]) => v !== void 0));
204
262
  const cfg = { ...env.config, ...stated };
@@ -247,7 +305,7 @@ async function startRun(passed, declared) {
247
305
  return fit;
248
306
  });
249
307
  }
250
- const expected = declared?.map(bound);
308
+ const expected = declared2?.map(bound);
251
309
  if (offline) {
252
310
  log('plune: no API token \u2014 run "plune login" first. Results will be written to the fallback file.');
253
311
  }
@@ -386,27 +444,32 @@ async function startRun(passed, declared) {
386
444
  progress();
387
445
  return;
388
446
  }
389
- const out = await client.post(
390
- `/v1/runs/${runId}/results`,
391
- { results: submissions }
392
- );
393
- if (out.ok) {
394
- stats.accepted += out.body.counts.accepted ?? 0;
395
- stats.duplicate += out.body.counts.duplicate ?? 0;
396
- stats.conflict += out.body.counts.conflict ?? 0;
397
- stats.rejected += out.body.counts.rejected ?? 0;
398
- progress();
399
- return;
400
- }
401
- if (out.kind === "auth") {
402
- log('plune: the API token was refused \u2014 run "plune login" with a fresh one.');
403
- offline = true;
404
- } else if (out.kind === "conflict") {
405
- log(`plune: this run is closed \u2014 ${out.detail}`);
406
- } else {
407
- log(`plune: could not send results (${out.detail || out.kind}).`);
447
+ for (const part of packed(submissions)) {
448
+ if (offline) {
449
+ defer(part);
450
+ continue;
451
+ }
452
+ const out = await client.post(`/v1/runs/${runId}/results`, {
453
+ results: part
454
+ });
455
+ if (out.ok) {
456
+ stats.accepted += out.body.counts.accepted ?? 0;
457
+ stats.duplicate += out.body.counts.duplicate ?? 0;
458
+ stats.conflict += out.body.counts.conflict ?? 0;
459
+ stats.rejected += out.body.counts.rejected ?? 0;
460
+ progress();
461
+ continue;
462
+ }
463
+ if (out.kind === "auth") {
464
+ log('plune: the API token was refused \u2014 run "plune login" with a fresh one.');
465
+ offline = true;
466
+ } else if (out.kind === "conflict") {
467
+ log(`plune: this run is closed \u2014 ${out.detail}`);
468
+ } else {
469
+ log(`plune: could not send results (${out.detail || out.kind}).`);
470
+ }
471
+ defer(part);
408
472
  }
409
- defer(submissions);
410
473
  }
411
474
  function progress() {
412
475
  const total = expected?.length ?? 0;
@@ -422,9 +485,12 @@ async function startRun(passed, declared) {
422
485
  if (stats.unresolved > 0) parts.push(`${stats.unresolved} with no matching test case`);
423
486
  if (stats.offered > 0) parts.push(`${stats.offered} offered for review`);
424
487
  if (stats.created > 0) parts.push(`${stats.created} added as cases (trusted source)`);
425
- if (stats.deferred > 0) parts.push(`${stats.deferred} written to ${fallbackPath}`);
488
+ if (stats.deferred > 0) parts.push(`${stats.deferred} not delivered \u2014 written to ${fallbackPath}`);
426
489
  if (shortened.size > 0) parts.push(`${shortened.size} test name(s) shortened to fit a key`);
427
490
  log(`plune: ${parts.join(" \xB7 ")}`);
491
+ if (stats.deferred > 0 && process.env["GITHUB_ACTIONS"] === "true") {
492
+ log(`::warning::${stats.deferred} result(s) were not delivered to Plune \u2014 see the reporting step's log.`);
493
+ }
428
494
  }
429
495
  return {
430
496
  get runId() {
@@ -479,10 +545,120 @@ function resultKey(testId, retry) {
479
545
  const plain = `${testId}#${retry}`;
480
546
  return plain.length <= RESULT_KEY_MAX ? plain : `${sha256(testId).slice(0, HASH_CHARS)}#${retry}`;
481
547
  }
548
+ function failureOf(attempt) {
549
+ const error = chosen(attempt);
550
+ const headline = error === void 0 ? void 0 : firstLine(error.text);
551
+ const steps = chainOf(attempt.steps);
552
+ const location = error === void 0 ? void 0 : fromRoot(placeOf(error, attempt.testFile), attempt.repoRoot);
553
+ const artifacts = attempt.attachments.filter((a) => a.path !== void 0 && a.name !== "" && !a.name.startsWith("_") && a.contentType !== METADATA_TYPE).map(({ name, contentType }) => contentType === void 0 ? { name } : { name, contentType });
554
+ const ciUrl = webLink(attempt.buildHref);
555
+ const failure = {
556
+ ...headline !== void 0 ? { headline } : {},
557
+ ...steps.length > 0 ? { steps } : {},
558
+ ...location !== void 0 ? { location } : {},
559
+ ...artifacts.length > 0 ? { artifacts } : {},
560
+ ...ciUrl !== void 0 ? { ciUrl } : {}
561
+ };
562
+ return Object.keys(failure).length === 0 ? void 0 : failure;
563
+ }
564
+ function repoRootOf(dir, stopAt) {
565
+ for (let here = resolve(dir); ; here = dirname3(here)) {
566
+ if (existsSync2(join3(here, ".git"))) return here;
567
+ if (here === stopAt || dirname3(here) === here) return void 0;
568
+ }
569
+ }
570
+ function errorContextOf(attempt, home = homedir2()) {
571
+ let text = stripVTControlCharacters(
572
+ attempt.errors.map((e) => e.text).filter((t) => t !== "").join("\n\n")
573
+ ).replaceAll("\x1B", "");
574
+ const root = attempt.repoRoot === void 0 ? void 0 : pathIn(attempt.repoRoot);
575
+ if (root !== void 0) text = text.replace(new RegExp(`${root.source}[\\\\/]`, root.flags), "");
576
+ const own = pathIn(home);
577
+ if (own !== void 0) text = text.replace(new RegExp(`${own.source}(?![\\w.-])`, own.flags), "~");
578
+ if (attempt.repoRoot === void 0) text = text.replace(ANY_HOME, "~");
579
+ return cut(text);
580
+ }
581
+ var TEXT_LIMIT = 524288;
582
+ var ANY_HOME = /(?<=^|[\s'"`(=,[])(?:file:\/\/\/?)?(?:\/home\/|\/Users\/|[A-Za-z]:[\\/]Users[\\/])[^\\/\s'"`:*?<>|]+/g;
583
+ function pathIn(path3) {
584
+ const parts = path3.split(/[\\/]+/);
585
+ while (parts.length > 1 && parts.at(-1) === "") parts.pop();
586
+ if (!parts.some((part) => part !== "" && !/^[A-Za-z]:$/.test(part))) return void 0;
587
+ const escaped = parts.map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("[\\\\/]");
588
+ return new RegExp(`(?:file:\\/\\/\\/?)?${escaped}`, /^[A-Za-z]:$/.test(parts[0]) ? "gi" : "g");
589
+ }
590
+ function cut(text) {
591
+ if (Buffer.byteLength(text) <= TEXT_LIMIT) return text;
592
+ const lines = text.split("\n");
593
+ const size = lines.map((line) => Buffer.byteLength(line) + 1);
594
+ const budget = TEXT_LIMIT - Buffer.byteLength(omitted(lines.length));
595
+ let used = 0;
596
+ let head = 0;
597
+ let tail = lines.length;
598
+ while (head < tail && used + size[head] <= budget / 2) used += size[head++];
599
+ while (tail > head && used + size[tail - 1] <= budget) used += size[--tail];
600
+ return [...lines.slice(0, head), omitted(tail - head), ...lines.slice(tail)].join("\n");
601
+ }
602
+ var omitted = (lines) => `\u2026[omitted ${lines} lines]\u2026`;
603
+ var METADATA_TYPE = "application/plune.metadata+json";
604
+ var REPO_RELATIVE = /^(?![A-Za-z][A-Za-z0-9+.-]*:)(?![\\/~])(?!(?:.*[\\/])?\.\.(?:[\\/]|$)).+$/;
605
+ var FRAME = /^\s+at (?:.*? \()?(.+?):(\d+):(\d+)\)?$/;
606
+ var firstLine = (text) => stripVTControlCharacters(text).split("\n").map((line) => line.trim()).find((line) => line !== "");
607
+ function chosen({ status, errors }) {
608
+ if (status === "timedOut") {
609
+ const timeout = errors.findIndex((e) => firstLine(e.text)?.startsWith("Test timeout of ") === true);
610
+ if (timeout !== -1 && timeout + 1 < errors.length) return errors[timeout + 1];
611
+ }
612
+ return errors[0];
613
+ }
614
+ function chainOf(steps) {
615
+ const chain = [];
616
+ for (let failed = steps.find((s) => s.failed); failed !== void 0; failed = failed.steps.find((s) => s.failed)) {
617
+ chain.push(failed.title);
618
+ }
619
+ return chain;
620
+ }
621
+ function placeOf(error, testFile) {
622
+ const own = normal(testFile);
623
+ let first;
624
+ for (const line of stripVTControlCharacters(error.text).split("\n")) {
625
+ const frame = FRAME.exec(line);
626
+ if (frame === null) continue;
627
+ const place = { file: fileOf(frame[1]), line: Number(frame[2]), column: Number(frame[3]) };
628
+ if (normal(place.file) === own) return place;
629
+ if (first === void 0 && !normal(place.file).includes("/node_modules/")) first = place;
630
+ }
631
+ return error.location ?? first;
632
+ }
633
+ function fileOf(raw) {
634
+ if (!raw.startsWith("file://")) return raw;
635
+ const path3 = decodeURIComponent(raw.slice("file://".length));
636
+ return /^\/[A-Za-z]:\//.test(path3) ? path3.slice(1) : path3;
637
+ }
638
+ var normal = (path3) => posix.normalize(path3.replace(/\\/g, "/")).replace(/^([a-z]):/, (_, drive) => `${drive.toUpperCase()}:`);
639
+ function fromRoot(place, root) {
640
+ if (place === void 0 || root === void 0 || !Number.isInteger(place.line) || place.line < 1) return void 0;
641
+ const base = normal(root).replace(/\/+$/, "");
642
+ const file = normal(place.file);
643
+ if (!file.startsWith(`${base}/`)) return void 0;
644
+ const relative = file.slice(base.length + 1);
645
+ if (!REPO_RELATIVE.test(relative)) return void 0;
646
+ const column = place.column !== void 0 && Number.isInteger(place.column) && place.column >= 1 ? place.column : void 0;
647
+ return column === void 0 ? { file: relative, line: place.line } : { file: relative, line: place.line, column };
648
+ }
649
+ function webLink(href) {
650
+ if (href === void 0) return void 0;
651
+ try {
652
+ const { protocol } = new URL(href);
653
+ return protocol === "http:" || protocol === "https:" ? href : void 0;
654
+ } catch {
655
+ return void 0;
656
+ }
657
+ }
482
658
 
483
659
  // src/index.ts
484
660
  var SOURCE = "playwright";
485
- function fileOf(test) {
661
+ function fileOf2(test) {
486
662
  for (let suite = test.parent; suite !== void 0; suite = suite.parent) {
487
663
  if (suite.type === "file") return suite.title.replace(/\\/g, "/");
488
664
  }
@@ -498,13 +674,13 @@ function titlesOf(test) {
498
674
  function keysFor(test) {
499
675
  return [
500
676
  { kind: "playwright-id", value: test.id },
501
- { kind: "path-title", value: [fileOf(test), ...titlesOf(test)].join("#") }
677
+ { kind: "path-title", value: [fileOf2(test), ...titlesOf(test)].join("#") }
502
678
  ];
503
679
  }
504
- var METADATA_TYPE = "application/plune.metadata+json";
680
+ var METADATA_TYPE2 = "application/plune.metadata+json";
505
681
  var TOKEN = /@P([A-Za-z0-9_-]+)/;
506
682
  function metadataOf(result) {
507
- const found = result.attachments.find((a) => a.contentType === METADATA_TYPE);
683
+ const found = result.attachments.find((a) => a.contentType === METADATA_TYPE2);
508
684
  if (found === void 0) return void 0;
509
685
  try {
510
686
  const raw = found.body !== void 0 ? found.body.toString("utf8") : found.path !== void 0 ? readFileSync2(found.path, "utf8") : void 0;
@@ -520,14 +696,43 @@ function statedIdOf(test, metadata) {
520
696
  if (token !== void 0) return token;
521
697
  return metadata?.id !== void 0 && metadata.id !== "" ? metadata.id : void 0;
522
698
  }
523
- function errorTextOf(result) {
524
- return result.errors.map((e) => e.stack ?? e.message ?? e.value ?? "").filter((text) => text !== "").join("\n\n");
699
+ var NOT_FAILED = /* @__PURE__ */ new Set(["passed", "skipped"]);
700
+ function textOf(error) {
701
+ const message = error.message || error.value || "";
702
+ if (!error.stack && !error.location) return message;
703
+ const lines = error.stack?.split("\n") ?? [];
704
+ const at = lines.findIndex((line) => line.startsWith(" at "));
705
+ const tokens = [(at === -1 ? lines : lines.slice(0, at)).join("\n") || message];
706
+ if (error.snippet) tokens.push("", stripVTControlCharacters2(error.snippet));
707
+ if (at !== -1) tokens.push(lines.slice(at).join("\n"));
708
+ if (error.cause) tokens.push(`[cause]: ${textOf(error.cause)}`);
709
+ return tokens.join("\n");
710
+ }
711
+ function declared(steps) {
712
+ return steps.filter((step) => step.category === "test.step").map((step) => ({ title: step.title, failed: step.error !== void 0, steps: declared(step.steps) }));
713
+ }
714
+ function attemptOf(test, result, ctx) {
715
+ return {
716
+ status: result.status,
717
+ errors: result.errors.map((e) => ({ text: textOf(e), ...e.location !== void 0 ? { location: e.location } : {} })),
718
+ steps: declared(result.steps ?? []),
719
+ attachments: result.attachments.map(({ name, contentType, path: path3 }) => ({
720
+ name,
721
+ contentType,
722
+ ...path3 !== void 0 ? { path: path3 } : {}
723
+ })),
724
+ ...ctx.buildHref !== void 0 ? { buildHref: ctx.buildHref } : {},
725
+ testFile: test.location.file,
726
+ ...ctx.repoRoot !== void 0 ? { repoRoot: ctx.repoRoot } : {}
727
+ };
525
728
  }
526
- function pendingFrom(test, result) {
729
+ function pendingFrom(test, result, ctx) {
527
730
  const metadata = metadataOf(result);
528
731
  const pluneId = statedIdOf(test, metadata);
529
732
  const expected = test.expectedStatus;
530
- const errorContext = errorTextOf(result);
733
+ const attempt = attemptOf(test, result, ctx);
734
+ const errorContext = errorContextOf(attempt);
735
+ const failure = NOT_FAILED.has(result.status) ? void 0 : failureOf(attempt);
531
736
  const startedAt = result.startTime;
532
737
  return {
533
738
  resultKey: resultKey(test.id, result.retry),
@@ -541,7 +746,7 @@ function pendingFrom(test, result) {
541
746
  title: titlesOf(test).join(" \u203A "),
542
747
  // The line as well as the file. A reviewer's first move on an unknown test is to open it, and
543
748
  // `specRef` is the only thing the entry carries that can take them there.
544
- specRef: `${fileOf(test)}:${test.location.line}`,
749
+ specRef: `${fileOf2(test)}:${test.location.line}`,
545
750
  source: SOURCE,
546
751
  // The runner's own word, untouched. Mapping it is the platform's job and a project's setting.
547
752
  rawStatus: result.status,
@@ -555,7 +760,8 @@ function pendingFrom(test, result) {
555
760
  retry: result.retry,
556
761
  worker: String(result.workerIndex)
557
762
  },
558
- ...errorContext !== "" ? { errorContext } : {}
763
+ ...errorContext !== "" ? { errorContext } : {},
764
+ ...failure !== void 0 ? { failure } : {}
559
765
  };
560
766
  }
561
767
  var PluneReporter = class {
@@ -567,6 +773,9 @@ var PluneReporter = class {
567
773
  chain = Promise.resolve();
568
774
  keepOpen = false;
569
775
  complained = false;
776
+ /** Kept whole: `metadata.ci` is written into it after `onConfigure`, so it is read at the run's opening. */
777
+ config = null;
778
+ context = {};
570
779
  constructor(options = {}) {
571
780
  this.options = options;
572
781
  }
@@ -580,6 +789,9 @@ var PluneReporter = class {
580
789
  }
581
790
  onConfigure(config) {
582
791
  this.keepOpen = config.shard !== null && config.shard !== void 0 || readEnv().keepOpen;
792
+ this.config = config;
793
+ const repoRoot = config.rootDir === void 0 ? void 0 : repoRootOf(config.rootDir);
794
+ if (repoRoot !== void 0) this.context = { repoRoot };
583
795
  }
584
796
  /**
585
797
  * Only the list is taken here; the run opens on the first result. `onBegin` also fires for
@@ -593,6 +805,10 @@ var PluneReporter = class {
593
805
  }
594
806
  open() {
595
807
  if (this.session === null) {
808
+ const ci = this.config?.metadata?.["ci"];
809
+ const buildHref = typeof ci === "object" && ci !== null ? ci.buildHref : void 0;
810
+ if (typeof buildHref === "string") this.context = { ...this.context, buildHref };
811
+ const ciUrl = webLink(this.context.buildHref);
596
812
  this.session = startRun(
597
813
  {
598
814
  ...this.options.apiUrl !== void 0 ? { apiUrl: this.options.apiUrl } : {},
@@ -600,7 +816,7 @@ var PluneReporter = class {
600
816
  ...this.options.externalKey !== void 0 ? { externalKey: this.options.externalKey } : {},
601
817
  ...this.options.batchSize !== void 0 ? { batchSize: this.options.batchSize } : {},
602
818
  ...this.options.fallbackPath !== void 0 ? { fallbackPath: this.options.fallbackPath } : {},
603
- meta: { runner: SOURCE }
819
+ meta: { runner: SOURCE, ...ciUrl !== void 0 ? { ciUrl } : {} }
604
820
  },
605
821
  this.declared
606
822
  );
@@ -610,7 +826,7 @@ var PluneReporter = class {
610
826
  onTestEnd(test, result) {
611
827
  const session = this.open();
612
828
  this.chain = this.chain.then(async () => {
613
- (await session).add(pendingFrom(test, result));
829
+ (await session).add(pendingFrom(test, result, this.context));
614
830
  }).catch((err) => this.giveUp(err));
615
831
  }
616
832
  async onEnd(_result) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plune-ai/playwright",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Report Playwright results to Plune — a reporter and, later, a test importer.",
5
5
  "keywords": [
6
6
  "playwright",
@@ -38,7 +38,7 @@
38
38
  "tsup": "^8.0.0",
39
39
  "typescript": "^5.4.0",
40
40
  "vitest": "^1.6.0",
41
- "@plune-ai/cli": "0.12.0"
41
+ "@plune-ai/cli": "0.14.0"
42
42
  },
43
43
  "repository": {
44
44
  "type": "git",