@unotest/web 0.45.0 → 0.46.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,6 +1,6 @@
1
1
  import { InjectedDomHelpers } from '@unotest/grounder-client/dom-walker';
2
2
  import { PickerMode } from '@unotest/protocol';
3
- import { E as ElementHint } from '../interfaces-OvnJKELk.js';
3
+ import { E as ElementHint } from '../interfaces-CYoL4Taq.js';
4
4
  import '../config/schema.js';
5
5
  import 'zod';
6
6
 
@@ -88,6 +88,10 @@ interface LaunchOptions {
88
88
  * persistent context, which every `newContext()` then returns
89
89
  * (`config.launch.userDataDir`). */
90
90
  userDataDir?: string;
91
+ /** A new browser on a new profile directory for every context
92
+ * (`config.launch.profile`); each `newContext()` then needs
93
+ * `ContextOptions.profileDir`. */
94
+ profile?: "per-test";
91
95
  /** Extra browser command-line arguments (`config.launch.args`). */
92
96
  args?: string[];
93
97
  }
@@ -139,6 +143,10 @@ interface ContextOptions {
139
143
  * `UNOTEST_DEFAULT_NAVIGATION_TIMEOUT_MS` env overrides.
140
144
  */
141
145
  defaultNavigationTimeoutMs?: number;
146
+ /** The directory a `profile: "per-test"` browser starts on. The caller
147
+ * makes it and decides whether it stays; given to any other launch it
148
+ * is refused. */
149
+ profileDir?: string;
142
150
  }
143
151
  interface ActionTimeout {
144
152
  /** Override default action timeout (D-7 actionability wait). Milliseconds. */
@@ -324,6 +332,11 @@ interface WebDriver {
324
332
  wsEndpoint(): string | undefined;
325
333
  connectShared(wsEndpoint: string, browser: LaunchOptions["browser"]): Promise<void>;
326
334
  attachExisting(opts?: AttachOptions): Promise<DriverContext>;
335
+ /** True while the browser `connectShared` joined is still there. A run
336
+ * on `launch.profile: "per-test"` closes it with each test and starts
337
+ * the next one at the same endpoint, so a joined client asks this
338
+ * before it follows the run. False when nothing is joined. */
339
+ sharedBrowserConnected(): boolean;
327
340
  }
328
341
  /** One captured network request/response, recorded only under
329
342
  * `UNOTEST_NETWORK`. `status`/`ok` come from the response; `failureText`
@@ -545,10 +558,16 @@ interface DriverContext {
545
558
  * runner can pull the tail when a test fails.
546
559
  */
547
560
  consoleEntries(): ReadonlyArray<{
548
- level: "log" | "info" | "warn" | "error" | "debug";
561
+ level: ConsoleLevel;
549
562
  text: string;
550
563
  timestamp: string;
551
564
  }>;
565
+ /** The console lines and uncaught errors of the ACTIVE page, oldest
566
+ * first. Recorded always, from the moment the page opened — unlike
567
+ * `consoleEntries()`, which only `UNOTEST_CONSOLE` fills — so a
568
+ * scenario that clicks and then asks finds what the click logged.
569
+ * Extension pages (`chrome-extension://`) are pages like any other. */
570
+ pageConsole(): PageConsole;
552
571
  /**
553
572
  * Snapshot of network request/response entries captured since context
554
573
  * creation, oldest first. Populated only when `UNOTEST_NETWORK` is on (else
@@ -787,5 +806,26 @@ interface AncestorHint {
787
806
  /** A single stable, semantic class token (not a hash / utility class). */
788
807
  className?: string;
789
808
  }
809
+ type ConsoleLevel = "log" | "info" | "warn" | "error" | "debug";
810
+ /** One console line of a page: `url` is the page's at the time, `at`
811
+ * epoch ms — the scale `nowMs()` gives a scenario. */
812
+ interface PageConsoleEntry {
813
+ level: ConsoleLevel;
814
+ text: string;
815
+ url: string;
816
+ at: number;
817
+ }
818
+ /** An error the page threw and nothing caught (`pageerror`). `stack` is
819
+ * empty when the browser gave none. */
820
+ interface PageErrorEntry {
821
+ message: string;
822
+ stack: string;
823
+ url: string;
824
+ at: number;
825
+ }
826
+ interface PageConsole {
827
+ entries: readonly PageConsoleEntry[];
828
+ errors: readonly PageErrorEntry[];
829
+ }
790
830
 
791
- export { type AttachOptions as A, type BoundingBox as B, type CaptureFrame as C, type DriverContext as D, type ElementHint as E, type FillOptions as F, type GotoOptions as G, type HoverOptions as H, type LocatorValue as L, type NetworkEntry as N, type PressOptions as P, type ReloadOptions as R, type ScreenshotOptions as S, type Viewport as V, type WebDriver as W, type CaptureRect as a, type LaunchOptions as b, type ContextOptions as c, type ActionTimeout as d, type CheckOptions as e, type ClickOptions as f, type CookieOptions as g, type DriverPage as h, type NavigationOptions as i, type SelectOptions as j, type ViewportSize as k, type WaitOptions as l, type WaitState as m, type DriverDownload as n, type LocatorStep as o, appendStep as p, describeLocator as q, isLocatorValue as r, rootedAt as s };
831
+ export { type AttachOptions as A, type BoundingBox as B, type CaptureFrame as C, type DriverContext as D, type ElementHint as E, type FillOptions as F, type GotoOptions as G, type HoverOptions as H, type LocatorValue as L, type NetworkEntry as N, type PageConsole as P, type ReloadOptions as R, type ScreenshotOptions as S, type Viewport as V, type WebDriver as W, type CaptureRect as a, type LaunchOptions as b, type ContextOptions as c, type ActionTimeout as d, type CheckOptions as e, type ClickOptions as f, type CookieOptions as g, type DriverPage as h, type NavigationOptions as i, type PressOptions as j, type SelectOptions as k, type ViewportSize as l, type WaitOptions as m, type WaitState as n, type DriverDownload as o, type LocatorStep as p, appendStep as q, describeLocator as r, isLocatorValue as s, rootedAt as t };