@piwitests/reporter 0.52.0 → 0.54.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.
@@ -1,3 +1,5 @@
1
+ export { FAILURE_SCREENSHOT_ATTACHMENT } from '@piwitests/core/wire';
2
+
1
3
  /**
2
4
  * Names of the `testInfo` attachments the dashboard fixtures produce and the
3
5
  * reporter parses. Single source of truth — imported by the producer
@@ -15,6 +17,7 @@ declare const ATTACHMENT_NAMES: {
15
17
  readonly pageInventory: "piwi-page-inventory";
16
18
  readonly locatorPages: "piwi-locator-pages";
17
19
  readonly codeReach: "piwi-code-reach";
20
+ readonly serverCoverageRequests: "piwi-server-coverage-requests";
18
21
  readonly webVitals: "piwi-web-vitals";
19
22
  readonly locatorSuggestion: "piwi-locator-suggestion";
20
23
  readonly pageState: "piwi-page-state";
@@ -25,6 +28,7 @@ declare const ATTACHMENT_NAMES: {
25
28
  };
26
29
  /** Set of every internal attachment name — used to skip them when collecting user attachments. */
27
30
  declare const INTERNAL_ATTACHMENT_NAMES: ReadonlySet<string>;
31
+
28
32
  /** Annotation type that surfaces a locator-healing suggestion in the report/trace. */
29
33
  declare const LOCATOR_SUGGESTION_ANNOTATION: "piwi-locator-suggestion";
30
34
  /** Annotation type that surfaces a human-confirmed replacement locator in the report/trace. */
@@ -21,11 +21,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var attachments_exports = {};
22
22
  __export(attachments_exports, {
23
23
  ATTACHMENT_NAMES: () => ATTACHMENT_NAMES,
24
+ FAILURE_SCREENSHOT_ATTACHMENT: () => FAILURE_SCREENSHOT_ATTACHMENT,
24
25
  INTERNAL_ATTACHMENT_NAMES: () => INTERNAL_ATTACHMENT_NAMES,
25
26
  LOCATOR_SUGGESTION_ANNOTATION: () => LOCATOR_SUGGESTION_ANNOTATION,
26
27
  USER_PICK_ANNOTATION: () => USER_PICK_ANNOTATION
27
28
  });
28
29
  module.exports = __toCommonJS(attachments_exports);
