@unotest/web 0.45.0 → 0.47.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.
@@ -92,7 +92,7 @@ interface Locator {
92
92
  }
93
93
 
94
94
  /**
95
- * click(locator, { force?, timeout?, noWaitAfter? })
95
+ * click(locator, { force?, timeout?, position?, modifiers?, button?, clickCount? })
96
96
  *
97
97
  * Click an element.
98
98
  */
@@ -134,7 +134,7 @@ declare function hover(locator: Locator, options?: any): void;
134
134
  declare function scrollIntoView(locator: Locator, options?: any): void;
135
135
 
136
136
  /**
137
- * fill(locator, value, { timeout?, noWaitAfter? })
137
+ * fill(locator, value, { force?, timeout? })
138
138
  *
139
139
  * Clear and type a value into an input.
140
140
  */
@@ -176,11 +176,25 @@ declare function uploadFile(input: Locator, files: any): void;
176
176
  declare function clipboardPaste(target: Locator, text: string): void;
177
177
 
178
178
  /**
179
- * assertText(locator, expected, { exact?, timeout? })
179
+ * assertText(locator, expected, { exact?, not?, timeout? })
180
180
  *
181
- * Element's text equals/contains `expected`.
181
+ * Element's text equals `expected` (a string; exact: false — contains it) or matches it (a /regex/). {not: true} waits until it no longer does. Empty: assertText(loc, ''); not empty: assertText(loc, '', {not: true}).
182
182
  */
183
- declare function assertText(locator: Locator, text: string, options?: any): void;
183
+ declare function assertText(locator: Locator, text: string | RegExp, options?: any): void;
184
+
185
+ /**
186
+ * assertTexts(locator, expected, { exact?, timeout? })
187
+ *
188
+ * The locator matches exactly expected.length elements, and element i's text matches expected[i] (string or /regex/, same rules as assertText), in order.
189
+ */
190
+ declare function assertTexts(locator: Locator, texts: unknown[], options?: any): void;
191
+
192
+ /**
193
+ * assertAttribute(locator, name, expected, { exact?, not?, timeout? })
194
+ *
195
+ * Polls the attribute `name` until it equals `expected` (exact: false — contains) or matches a /regex/. An absent attribute matches nothing. {not: true} waits until it no longer matches or is gone.
196
+ */
197
+ declare function assertAttribute(locator: Locator, name: string, value: string | RegExp, options?: any): void;
184
198
 
185
199
  /**
186
200
  * assertVisible(locator, { timeout? })
@@ -220,9 +234,9 @@ declare function assertCount(locator: Locator, count: number): void;
220
234
  /**
221
235
  * assertUrl(pattern, { timeout? })
222
236
  *
223
- * Current URL contains `pattern`.
237
+ * Current URL contains `pattern` (a string) or matches it (a /regex/, unanchored). A failure names the pattern as /source/flags.
224
238
  */
225
- declare function assertUrl(pattern: string): void;
239
+ declare function assertUrl(pattern: string | RegExp, options?: any): void;
226
240
 
227
241
  /**
228
242
  * assertJudge(locator, rubric)
@@ -252,6 +266,27 @@ declare function assertEqual(actual: any, expected: any): void;
252
266
  */
253
267
  declare function assertTrue(condition: boolean, message?: string): void;
254
268
 
269
+ /**
270
+ * assertSchema(value, schema)
271
+ *
272
+ * Check a value against a JSON Schema (draft 2020-12), e.g. one your app generates from its zod schemas: assertSchema(res.body, readJson('unotest/fixtures/message.schema.json')). FAILS naming every broken field by path (`/items/0/id`) with what is wrong. External $ref is refused; `format` is not checked.
273
+ */
274
+ declare function assertSchema(value: any, schema: any): void;
275
+
276
+ /**
277
+ * skip(reason, condition?)
278
+ *
279
+ * End the test as skipped when the condition is true (always, without one) — it does not apply here: skip('no live API configured', env('LIVE_API') == null). The run reports skipped with the reason, not passed and not failed; teardown blocks already registered still play. A test guard: at the level of the test_* body, next to its steps, not inside one.
280
+ */
281
+ declare function skip(reason: string, condition?: boolean): void;
282
+
283
+ /**
284
+ * setTestTimeout(ms)
285
+ *
286
+ * This test's own time budget, counted from its start (Playwright's test.setTimeout). Replaces config testTimeoutMs and UNOTEST_MAX_DURATION_MS for this test. A deadline: an action still running when it runs out is cut, the test fails naming the budget, teardown blocks still play. Only in a test_* body.
287
+ */
288
+ declare function setTestTimeout(ms: number): void;
289
+
255
290
  /**
256
291
  * filter(locator, { hasText?, hasNotText?, has?, hasNot? })
257
292
  *
@@ -301,6 +336,27 @@ declare function screenshot(name?: string, options?: any): string;
301
336
  */
