@piwitests/reporter 0.66.0 → 0.68.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.
@@ -31,6 +31,7 @@ declare const ATTACHMENT_NAMES: {
31
31
  readonly aiMeta: "piwi-ai-meta";
32
32
  readonly resources: "piwi-resources";
33
33
  readonly pauses: "piwi-pauses";
34
+ readonly environment: "piwi-environment";
34
35
  };
35
36
  /** Set of every internal attachment name — used to skip them when collecting user attachments. */
36
37
  declare const INTERNAL_ATTACHMENT_NAMES: ReadonlySet<string>;
@@ -58,7 +58,8 @@ var ATTACHMENT_NAMES = {
58
58
  aiUsage: "piwi-ai-usage",
59
59
  aiMeta: "piwi-ai-meta",
60
60
  resources: "piwi-resources",
61
- pauses: "piwi-pauses"
61
+ pauses: "piwi-pauses",
62
+ environment: "piwi-environment"
62
63
  };
63
64
  var INTERNAL_ATTACHMENT_NAMES = new Set(Object.values(ATTACHMENT_NAMES));
64
65
  var ARIA_SNAPSHOT_CONTENT_TYPE = "text/plain; charset=utf-8";
@@ -93,7 +93,9 @@ declare class LocatorPageLog {
93
93
  * element** and a region's ARIA snapshot, started from outside the page; at any stop, the responses the test kept (an
94
94
  * interactive run keeps the text bodies of its pages' fetch and XHR answers), one of them to mock, and a locator's
95
95
  * matches; and, for a viewer outside the page, the stopped page's live view (`@piwitests/core/run-view`: its frames,
96
- * the input played on it) and the locator of the element under a point of an image of it; and, for an agent (the
96
+ * the input played on it) and the locator of the element under a point of an image of it; for a viewer of the
97
+ * worker's lane, its running test's page live, through its tests and stops (`view-lane`, a feature beyond `takes`);
98
+ * and, for an agent (the
97
99
  * editor's MCP server), the stopped page's ARIA snapshot in AI mode, an action on one of its elements by its ref, that
98
100
  * element's ranked locators, what the run does as it goes (`events`), and its browser bound for Playwright's own tools
99
101
  * on request (`bind`). A worker holds a failure for the editor only once the service said it shows and answers one
@@ -135,6 +137,14 @@ declare class BarIntents {
135
137
  answered(): void;
136
138
  }
137
139
 
140
+ /** A call of the test, as the run page names it: its title and its place in the user's code, when known. */
141
+ interface LiveCall {
142
+ title: string;
143
+ /** The file, relative to the run's working directory, with forward slashes. */
144
+ file: string | null;
145
+ line: number | null;
146
+ }
147
+
138
148
  /**
139
149
  * Register this package's `dist/` directory as a boxed stack prefix — the list
140
150
  * Playwright filters its own frames with — so a wrapped action's step location
@@ -175,8 +185,8 @@ declare function internalCall<T>(owner: unknown, run: () => Promise<T>): Promise
175
185
  * At line granularity, V8's block coverage tells which code ran inside a
176
186
  * function: at each offset, the innermost range around it (a function or a
177
187
  * block) gives its count. A source line is executable when a source map
178
- * segment maps to it, and it ran when one of those segments starts at an
179
- * offset that ran. A script with no map counts the lines holding code inside
188
+ * segment holding code maps to it, and it ran when one of those segments ran
189
+ * at its first character of code ({@link scriptLines}). A script with no map counts the lines holding code inside
180
190
  * the functions V8 lists, its top level left out, and one of them ran when
181
191
  * code on it ran.
182
192
  *
@@ -423,6 +433,19 @@ interface ResourceTestRef {
423
433
  /** Set on the test a census closes when it failed: Playwright shuts its worker down right after it. */
424
434
  failed?: boolean;
425
435
  }
