@piwitests/reporter 0.15.0 → 0.17.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.
@@ -57,6 +57,7 @@ var DEFAULTS = {
57
57
  collectPerformanceMetrics: true,
58
58
  captureLocators: true,
59
59
  capturePageState: true,
60
+ captureServerTraces: true,
60
61
  streaming: true,
61
62
  streamingBatchSize: 5,
62
63
  streamingBatchDelay: 2e3,
@@ -83,6 +84,7 @@ var PIWI_ENV_KEYS = {
83
84
  uploadReport: "PIWI_UPLOAD_REPORT",
84
85
  captureLocators: "PIWI_CAPTURE_LOCATORS",
85
86
  capturePageState: "PIWI_CAPTURE_PAGE_STATE",
87
+ captureServerTraces: "PIWI_CAPTURE_SERVER_TRACES",
86
88
  inspectOnFailure: "PIWI_INSPECT_ON_FAIL",
87
89
  pickLocatorOnFailure: "PIWI_PICK_LOCATOR_ON_FAIL",
88
90
  outputFile: "PIWI_OUTPUT_FILE"
@@ -108,6 +110,7 @@ var ENV_FALLBACK_SPECS = [
108
110
  { option: "uploadReport", env: PIWI_ENV_KEYS.uploadReport, kind: "bool" },
109
111
  { option: "captureLocators", env: PIWI_ENV_KEYS.captureLocators, kind: "bool" },
110
112
  { option: "capturePageState", env: PIWI_ENV_KEYS.capturePageState, kind: "bool" },
113
+ { option: "captureServerTraces", env: PIWI_ENV_KEYS.captureServerTraces, kind: "bool" },
111
114
  { option: "inspectOnFailure", env: PIWI_ENV_KEYS.inspectOnFailure, kind: "bool" },
112
115
  { option: "pickLocatorOnFailure", env: PIWI_ENV_KEYS.pickLocatorOnFailure, kind: "bool" },
113
116
  { option: "outputFile", env: PIWI_ENV_KEYS.outputFile, kind: "string" }
package/dist/index.d.ts CHANGED
@@ -41,6 +41,16 @@ interface PiwiDashboardOptions extends PlaywrightTestConfig {
41
41
  * also be forced off with `PIWI_CAPTURE_PAGE_STATE=false`.
42
42
  */
43
43
  capturePageState?: boolean;
44
+ /**
45
+ * Capture server-side spans for each API/document request the test makes,
46
+ * read from the `X-Piwi-Trace` response header emitted by a Piwi
47
+ * instrumentation plugin (e.g. `@piwitests/instrumentation`). The spans show
48
+ * up next to the network request in the dashboard and feed AI diagnosis. Free
49
+ * when no instrumentation is present (the header is simply absent). Defaults
50
+ * to `true`; automatically disabled when `collectPerformanceMetrics` is
51
+ * `false`. Can also be forced off with `PIWI_CAPTURE_SERVER_TRACES=false`.
52
+ */
53
+ captureServerTraces?: boolean;
44
54
  /**
45
55
  * Open Piwi's own failure-time overlay on the failing page — for inspecting
46
56
  * the page and picking a locator for any element (click an element → confirm
package/dist/index.js CHANGED
@@ -53,6 +53,7 @@ var DEFAULTS = {
53
53
  collectPerformanceMetrics: true,
54
54
  captureLocators: true,
55
55
  capturePageState: true,
56
+ captureServerTraces: true,
56
57
  streaming: true,
57
58
  streamingBatchSize: 5,
58
59
  streamingBatchDelay: 2e3,
@@ -79,6 +80,7 @@ var PIWI_ENV_KEYS = {
79
80
  uploadReport: "PIWI_UPLOAD_REPORT",
80
81
  captureLocators: "PIWI_CAPTURE_LOCATORS",
81
82
  capturePageState: "PIWI_CAPTURE_PAGE_STATE",
83
+ captureServerTraces: "PIWI_CAPTURE_SERVER_TRACES",
82
84
  inspectOnFailure: "PIWI_INSPECT_ON_FAIL",
83
85
  pickLocatorOnFailure: "PIWI_PICK_LOCATOR_ON_FAIL",
84
86
  outputFile: "PIWI_OUTPUT_FILE"
@@ -104,6 +106,7 @@ var ENV_FALLBACK_SPECS = [
104
106
  { option: "uploadReport", env: PIWI_ENV_KEYS.uploadReport, kind: "bool" },
105
107
  { option: "captureLocators", env: PIWI_ENV_KEYS.captureLocators, kind: "bool" },
106
108
  { option: "capturePageState", env: PIWI_ENV_KEYS.capturePageState, kind: "bool" },
109
+ { option: "captureServerTraces", env: PIWI_ENV_KEYS.captureServerTraces, kind: "bool" },
107
110
  { option: "inspectOnFailure", env: PIWI_ENV_KEYS.inspectOnFailure, kind: "bool" },
108
111
  { option: "pickLocatorOnFailure", env: PIWI_ENV_KEYS.pickLocatorOnFailure, kind: "bool" },
109
112
  { option: "outputFile", env: PIWI_ENV_KEYS.outputFile, kind: "string" }
@@ -141,6 +144,9 @@ function applyOptionsToEnv(options) {
141
144
  if (options.capturePageState === false || options.collectPerformanceMetrics === false)
142
145
  env[PIWI_ENV_KEYS.capturePageState] = "false";
143
146
  else if (options.capturePageState === true) env[PIWI_ENV_KEYS.capturePageState] = "true";
147
+ if (options.captureServerTraces === false || options.collectPerformanceMetrics === false)
148
+ env[PIWI_ENV_KEYS.captureServerTraces] = "false";
149
+ else if (options.captureServerTraces === true) env[PIWI_ENV_KEYS.captureServerTraces] = "true";
144
150
  if (options.inspectOnFailure !== void 0) env[PIWI_ENV_KEYS.inspectOnFailure] = String(options.inspectOnFailure);
145
151
  if (options.pickLocatorOnFailure !== void 0)
146
152
  env[PIWI_ENV_KEYS.pickLocatorOnFailure] = String(options.pickLocatorOnFailure);
@@ -355,6 +361,7 @@ function toWireTestCase(tc) {
355
361
  location: rest.location,
356
362
  status: rest.status,
357
363
  duration: rest.duration,
364
+ timeout: rest.timeout ?? null,
358
365
  error: rest.error,
359
366
  retries: rest.retries,
360
367
  workerIndex: rest.workerIndex ?? null,
@@ -2472,6 +2479,9 @@ var PiwiDashboardReporter = class {
2472
2479
  location: testLocation(test),
2473
2480
  status,
2474
2481
  duration: result.duration,
2482
+ // Effective per-test timeout (reflects project config + describe-level
2483
+ // overrides). `0` means unbounded; kept as-is so the dashboard can flag it.
2484
+ timeout: test.timeout ?? null,
2475
2485
  error: buildErrorText(result),
2476
2486
  retries: result.retry,
2477
2487
  workerIndex: workerIndexOf(result),
@@ -2547,6 +2557,7 @@ var PiwiDashboardReporter = class {
2547
2557
  location: testLocation(test),
2548
2558
  status: "didnotrun",
2549
2559
  duration: 0,
2560
+ timeout: test.timeout ?? null,
2550
2561
  error: null,
2551
2562
  retries: 0,
2552
2563
  workerIndex: null,
@@ -4627,6 +4638,13 @@ function instrumentPage(page) {
4627
4638
  } catch {
4628
4639
  }
4629
4640
  }
4641
+ const traceHeader = headers["x-piwi-trace"];
4642
+ if (traceHeader && process.env.PIWI_CAPTURE_SERVER_TRACES !== "false") {
4643
+ try {
4644
+ entry.serverTraces = JSON.parse((0, import_node_zlib.gunzipSync)(Buffer.from(traceHeader, "base64")).toString("utf-8"));
4645
+ } catch {
4646
+ }
4647
+ }
4630
4648
  }
4631
4649
  sink.networkRequests.push(entry);
4632
4650
  } catch {
@@ -2085,6 +2085,13 @@ function instrumentPage(page) {
2085
2085
  } catch {
2086
2086
  }
2087
2087
  }
2088
+ const traceHeader = headers["x-piwi-trace"];
2089
+ if (traceHeader && process.env.PIWI_CAPTURE_SERVER_TRACES !== "false") {
2090
+ try {
2091
+ entry.serverTraces = JSON.parse((0, import_node_zlib.gunzipSync)(Buffer.from(traceHeader, "base64")).toString("utf-8"));
2092
+ } catch {
2093
+ }
2094
+ }
2088
2095
  }
2089
2096
  sink.networkRequests.push(entry);
2090
2097
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@piwitests/reporter",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
4
4
  "description": "Playwright reporter for sending test results to Piwi Dashboard",
5
5
  "url": "https://github.com/PiwiTests/platform",
6
6
  "homepage": "https://piwitests.github.io",