302
337
  declare function note(label: string, value: any): void;
303
338
 
339
+ /**
340
+ * consoleEntries({ level?, since? }) → [{ level, text, url }]
341
+ *
342
+ * What the active page wrote to its console, oldest first: `level` is log, info, warn, error or debug. Recorded from the moment the page opened, so act first, then ask. Extension pages (chrome-extension://) too. options: {level} (one level or a list), {since} (epoch ms, from nowMs()).
343
+ */
344
+ declare function consoleEntries(options?: any): any;
345
+
346
+ /**
347
+ * pageErrors({ since? }) → [{ message, stack }]
348
+ *
349
+ * Errors the active page threw and nothing caught (an uncaught exception, a rejected promise), oldest first; `stack` is empty when the browser gave none. options: {since} (epoch ms, from nowMs()).
350
+ */
351
+ declare function pageErrors(options?: any): any;
352
+
353
+ /**
354
+ * assertNoConsoleErrors({ includePageErrors?, since? })
355
+ *
356
+ * FAIL when the active page logged console errors, or threw uncaught ones (unless {includePageErrors: false}), quoting the first three. With `since` (epoch ms, from nowMs()) only from then on.
357
+ */
358
+ declare function assertNoConsoleErrors(options?: any): void;
359
+
304
360
  /**
305
361
  * evaluate(js, arg?) → any
306
362
  *
@@ -357,6 +413,13 @@ declare function closePage(index?: number): void;
357
413
  */
358
414
  declare function setViewport(size: any): void;
359
415
 
416
+ /**
417
+ * emulateMedia({ reducedMotion?, colorScheme? })
418
+ *
419
+ * Change the media features the current tab reports from now on — what matchMedia and CSS @media see: reducedMotion 'reduce' | 'no-preference', colorScheme 'light' | 'dark' | 'no-preference'. This tab only: a tab or popup opened later starts without it.
420
+ */
421
+ declare function emulateMedia(media: any): void;
422
+
360
423
  /**
361
424
  * newContext() → number
362
425
  *
@@ -416,9 +479,9 @@ declare function goForward(): void;
416
479
  /**
417
480
  * waitForUrl(pattern, { timeout? })
418
481
  *
419
- * Wait until the URL contains `pattern` (substring match).
482
+ * Wait until the URL contains `pattern` (a string, substring match) or matches it (a /regex/, unanchored).
420
483
  */
421
- declare function waitForUrl(pattern: string): void;
484
+ declare function waitForUrl(pattern: string | RegExp, options?: any): void;
422
485
 
423
486
  /**
424
487
  * waitForNavigation({ timeout? })
@@ -476,6 +539,20 @@ declare function isEnabled(locator: Locator): boolean;
476
539
  */
477
540
  declare function hasAttribute(locator: Locator, name: string): boolean;
478
541
 
542
+ /**
543
+ * computedStyle(locator, property) → string
544
+ *
545
+ * The element's computed CSS value, as the browser resolved it: computedStyle(card, "opacity") → "0.5", custom properties too ("--accent"). "" when the property is not set.
546
+ */
547
+ declare function computedStyle(locator: Locator, property: string): string;
548
+
549
+ /**
550
+ * hasAnimation(locator) → bool
551
+ *
552
+ * Whether the element or a descendant has an animation still running towards an end. Infinite (spinners) and paused ones do not count — the same rule waitForAnimations waits by.
553
+ */
554
+ declare function hasAnimation(locator: Locator): boolean;
555
+
479
556
  /**
480
557
  * randomFirstName() → string
481
558
  *
@@ -574,6 +651,34 @@ declare function parseJson(text: string): any;
574
651
  */