436
+ /** The last call a test made on an object, or on anything under it (a page's frames and elements, a context's pages). */
437
+ interface ResourceUse {
438
+ at: number;
439
+ /** The line that made it, `file:line`. */
440
+ site: string | null;
441
+ /** The test that made it. */
442
+ test?: string;
443
+ }
444
+ /** The fixture being set up or torn down: its title, and its location for a fixture of the suite's own. */
445
+ interface ResourceFixture {
446
+ title: string;
447
+ location: string | null;
448
+ }
426
449
  interface ResourceBirth {
427
450
  id: number;
428
451
  kind: ResourceKind;
@@ -430,12 +453,16 @@ interface ResourceBirth {
430
453
  parent: number | null;
431
454
  at: number;
432
455
  phase: ResourcePhase;
433
- /** The fixture being set up when the object was opened; `worker` when that fixture is worker-scoped. */
434
- fixture: {
435
- title: string;
436
- location: string | null;
456
+ /**
457
+ * The fixture being set up when the object was opened. `worker` when it ran
458
+ * with a timeout slot, which Playwright gives a worker-scoped fixture and any
459
+ * fixture with a `timeout` of its own; `timed` for the second case, whose
460
+ * scope the slot does not tell.
461
+ */
462
+ fixture: (ResourceFixture & {
437
463
  worker: boolean;
438
- } | null;
464
+ timed?: boolean;
465
+ }) | null;
439
466
  /** The test it was opened during; for a `beforeAll`, the test that ran the hook. */
440
467
  test: ResourceTestRef | null;
441
468
  /** The line that opened it, `file:line`. */
@@ -444,7 +471,7 @@ interface ResourceBirth {
444
471
  opener?: number;
445
472
  /** A popup: the call that was running or last ran when it appeared. */
446
473
  trigger?: string;
447
- /** A context `browser.newPage()` opened for its page. */
474
+ /** A context `browser.newPage()` opened for its page, or the browser `launchPersistentContext` opened for its context. */
448
475
  implicit?: boolean;
449
476
  /** A context Playwright reuses across tests on purpose (UI mode, `--reuse-context`). */
450
477
  reused?: boolean;
@@ -454,8 +481,18 @@ interface ResourceClose {
454
481
  at: number;
455
482
  phase: ResourcePhase;
456
483
  test: ResourceTestRef | null;
484
+ /** The fixture tearing down when it closed. */
485
+ fixture?: ResourceFixture;
457
486
  /** Pages: whether anything ever ran on it. */
458
487
  used?: boolean;
488
+ /** The last call a test made on it before it closed. */
489
+ lastUse?: ResourceUse;
490
+ /**
491
+ * When its close began, or its context's or browser's: before the work a
492
+ * close does first (Piwi's reads of its pages, Playwright saving its trace).
493
+ * Set when it began before `at`.
494
+ */
495
+ closingAt?: number;
459
496
  /** Closed by `PIWI_LEAK_CHECK=close`. */
460
497
  byPiwi?: boolean;
461
498
  }
@@ -465,7 +502,9 @@ interface ResourceOpen {
465
502
  used?: boolean;
466
503
  /** Pages: the current URL, without query or hash. */
467
504
  url?: string;
468
- /** Pages: listeners on Playwright's page events. */
505
+ /** The last call a test made on it so far. */
506
+ lastUse?: ResourceUse;
507
+ /** Listeners on Playwright's events of the page, the context or the browser. */
469
508
  listeners?: number;
470
509
  /** Pages and contexts: `route()` handlers. */
471
510
  routes?: number;
@@ -483,6 +522,8 @@ interface ResourceCensus {
483
522
  at: number;
484
523
  /** The test this census closes; null for the census a worker takes as it shuts down. */
485
524
  test: ResourceTestRef | null;
525
+ /** When the test this census closes started, before its test-scoped fixtures were set up. */
526
+ startedAt?: number;
486
527
  born: ResourceBirth[];
487
528
  closed: ResourceClose[];
488
529
  open: ResourceOpen[];
@@ -528,14 +569,21 @@ interface LeakedResource {
528
569
  implicit: boolean;
529
570
  /** A popup: the call that opened it. */
530
571
  trigger?: string;
572
+ /** The line of the last call the test made on it, where its close belongs. */
573
+ lastUse?: string | null;
531
574
  }
532
575
  interface Instrumentation {
533
576
  addListener?: (listener: object) => void;
534
577
  removeListener?: (listener: object) => void;
535
578
  }
579
+ /** A connection to Playwright (internal): every call of the objects it carries goes through it. */
580
+ interface ConnectionLike {
581
+ sendMessageToServer?: (object: unknown, method: unknown, params: unknown, options: unknown) => unknown;
582
+ }
536
583
  type BrowserTypeLike = Record<string, unknown>;
537
584
  interface PlaywrightLike {
538
585
  _instrumentation?: Instrumentation;
586
+ _connection?: ConnectionLike;
539
587
  chromium?: BrowserTypeLike;
540
588
  firefox?: BrowserTypeLike;
541
589
  webkit?: BrowserTypeLike;
@@ -548,6 +596,9 @@ interface TestInfoLike {
548
596
  titlePath?: string[];
549
597
  status?: string;
550
598
  expectedStatus?: string;
599
+ project?: {
600
+ timeout?: number;
601
+ };
551
602
  _timeoutManager?: {
552
603
  _running?: {
553
604
  runnable?: {
@@ -558,7 +609,9 @@ interface TestInfoLike {
558
609
  file?: string;
559
610
  line?: number;
560
611
  };
561
- slot?: unknown;
612
+ slot?: {
613
+ timeout?: number;
614
+ } | null;
562
615
  };
563
616
  };
564
617
  } | null;
@@ -581,6 +634,14 @@ declare class ResourceLedger {
581
634
  private lastCall;
582
635
  /** The page a wrapped page method is calling into: its first reported API call marks it used. */
583
636
  private usingPage;
637
+ /**
638
+ * The connections the ledger follows, each with what puts it back: every call a test makes through one marks what
639
+ * it lands on used.
640
+ */
641
+ private readonly followed;
642
+ /** The client-side waits a test began, by their id, with the object each waits on and the line that began it. */
643
+ private readonly waits;
644
+ private windowStartedAt;
584
645
  private born;
585
646
  private closed;
586
647
  private handlesAtStart;
@@ -603,6 +664,39 @@ declare class ResourceLedger {
603
664
  nodeHandles?: boolean);
604
665
  /** Listen to the worker's Playwright and wrap its browser types. False when the instrumentation is missing. */
605
666
  install(): boolean;
667
+ /**
668
+ * Follow every call made through a connection to Playwright
669
+ * (`sendMessageToServer`, internal): the worker's own, and that of each
670
+ * browser it connects to. A call a test made (with its frames, not
671
+ * `internal` like Piwi's own reads and Playwright's artifacts) marks the
672
+ * object it lands on used, and the page, context and browser it belongs to
673
+ * (its `_parent` chain), with when and from which line. A long call (an
674
+ * assertion, a wait on the browser) keeps it in use until it returns, and a
675
+ * wait on the client (`waitForEvent` and its kin) until its internal end. A
676
+ * close marks when the object's close began; a `route()` handler's answers to
677
+ * the page's own traffic are no use. The pages of a connection it does not
678
+ * follow keep being marked used by their page methods and locators.
679
+ */
680
+ private followCalls;
681
+ /** Stop following a connection, and let it go: a browser the worker connected to and has left. */
682
+ private unfollow;
683
+ /** Whether the ledger follows the calls of an object's connection. */
684
+ private follows;
685
+ private onCall;
686
+ /**
687
+ * A wait on the client begins with a call of the test's (with its frames)
688
+ * and ends with an internal one of the same id: the object it waited on was
689
+ * in use until then.
690
+ */
691
+ private onWait;
692
+ /**
693
+ * Mark an object, and the page, context and browser it belongs to, used now
694
+ * by the call at `site`. A close that began before it did not end: the
695
+ * object is in use again.
696
+ */
697
+ private touch;
698
+ /** Mark when an object's close began, the first time it begins. */
699
+ noteClosing(object: object): void;
606
700
  /** Stop listening, and put Node's `listen` and `spawn` back; the objects already tracked stay in the ledger. */
607
701
  uninstall(): void;
608
702
  /**
@@ -650,6 +744,8 @@ declare class ResourceLedger {
650
744
  /** `initial` is set for a page that came with its context (a persistent context's), which is no popup. */
651
745
  private onPage;
652
746
  private onClosed;
747
+ /** When the close of an object, or of the context or browser it belongs to, began first; null when none did. */
748
+ private closingOf;
653
749
  private latestPendingCall;
654
750
  private openEntries;
655
751
  /**
@@ -660,6 +756,7 @@ declare class ResourceLedger {
660
756
  private leaksOf;
661
757
  /** Open pages under a context, or under any context of a browser. */
662
758
  private pagesUnder;
759
+ /** A context `browser.newPage()` opened for its page, or a browser `launchPersistentContext` opened for its context. */
663
760
  private isImplicit;
664
761
  private openPagesOf;
665
762
  private closeLeaks;
@@ -836,6 +933,11 @@ type CodePlace = {
836
933
  * as Windows writes them. Null for an error with no such frame (a test timeout).
837
934
  */
838
935
  declare function errorPlace(error: unknown, windows?: boolean): CodePlace | null;
936
+ /**
937
+ * The call the test is on, as the run page's live view names it beside each frame, its file relative to the working
938
+ * directory. Null for none.
939
+ */
940
+ declare function runningCall(testInfo: TestInfo): LiveCall | null;
839
941
  /**
840
942
  * The fixtures `piwiFixtures` / `extendPiwiFixtures` contribute. The single
841
943
  * added fixture is `piwiCapture`: an auto, test-scoped teardown hook that
@@ -892,4 +994,4 @@ declare const piwiFixtures: Fixtures<PiwiFixtures, PiwiWorkerFixtures, Playwrigh
892
994
  */
893
995
  declare function extendPiwiFixtures<TestArgs extends FixtureArgs, WorkerArgs extends FixtureArgs>(test: TestType<TestArgs, WorkerArgs>): TestType<TestArgs & PiwiFixtures, WorkerArgs & PiwiWorkerFixtures>;
894
996
 
895
- export { CAPTURED_ATTRS_ARG, type IntentStop, LocatorPageLog, type PageState, type PiwiFixtures, type PiwiWorkerFixtures, ProbeArg, ProbedAttrs, type RawPageState, type RawVitalEntry, activeResourceLedger, ariaSnapshotBestEffort, ariaSnapshotJSONBestEffort, boxCaptureFrames, buildPageState, callMethod, codeReachRoots, computeCoreVitals, configuredCodeReachRoots, errorPlace, extendPiwiFixtures, failureError, intentAt, internalCall, noteLocatorCall, noteNavigation, noteResourceUse, pageMapFetcher, piwiFixtures, probeElementAttrs, readPageInteraction, recordResourceCensus, resolveCodeReach, startCodeReach, startResourceLedger, stopCodeReach, stopResourceLedger };
997
+ export { CAPTURED_ATTRS_ARG, type IntentStop, LocatorPageLog, type PageState, type PiwiFixtures, type PiwiWorkerFixtures, ProbeArg, ProbedAttrs, type RawPageState, type RawVitalEntry, activeResourceLedger, ariaSnapshotBestEffort, ariaSnapshotJSONBestEffort, boxCaptureFrames, buildPageState, callMethod, codeReachRoots, computeCoreVitals, configuredCodeReachRoots, errorPlace, extendPiwiFixtures, failureError, intentAt, internalCall, noteLocatorCall, noteNavigation, noteResourceUse, pageMapFetcher, piwiFixtures, probeElementAttrs, readPageInteraction, recordResourceCensus, resolveCodeReach, runningCall, startCodeReach, startResourceLedger, stopCodeReach, stopResourceLedger };