30
+
31
+ // ../core/src/wire.ts
32
+ var FAILURE_SCREENSHOT_ATTACHMENT = "piwi-failure-screenshot";
33
+
34
+ // src/internal/capture/attachments.ts
29
35
  var ATTACHMENT_NAMES = {
30
36
  locators: "piwi-locators",
31
37
  ariaSnapshot: "piwi-aria-snapshot",
@@ -36,6 +42,7 @@ var ATTACHMENT_NAMES = {
36
42
  pageInventory: "piwi-page-inventory",
37
43
  locatorPages: "piwi-locator-pages",
38
44
  codeReach: "piwi-code-reach",
45
+ serverCoverageRequests: "piwi-server-coverage-requests",
39
46
  webVitals: "piwi-web-vitals",
40
47
  locatorSuggestion: "piwi-locator-suggestion",
41
48
  pageState: "piwi-page-state",
@@ -50,6 +57,7 @@ var USER_PICK_ANNOTATION = ATTACHMENT_NAMES.userPick;
50
57
  // Annotate the CommonJS export names for ESM import in node:
51
58
  0 && (module.exports = {
52
59
  ATTACHMENT_NAMES,
60
+ FAILURE_SCREENSHOT_ATTACHMENT,
53
61
  INTERNAL_ATTACHMENT_NAMES,
54
62
  LOCATOR_SUGGESTION_ANNOTATION,
55
63
  USER_PICK_ANNOTATION
@@ -1,5 +1,6 @@
1
1
  import { ProbeArg } from '@piwitests/picker-dom';
2
2
  export { ProbeArg, ProbedAttrs, probeElementAttrs } from '@piwitests/picker-dom';
3
+ import { PageInteraction } from '@piwitests/core/page-interaction';
3
4
  import { Page, TestInfo, TestType, Fixtures, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, Locator } from '@playwright/test';
4
5
  import { LocatorPageUse, ProcessRole, RoleCost } from '@piwitests/core/wire';
5
6
  import { JsCoverageEntry } from '@piwitests/core/code-reach';
@@ -34,6 +35,13 @@ declare class LocatorPageLog {
34
35
  * layout leaves Playwright's defaults untouched.
35
36
  */
36
37
  declare function boxCaptureFrames(extraPrefixes?: readonly string[]): void;
38
+ /**
39
+ * Call a Playwright method on its own receiver. Playwright names an API call
40
+ * after the method frame the call enters, so the call keeps its real name
41
+ * (`locator.fill: Timeout …`); a call through `Function.prototype.apply` is
42
+ * named `apply`.
43
+ */
44
+ declare function callMethod(target: object, prop: string | symbol, args: unknown[]): unknown;
37
45
  /**
38
46
  * Run a page read as an internal Playwright call: every API call made inside
39
47
  * `run` is kept out of the test's steps and the trace. `owner` is the page (or
@@ -51,6 +59,15 @@ interface CodeReachRoots {
51
59
  }
52
60
  /** Fetches a source map's text; null when it cannot. */
53
61
  type MapFetcher = (url: string) => Promise<string | null>;
62
+ /**
63
+ * One covered script: its function coverage (one range per function), V8's
64
+ * content hash, and its source, which is left out when the worker has already
65
+ * resolved that version of the script.
66
+ */
67
+ interface CoveredScript extends JsCoverageEntry {
68
+ /** V8's content hash of the script; without it, the version is a hash of `source`. */
69
+ hash?: string;
70
+ }
54
71
  /**
55
72
  * The roots for a test: `codeReachRoots` when set, else the Playwright config's
56
73
  * directory; the repository root always comes last, since bundlers name
@@ -58,13 +75,19 @@ type MapFetcher = (url: string) => Promise<string | null>;
58
75
  */
59
76
  declare function codeReachRoots(configDir: string, configured: string[] | null | undefined): CodeReachRoots;
60
77
  /** The repository-relative files the covered scripts reached, sorted and capped. */
61
- declare function resolveCodeReach(entries: JsCoverageEntry[], roots: CodeReachRoots, fetchMap: MapFetcher): Promise<string[]>;
78
+ declare function resolveCodeReach(entries: CoveredScript[], roots: CodeReachRoots, fetchMap: MapFetcher): Promise<string[]>;
62
79
  /** A map fetcher through the page's request context, bounded in size and time. */
63
80
  declare function pageMapFetcher(page: Page): MapFetcher;
64
- /** Start JavaScript coverage on a page; false when the browser has none or it fails. */
81
+ /**
82
+ * Start function coverage on a page, with the debugger on to learn each
83
+ * script's version; false when the browser has none or it fails.
84
+ */
65
85
  declare function startCodeReach(page: Page): Promise<boolean>;
66
- /** Stop JavaScript coverage and return its entries; null when it cannot be read. */
67
- declare function stopCodeReach(page: Page): Promise<JsCoverageEntry[] | null>;
86
+ /**
87
+ * Stop the page's coverage and return the scripts parsed since it started,
88
+ * each with its functions and version; null when it cannot be read.
89
+ */
90
+ declare function stopCodeReach(page: Page): Promise<CoveredScript[] | null>;
68
91
 
69
92
  interface ProcStat {
70
93
  pid: number;
@@ -424,6 +447,18 @@ declare function noteResourceUse(page: object): void;
424
447
  */
425
448
  declare function recordResourceCensus(testInfo: TestInfo): Promise<void>;
426
449
 
450
+ /**
451
+ * Reads, in the page, what it is doing beyond its DOM: the element holding keyboard focus (and the caret or
452
+ * selected range of a text field), the element under the mouse, a text selection outside fields, and the
453
+ * checkboxes in the indeterminate state. Elements are named by element path and text by offset, the format
454
+ * `@piwitests/core/page-interaction` describes and the dashboard resolves in the failure-time DOM. Never reads
455
+ * a field's value or the selected text.
456
+ *
457
+ * Runs in the browser through `page.evaluate`, so it is self-contained: no reference to this module's scope,
458
+ * and `any` for the DOM this package has no types for.
459
+ */
460
+ declare function readPageInteraction(): PageInteraction;
461
+
427
462
  type FixtureArgs = {
428
463
  [key: string]: any;
429
464
  };
@@ -449,7 +484,7 @@ declare function computeCoreVitals(lcpEntries: RawVitalEntry[] | null, shiftEntr
449
484
  /** The code reach roots from `PIWI_CODE_REACH_ROOTS` (a JSON array or a path list). */
450
485
  declare function configuredCodeReachRoots(): string[] | null;
451
486
  /** Page state captured at test end. Storage values and cookie values are NEVER included. */
452
- interface PageState {
487
+ interface PageState extends PageInteraction {
453
488
  url: string;
454
489
  hash: string | null;
455
490
  /** `history.state` as JSON, capped and token-masked. */
@@ -489,11 +524,12 @@ interface RawPageState {
489
524
  }>;
490
525
  }
491
526
  /**
492
- * Assemble the wire page-state from the in-page reads and the context cookies.
493
- * Pure and Node-side so the sanitization (token masking, caps, value-free
494
- * cookies) is unit-testable.
527
+ * Assemble the wire page-state from the in-page reads, the context cookies and
528
+ * what the page was doing (`readPageInteraction`). Pure and Node-side so the
529
+ * sanitization (token masking, caps, value-free cookies, well-formed element
530
+ * paths) is unit-testable.
495
531
  */
496
- declare function buildPageState(raw: RawPageState, cookies: Array<Record<string, unknown>> | null): PageState;
532
+ declare function buildPageState(raw: RawPageState, cookies: Array<Record<string, unknown>> | null, interaction?: unknown): PageState;
497
533
  /**
498
534
  * Everything the in-page probe needs, serialized into the browser on every
499
535
  * action. `tagRoles`/`inputRoles` are the shared role maps (single source of
@@ -524,13 +560,6 @@ declare function ariaSnapshotBestEffort(target: Locator, timeout?: number): Prom
524
560
  * yields null and the capture proceeds with the YAML alone.
525
561
  */
526
562
  declare function ariaSnapshotJSONBestEffort(target: Locator, timeout?: number): Promise<string | null>;
527
- /**
528
- * Call a Playwright method on its own receiver. Playwright names an API call
529
- * after the method frame the call enters, so the call keeps its real name
530
- * (`locator.fill: Timeout …`); a call through `Function.prototype.apply` is
531
- * named `apply`.
532
- */
533
- declare function callMethod(target: object, prop: string | symbol, args: unknown[]): unknown;
534
563
  /**
535
564
  * The fixtures `piwiFixtures` / `extendPiwiFixtures` contribute. The single
536
565
  * added fixture is `piwiCapture`: an auto, test-scoped teardown hook that
@@ -546,9 +575,11 @@ interface PiwiFixtures {
546
575
  * The worker fixture `piwiFixtures` / `extendPiwiFixtures` contribute:
547
576
  * `piwiResources`, an auto, worker-scoped fixture that keeps the worker's
548
577
  * resource ledger (the browsers, contexts, pages and API request contexts its
549
- * tests open) from before the first hook to the worker's shutdown. Its name is
550
- * **reserved** like `piwiCapture`'s: a fixture of your own with that name
551
- * replaces it and turns the ledger off.
578
+ * tests open) from before the first hook to the worker's shutdown, and records
579
+ * the calls tests make through the API request contexts `playwright.request`
580
+ * creates, the `request` fixture's among them. Its name is **reserved** like
581
+ * `piwiCapture`'s: a fixture of your own with that name replaces it and turns
582
+ * the ledger and those calls' capture off.
552
583
  */
553
584
  interface PiwiWorkerFixtures {
554
585
  piwiResources: void;
@@ -559,8 +590,11 @@ interface PiwiWorkerFixtures {
559
590
  *
560
591
  * Capture is wired at the `browser` level, so it works whether a test uses the
561
592
  * standard `page` fixture or builds its own pages from `browser` /
562
- * `browser.newContext()`. Collected data is attached as `piwi-*`
563
- * test-info attachments which the Piwi Dashboard reporter parses on `onTestEnd`.
593
+ * `browser.newContext()`. The calls a test makes through an API request
594
+ * context (the `request` fixture, `playwright.request.newContext()`,
595
+ * `page.request`) are recorded with its network requests. Collected data is
596
+ * attached as `piwi-*` test-info attachments which the Piwi Dashboard reporter
597
+ * parses on `onTestEnd`.
564
598
  */
565
599
  declare const piwiFixtures: Fixtures<PiwiFixtures, PiwiWorkerFixtures, PlaywrightTestArgs & PlaywrightTestOptions, PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
566
600
  /**
@@ -581,4 +615,4 @@ declare const piwiFixtures: Fixtures<PiwiFixtures, PiwiWorkerFixtures, Playwrigh
581
615
  */
582
616
  declare function extendPiwiFixtures<TestArgs extends FixtureArgs, WorkerArgs extends FixtureArgs>(test: TestType<TestArgs, WorkerArgs>): TestType<TestArgs & PiwiFixtures, WorkerArgs & PiwiWorkerFixtures>;
583
617
 
584
- export { CAPTURED_ATTRS_ARG, LocatorPageLog, type PageState, type PiwiFixtures, type PiwiWorkerFixtures, type RawPageState, type RawVitalEntry, activeResourceLedger, ariaSnapshotBestEffort, ariaSnapshotJSONBestEffort, boxCaptureFrames, buildPageState, callMethod, codeReachRoots, computeCoreVitals, configuredCodeReachRoots, extendPiwiFixtures, internalCall, noteLocatorCall, noteNavigation, noteResourceUse, pageMapFetcher, piwiFixtures, recordResourceCensus, resolveCodeReach, startCodeReach, startResourceLedger, stopCodeReach, stopResourceLedger };
618
+ export { CAPTURED_ATTRS_ARG, LocatorPageLog, type PageState, type PiwiFixtures, type PiwiWorkerFixtures, type RawPageState, type RawVitalEntry, activeResourceLedger, ariaSnapshotBestEffort, ariaSnapshotJSONBestEffort, boxCaptureFrames, buildPageState, callMethod, codeReachRoots, computeCoreVitals, configuredCodeReachRoots, extendPiwiFixtures, internalCall, noteLocatorCall, noteNavigation, noteResourceUse, pageMapFetcher, piwiFixtures, readPageInteraction, recordResourceCensus, resolveCodeReach, startCodeReach, startResourceLedger, stopCodeReach, stopResourceLedger };