575
652
  declare function urlParam(url: string, key: string): any;
576
653
 
654
+ /**
655
+ * toNumber(text, { decimal? }) → number
656
+ *
657
+ * A number as a page writes it: '1 234,5', '1,234.56', '−12'. Spaces (NBSP too) group digits; with both ',' and '.' the last one is the decimal mark; one mark used twice groups. '1,234' and '1.234' read both ways and FAIL unless {decimal: ',' | '.'} says which. Units and currency ('440px', '€12') FAIL, quoting the input — cut the number out with textMatches first. A number passes through.
658
+ */
659
+ declare function toNumber(text: any, options?: any): number;
660
+
661
+ /**
662
+ * round(n, digits?) → number
663
+ *
664
+ * Round to `digits` decimals (0..10, default 0), half away from zero on the decimal as written: round(2.5) → 3, round(-2.5) → -3, round(1.005, 2) → 1.01.
665
+ */
666
+ declare function round(n: number, digits?: number): number;
667
+
668
+ /**
669
+ * formatNumber(n, { locale?, minFractionDigits?, maxFractionDigits? }) → string
670
+ *
671
+ * A number as text, via Intl.NumberFormat with digit grouping. Without a locale it is en-US on every machine: formatNumber(1234.5) → '1,234.5'. Another locale's output (its spaces and marks) comes from the ICU of the Node that runs it.
672
+ */
673
+ declare function formatNumber(n: number, options?: any): string;
674
+
675
+ /**
676
+ * env(name) → string | null
677
+ *
678
+ * An environment value the test can do without: the ambient environment, unotest/.env or .secrets, as a bare UPPER_SNAKE name reads it — but null when unset instead of failing. For deciding on it: if (env('LIVE_API') == null) { … }. A secret is refused; write its bare name where the value is typed.
679
+ */
680
+ declare function env(name: string): any;
681
+
577
682
  /**
578
683
  * shell(cmd, ...args, options?) → { stdout, stderr, code }
579
684
  *
@@ -840,6 +945,13 @@ declare function waitForText(text: string | RegExp, options?: any): void;
840
945
  */
841
946
  declare function waitForCount(locator: Locator, count: number, options?: any): void;
842
947
 
948
+ /**
949
+ * waitForAnimations(locator, { timeout? })
950
+ *
951
+ * Wait until the element and its descendants have no animation still running — a dialog done fading in, a card done sliding. Infinite ones (spinners) and paused ones are not waited for. Default timeout 5000 ms; a timeout names the element and how many were left.
952
+ */
953
+ declare function waitForAnimations(locator: Locator, options?: any): void;
954
+
843
955
  /**
844
956
  * pause(ms)
845
957
  *
@@ -878,7 +990,7 @@ declare function clockRun(): void;
878
990
  /**
879
991
  * mockRoute(glob, response)
880
992
  *
881
- * From now on, requests matching `glob` (a Playwright URL glob: `**\/api/items*`) get a fixed answer: `{status?, body?, headers?, contentType?}` (an object body goes as JSON), `{abort: true, record?}` or `{continue: true}` (to the network). Where several masks match, the one mocked last answers; mocking a mask again replaces its answer. A response to `**\/*` is refused; the site's own page is never aborted. Mocks last until the scenario ends.
993
+ * From now on, requests matching `glob` (a Playwright URL glob: `**\/api/items*`) get a fixed answer: `{status?, body?, headers?, contentType?}` (an object body goes as JSON), `{abort: true, record?}` or `{continue: true}` (to the network). Where several masks match, the one mocked last answers; mocking a mask again replaces its answer. A response to `**\/*` is refused; the site's own page is never aborted. A mask reaches http(s) and ws(s) only, so an extension's own pages and scripts load under `**\/*`; to mock them, start the mask with their scheme (`chrome-extension://<id>/x.js`). Mocks last until the scenario ends.
882
994
  */
883
995
  declare function mockRoute(glob: string, response: any): void;
884
996