@testspectra/matchers 1.0.69 → 1.1.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.
package/dist/types.d.ts CHANGED
@@ -2,12 +2,12 @@
2
2
  * Canonical action keys supported across TestSpectra runner and database models.
3
3
  * @see backend/src/models/test_step.rs
4
4
  */
5
- export type ActionKey = "navigate" | "click" | "type" | "clear" | "select" | "scroll" | "swipe" | "wait" | "waitForElement" | "pressKey" | "longPress" | "doubleClick" | "hover" | "dragDrop" | "back" | "refresh";
5
+ export type ActionKey = 'navigate' | 'click' | 'type' | 'clear' | 'select' | 'scroll' | 'swipe' | 'wait' | 'waitForElement' | 'pressKey' | 'longPress' | 'doubleClick' | 'hover' | 'dragDrop' | 'back' | 'refresh';
6
6
  /**
7
7
  * Canonical assertion keys supported across TestSpectra runner and database models.
8
8
  * @see backend/src/models/test_step.rs
9
9
  */
10
- export type AssertionKey = "elementDisplayed" | "elementNotDisplayed" | "elementExists" | "elementEnabled" | "elementDisabled" | "textContains" | "textEquals" | "textNotContains" | "urlContains" | "urlEquals" | "valueEquals" | "valueContains" | "attributeEquals" | "attributeContains" | "hasClass" | "hasAttribute" | "isSelected" | "elementCount" | "elementCountGreaterThan" | "pageLoaded" | "noErrors";
10
+ export type AssertionKey = 'elementDisplayed' | 'elementNotDisplayed' | 'elementExists' | 'elementNotExists' | 'elementClickable' | 'elementNotClickable' | 'elementEnabled' | 'elementDisabled' | 'elementChecked' | 'elementNotChecked' | 'elementFocused' | 'elementNotFocused' | 'textEquals' | 'textNotEquals' | 'textContains' | 'textNotContains' | 'valueEquals' | 'valueNotEquals' | 'valueContains' | 'valueNotContains' | 'attributeEquals' | 'attributeNotEquals' | 'hasClass' | 'notHasClass' | 'hasCss' | 'notHasCss' | 'collectionLengthEquals' | 'collectionLengthNotEquals' | 'collectionLengthGreaterThan' | 'collectionLengthLessThan' | 'collectionEmpty' | 'collectionNotEmpty' | 'urlEquals' | 'urlContains' | 'titleEquals' | 'titleContains' | 'pageLoaded' | 'noConsoleErrors';
11
11
  /**
12
12
  * Supported keyboard key names for `Spectra.pressKey(key)`.
13
13
  *
@@ -17,15 +17,15 @@ export type AssertionKey = "elementDisplayed" | "elementNotDisplayed" | "element
17
17
  * await Spectra.pressKey("Tab");
18
18
  * ```
19
19
  */
20
- export type KeyOption = "Enter" | "Tab" | "Escape" | "Backspace" | "Delete" | "ArrowUp" | "ArrowDown" | "ArrowLeft" | "ArrowRight" | "Space";
20
+ export type KeyOption = 'Enter' | 'Tab' | 'Escape' | 'Backspace' | 'Delete' | 'ArrowUp' | 'ArrowDown' | 'ArrowLeft' | 'ArrowRight' | 'Space';
21
21
  /**
22
22
  * Cardinal directions for gestures such as swipe and scroll.
23
23
  */
24
- export type Direction = "up" | "down" | "left" | "right";
24
+ export type Direction = 'up' | 'down' | 'left' | 'right';
25
25
  /**
26
26
  * Target reference for locating an element.
27
- * Can be a CSS/XPath selector string, a resolved `WebdriverIO.Element`,
28
- * or a chainable element promise `ChainablePromiseElement`.
27
+ * Can be a CSS/XPath selector string, a resolved `SpectraElement` proxy,
28
+ * or a chainable element promise `Promise<SpectraElement>`.
29
29
  *
30
30
  * @example
31
31
  * ```ts
@@ -36,7 +36,7 @@ export type Direction = "up" | "down" | "left" | "right";
36
36
  * Spectra.get(LoginPage.submitButton);
37
37
  * ```
38
38
  */
39
- export type ElementTarget = string | WebdriverIO.Element | ChainablePromiseElement;
39
+ export type ElementTarget = string | SingleElementProxy | Promise<SingleElementProxy>;
40
40
  /**
41
41
  * Configuration options for scroll actions.
42
42
  *
@@ -91,7 +91,7 @@ export interface ClickOptions {
91
91
  /** Optional inner text filter */
92
92
  text?: string;
93
93
  /** Click type: standard single click or double click */
94
- clickType?: "single" | "double";
94
+ clickType?: 'single' | 'double';
95
95
  }
96
96
  /**
97
97
  * Configuration options for typing input into form elements.
@@ -106,26 +106,1193 @@ export interface TypeOptions {
106
106
  clearFirst?: boolean;
107
107
  }
108
108
  /**
109
- * Fluent assertion matcher strings for single element verification.
110
- * Used in `Spectra.get(target).should(matcher, ...args)`.
111
- *
112
- * @example
113
- * ```ts
114
- * await Spectra.get("#username").should("be.visible");
115
- * await Spectra.get("#greeting").should("have.text", "Welcome back");
116
- * await Spectra.get("#status").should("have.class", "active");
117
- * ```
109
+ * Canonical assertion matcher keys for single element verification.
110
+ * Dispatched internally by semantic receiver methods (`.shouldBeVisible()`, `.shouldHaveText()`, etc.).
118
111
  */
119
- export type SingleElementMatcher = "be.visible" | "not.be.visible" | "exist" | "not.exist" | "be.enabled" | "be.disabled" | "be.checked" | "not.be.checked" | "be.selected" | "not.be.selected" | "have.value" | "contain.value" | "have.text" | "contain.text" | "have.class" | "have.attr" | "have.url" | "contain.url" | "have.title" | "contain.title";
112
+ export type SingleElementMatcher = 'be.visible' | 'not.be.visible' | 'exist' | 'not.exist' | 'be.clickable' | 'not.be.clickable' | 'be.enabled' | 'be.disabled' | 'be.checked' | 'not.be.checked' | 'be.selected' | 'not.be.selected' | 'be.focused' | 'not.be.focused' | 'have.value' | 'not.have.value' | 'contain.value' | 'not.contain.value' | 'have.text' | 'not.have.text' | 'contain.text' | 'not.contain.text' | 'have.class' | 'not.have.class' | 'have.attr' | 'not.have.attr' | 'have.css' | 'not.have.css' | 'have.url' | 'contain.url' | 'have.title' | 'contain.title';
120
113
  /**
121
- * Fluent assertion matcher strings for multi-element collections.
122
- * Used in `Spectra.getAll(selector).should(matcher, ...args)`.
123
- *
124
- * @example
125
- * ```ts
126
- * await Spectra.getAll(".product-item").should("have.length", 4);
127
- * await Spectra.getAll(".product-item").should("have.length.greaterThan", 0);
128
- * await Spectra.getAll(".badge").should("not.be.empty");
129
- * ```
114
+ * Canonical assertion matcher keys for multi-element collections.
115
+ * Dispatched internally by semantic collection methods (`.shouldHaveLength()`, `.shouldBeEmpty()`, etc.).
116
+ */
117
+ export type MultiElementMatcher = 'have.length' | 'not.have.length' | 'have.length.greaterThan' | 'have.length.lessThan' | 'be.empty' | 'not.be.empty' | 'exist';
118
+ /**
119
+ * Receiver-oriented element assertion methods.
120
+ * Attached directly to SingleElementProxy instances.
121
+ */
122
+ export interface ElementReceiverAssertions<TReturn = Promise<void>> {
123
+ /**
124
+ * Asserts that the target element is visible and displayed on the page.
125
+ *
126
+ * @example
127
+ * ```ts
128
+ * await Spectra.get('#submit-btn').shouldBeVisible();
129
+ * await LoginPage.submitButton.shouldBeVisible();
130
+ * ```
131
+ */
132
+ shouldBeVisible(): TReturn;
133
+ /**
134
+ * Asserts that the target element is hidden, detached, or not displayed on the page.
135
+ *
136
+ * @example
137
+ * ```ts
138
+ * await Spectra.get('.loading-spinner').shouldNotBeVisible();
139
+ * ```
140
+ */
141
+ shouldNotBeVisible(): TReturn;
142
+ /**
143
+ * Asserts that the target element exists in the DOM.
144
+ *
145
+ * @example
146
+ * ```ts
147
+ * await Spectra.get('#cookie-consent-modal').shouldExist();
148
+ * ```
149
+ */
150
+ shouldExist(): TReturn;
151
+ /**
152
+ * Asserts that the target element does not exist in the DOM.
153
+ *
154
+ * @example
155
+ * ```ts
156
+ * await Spectra.get('#deleted-record-row').shouldNotExist();
157
+ * ```
158
+ */
159
+ shouldNotExist(): TReturn;
160
+ /**
161
+ * Asserts that the target element is visible, enabled, and clickable.
162
+ *
163
+ * @example
164
+ * ```ts
165
+ * await Spectra.get('button[type="submit"]').shouldBeClickable();
166
+ * ```
167
+ */
168
+ shouldBeClickable(): TReturn;
169
+ /**
170
+ * Asserts that the target element is disabled, covered, or not clickable.
171
+ *
172
+ * @example
173
+ * ```ts
174
+ * await Spectra.get('button.disabled-action').shouldNotBeClickable();
175
+ * ```
176
+ */
177
+ shouldNotBeClickable(): TReturn;
178
+ /**
179
+ * Asserts that the target form input/button is enabled (not disabled).
180
+ *
181
+ * @example
182
+ * ```ts
183
+ * await Spectra.get('#username-field').shouldBeEnabled();
184
+ * ```
185
+ */
186
+ shouldBeEnabled(): TReturn;
187
+ /**
188
+ * Asserts that the target form input/button has the disabled state/attribute.
189
+ *
190
+ * @example
191
+ * ```ts
192
+ * await Spectra.get('#submit-order-btn').shouldBeDisabled();
193
+ * ```
194
+ */
195
+ shouldBeDisabled(): TReturn;
196
+ /**
197
+ * Asserts that the target checkbox or radio input is checked/selected.
198
+ *
199
+ * @example
200
+ * ```ts
201
+ * await Spectra.get('#terms-checkbox').shouldBeChecked();
202
+ * ```
203
+ */
204
+ shouldBeChecked(): TReturn;
205
+ /**
206
+ * Asserts that the target checkbox or radio input is unchecked/deselected.
207
+ *
208
+ * @example
209
+ * ```ts
210
+ * await Spectra.get('#subscribe-newsletter').shouldNotBeChecked();
211
+ * ```
212
+ */
213
+ shouldNotBeChecked(): TReturn;
214
+ /**
215
+ * Asserts that the target element currently holds active document focus.
216
+ *
217
+ * @example
218
+ * ```ts
219
+ * await Spectra.get('#search-input').shouldBeFocused();
220
+ * ```
221
+ */
222
+ shouldBeFocused(): TReturn;
223
+ /**
224
+ * Asserts that the target element does not hold active document focus.
225
+ *
226
+ * @example
227
+ * ```ts
228
+ * await Spectra.get('#blur-input').shouldNotBeFocused();
229
+ * ```
230
+ */
231
+ shouldNotBeFocused(): TReturn;
232
+ /**
233
+ * Asserts that the target element's text content matches the expected string or regular expression.
234
+ *
235
+ * @param expected Exact string or RegExp pattern to match against element text.
236
+ * @example
237
+ * ```ts
238
+ * await Spectra.get('h1.page-title').shouldHaveText('Dashboard Overview');
239
+ * await Spectra.get('.badge').shouldHaveText(/Active|Pending/);
240
+ * ```
241
+ */
242
+ shouldHaveText(expected: string | RegExp): TReturn;
243
+ /**
244
+ * Asserts that the target element's text content does not match the expected string or regular expression.
245
+ *
246
+ * @param expected String or RegExp pattern that the element text must NOT match.
247
+ * @example
248
+ * ```ts
249
+ * await Spectra.get('.status-label').shouldNotHaveText('Error');
250
+ * ```
251
+ */
252
+ shouldNotHaveText(expected: string | RegExp): TReturn;
253
+ /**
254
+ * Asserts that the target element's text content contains the specified substring.
255
+ *
256
+ * @param substring Substring expected to be present within the element text.
257
+ * @example
258
+ * ```ts
259
+ * await Spectra.get('.toast-message').shouldContainText('Successfully saved');
260
+ * ```
261
+ */
262
+ shouldContainText(substring: string): TReturn;
263
+ /**
264
+ * Asserts that the target element's text content does not contain the specified substring.
265
+ *
266
+ * @param substring Substring that must NOT be present within the element text.
267
+ * @example
268
+ * ```ts
269
+ * await Spectra.get('.log-output').shouldNotContainText('Fatal Exception');
270
+ * ```
271
+ */
272
+ shouldNotContainText(substring: string): TReturn;
273
+ /**
274
+ * Asserts that the form input or textarea element's value exactly equals the specified string.
275
+ *
276
+ * @param value Expected input field value.
277
+ * @example
278
+ * ```ts
279
+ * await Spectra.get('input[name="email"]').shouldHaveValue('admin@testspectra.dev');
280
+ * ```
281
+ */
282
+ shouldHaveValue(value: string): TReturn;
283
+ /**
284
+ * Asserts that the form input or textarea element's value does not equal the specified string.
285
+ *
286
+ * @param value Value that the input field must NOT equal.
287
+ * @example
288
+ * ```ts
289
+ * await Spectra.get('input[name="role"]').shouldNotHaveValue('guest');
290
+ * ```
291
+ */
292
+ shouldNotHaveValue(value: string): TReturn;
293
+ /**
294
+ * Asserts that the form input or textarea element's value contains the specified substring.
295
+ *
296
+ * @param substring Substring expected to be contained within the input value.
297
+ * @example
298
+ * ```ts
299
+ * await Spectra.get('input[name="email"]').shouldContainValue('@testspectra.dev');
300
+ * ```
301
+ */
302
+ shouldContainValue(substring: string): TReturn;
303
+ /**
304
+ * Asserts that the form input or textarea element's value does not contain the specified substring.
305
+ *
306
+ * @param substring Substring that must NOT be contained within the input value.
307
+ * @example
308
+ * ```ts
309
+ * await Spectra.get('input[name="url"]').shouldNotContainValue('http://');
310
+ * ```
311
+ */
312
+ shouldNotContainValue(substring: string): TReturn;
313
+ /**
314
+ * Asserts that the element has the specified attribute, and optionally that its value matches.
315
+ *
316
+ * @param name Attribute name to inspect.
317
+ * @param value Optional expected attribute value string.
318
+ * @example
319
+ * ```ts
320
+ * await Spectra.get('a.external-link').shouldHaveAttribute('target', '_blank');
321
+ * await Spectra.get('input.required-field').shouldHaveAttribute('required');
322
+ * ```
323
+ */
324
+ shouldHaveAttribute(name: string, value?: string): TReturn;
325
+ /**
326
+ * Asserts that the element does not have the specified attribute.
327
+ *
328
+ * @param name Attribute name that must NOT exist on the element.
329
+ * @example
330
+ * ```ts
331
+ * await Spectra.get('button#action-btn').shouldNotHaveAttribute('disabled');
332
+ * ```
333
+ */
334
+ shouldNotHaveAttribute(name: string): TReturn;
335
+ /**
336
+ * Asserts that the element contains the specified CSS class name.
337
+ *
338
+ * @param className CSS class name expected in the element's classList.
339
+ * @example
340
+ * ```ts
341
+ * await Spectra.get('.nav-tab').shouldHaveClass('active');
342
+ * ```
343
+ */
344
+ shouldHaveClass(className: string): TReturn;
345
+ /**
346
+ * Asserts that the element does not contain the specified CSS class name.
347
+ *
348
+ * @param className CSS class name that must NOT be in the element's classList.
349
+ * @example
350
+ * ```ts
351
+ * await Spectra.get('.modal-backdrop').shouldNotHaveClass('hidden');
352
+ * ```
353
+ */
354
+ shouldNotHaveClass(className: string): TReturn;
355
+ /**
356
+ * Asserts that the computed CSS style property of the element equals the specified value.
357
+ *
358
+ * @param property CSS style property name (e.g. 'color', 'display', 'opacity').
359
+ * @param value Expected computed CSS property value.
360
+ * @example
361
+ * ```ts
362
+ * await Spectra.get('.badge-success').shouldHaveCss('color', 'rgb(0, 128, 0)');
363
+ * ```
364
+ */
365
+ shouldHaveCss(property: string, value: string): TReturn;
366
+ /**
367
+ * Asserts that the computed CSS style property of the element does not equal the specified value.
368
+ *
369
+ * @param property CSS style property name.
370
+ * @param value Value that the computed CSS property must NOT equal.
371
+ * @example
372
+ * ```ts
373
+ * await Spectra.get('.main-content').shouldNotHaveCss('display', 'none');
374
+ * ```
375
+ */
376
+ shouldNotHaveCss(property: string, value: string): TReturn;
377
+ }
378
+ /**
379
+ * Receiver-oriented collection assertion methods.
380
+ * Attached directly to CollectionProxy and collection prototypes.
381
+ */
382
+ export interface CollectionReceiverAssertions<TReturn = Promise<void>> {
383
+ /**
384
+ * Asserts that the collection contains exactly the specified number of matching elements.
385
+ *
386
+ * @param count Expected exact count of elements.
387
+ * @example
388
+ * ```ts
389
+ * await Spectra.getAll('.user-table-row').shouldHaveLength(10);
390
+ * ```
391
+ */
392
+ shouldHaveLength(count: number): TReturn;
393
+ /**
394
+ * Asserts that the collection does not contain the specified number of matching elements.
395
+ *
396
+ * @param count Count that the element collection must NOT equal.
397
+ * @example
398
+ * ```ts
399
+ * await Spectra.getAll('.error-item').shouldNotHaveLength(0);
400
+ * ```
401
+ */
402
+ shouldNotHaveLength(count: number): TReturn;
403
+ /**
404
+ * Asserts that the collection contains strictly more than `min` matching elements.
405
+ *
406
+ * @param min Minimum threshold (exclusive).
407
+ * @example
408
+ * ```ts
409
+ * await Spectra.getAll('.search-result-card').shouldHaveLengthGreaterThan(0);
410
+ * ```
411
+ */
412
+ shouldHaveLengthGreaterThan(min: number): TReturn;
413
+ /**
414
+ * Asserts that the collection contains strictly fewer than `max` matching elements.
415
+ *
416
+ * @param max Maximum threshold (exclusive).
417
+ * @example
418
+ * ```ts
419
+ * await Spectra.getAll('.warning-banner').shouldHaveLengthLessThan(5);
420
+ * ```
421
+ */
422
+ shouldHaveLengthLessThan(max: number): TReturn;
423
+ /**
424
+ * Asserts that the collection contains zero matching elements.
425
+ *
426
+ * @example
427
+ * ```ts
428
+ * await Spectra.getAll('.unread-notification-badge').shouldBeEmpty();
429
+ * ```
430
+ */
431
+ shouldBeEmpty(): TReturn;
432
+ /**
433
+ * Asserts that the collection contains at least one matching element.
434
+ *
435
+ * @example
436
+ * ```ts
437
+ * await Spectra.getAll('.product-card').shouldNotBeEmpty();
438
+ * ```
439
+ */
440
+ shouldNotBeEmpty(): TReturn;
441
+ }
442
+ /**
443
+ * Browser-level context assertion methods.
444
+ * Hosted on Spectra.browser and the global browser object.
445
+ */
446
+ export interface BrowserReceiverAssertions {
447
+ /**
448
+ * Asserts that current browser URL exactly matches the expected URL.
449
+ *
450
+ * @param expectedUrl Full expected URL string.
451
+ * @example
452
+ * ```ts
453
+ * await Spectra.browser.shouldHaveUrl('https://app.testspectra.dev/dashboard');
454
+ * ```
455
+ */
456
+ shouldHaveUrl(expectedUrl: string): Promise<void>;
457
+ /**
458
+ * Asserts that current browser URL contains the specified substring.
459
+ *
460
+ * @param expectedSubstr Substring expected in browser URL.
461
+ * @example
462
+ * ```ts
463
+ * await Spectra.browser.shouldContainUrl('/dashboard');
464
+ * ```
465
+ */
466
+ shouldContainUrl(expectedSubstr: string): Promise<void>;
467
+ /**
468
+ * Asserts that current page title exactly matches the expected title.
469
+ *
470
+ * @param expectedTitle Full expected page title string.
471
+ * @example
472
+ * ```ts
473
+ * await Spectra.browser.shouldHaveTitle('Dashboard - TestSpectra');
474
+ * ```
475
+ */
476
+ shouldHaveTitle(expectedTitle: string): Promise<void>;
477
+ /**
478
+ * Asserts that current page title contains the specified substring.
479
+ *
480
+ * @param expectedSubstr Substring expected in page title.
481
+ * @example
482
+ * ```ts
483
+ * await Spectra.browser.shouldContainTitle('Dashboard');
484
+ * ```
485
+ */
486
+ shouldContainTitle(expectedSubstr: string): Promise<void>;
487
+ /**
488
+ * Asserts that the browser document `readyState` is 'complete' or 'interactive'.
489
+ *
490
+ * @example
491
+ * ```ts
492
+ * await Spectra.browser.shouldBeLoaded();
493
+ * ```
494
+ */
495
+ shouldBeLoaded(): Promise<void>;
496
+ /**
497
+ * Asserts that no severe or unhandled JavaScript errors occurred in the browser console.
498
+ *
499
+ * @example
500
+ * ```ts
501
+ * await Spectra.browser.shouldHaveNoConsoleErrors();
502
+ * ```
503
+ */
504
+ shouldHaveNoConsoleErrors(): Promise<void>;
505
+ /**
506
+ * Clears all browser cookies for the active domain.
507
+ *
508
+ * @example
509
+ * ```ts
510
+ * await Spectra.browser.clearCookies();
511
+ * ```
512
+ */
513
+ clearCookies(): Promise<void>;
514
+ /**
515
+ * Clears all key-value entries in browser `localStorage`.
516
+ *
517
+ * @example
518
+ * ```ts
519
+ * await Spectra.browser.clearLocalStorage();
520
+ * ```
521
+ */
522
+ clearLocalStorage(): Promise<void>;
523
+ }
524
+ /**
525
+ * Native proxy interface for interacting with a single DOM / UI element.
526
+ */
527
+ export interface SingleElementProxy extends ElementReceiverAssertions<Promise<void>> {
528
+ /** Target CSS or XPath selector string for this element. */
529
+ selector: string;
530
+ /** Positional index when matched from a collection (or null for standalone selectors). */
531
+ index: number | null;
532
+ /**
533
+ * Waits until the element exists in the DOM within the specified timeout.
534
+ *
535
+ * @param timeoutMs Timeout in milliseconds (default: 5000ms).
536
+ */
537
+ waitForElement(timeoutMs?: number): Promise<boolean>;
538
+ /**
539
+ * Clicks on the element.
540
+ *
541
+ * @param options Optional click interaction options.
542
+ * @example
543
+ * ```ts
544
+ * await Spectra.get('#submit-btn').click();
545
+ * ```
546
+ */
547
+ click(options?: ClickOptions): Promise<void>;
548
+ /**
549
+ * Performs a double-click interaction on the element.
550
+ *
551
+ * @example
552
+ * ```ts
553
+ * await Spectra.get('.editable-cell').doubleClick();
554
+ * ```
555
+ */
556
+ doubleClick(): Promise<void>;
557
+ /**
558
+ * Performs a context-click (right-click) on the element.
559
+ *
560
+ * @example
561
+ * ```ts
562
+ * await Spectra.get('.file-item').rightClick();
563
+ * ```
564
+ */
565
+ rightClick(): Promise<void>;
566
+ /**
567
+ * Sets or replaces the value of a form input element.
568
+ *
569
+ * @param value Text value to set.
570
+ * @example
571
+ * ```ts
572
+ * await Spectra.get('#username').setValue('admin');
573
+ * ```
574
+ */
575
+ setValue(value: unknown): Promise<void>;
576
+ /**
577
+ * Types text keystrokes into the element, optionally clearing existing content first.
578
+ *
579
+ * @param value Text string to type.
580
+ * @param options Optional type options (e.g. `{ clearFirst: true }`).
581
+ * @example
582
+ * ```ts
583
+ * await LoginPage.emailInput.type('admin@testspectra.dev', { clearFirst: true });
584
+ * ```
585
+ */
586
+ type(value: unknown, options?: TypeOptions): Promise<void>;
587
+ /**
588
+ * Clears the current text value from an input or textarea element.
589
+ *
590
+ * @example
591
+ * ```ts
592
+ * await Spectra.get('#search-bar').clearValue();
593
+ * ```
594
+ */
595
+ clearValue(): Promise<void>;
596
+ /**
597
+ * Clears the current text value from an input or textarea element (alias to `clearValue()`).
598
+ *
599
+ * @example
600
+ * ```ts
601
+ * await Spectra.get('#search-bar').clear();
602
+ * ```
603
+ */
604
+ clear(): Promise<void>;
605
+ /**
606
+ * Selects an option in a `<select>` element by its visible text or value.
607
+ *
608
+ * @param option Visible text or value of the option to select.
609
+ * @example
610
+ * ```ts
611
+ * await Spectra.get('#country-dropdown').select('Indonesia');
612
+ * ```
613
+ */
614
+ select(option: string): Promise<void>;
615
+ /**
616
+ * Selects an option in a `<select>` dropdown by its visible text.
617
+ *
618
+ * @param text Visible text label of the option.
619
+ */
620
+ selectByVisibleText(text: string): Promise<void>;
621
+ /**
622
+ * Hovers the mouse cursor over the center of the element.
623
+ *
624
+ * @example
625
+ * ```ts
626
+ * await Spectra.get('.dropdown-trigger').hover();
627
+ * ```
628
+ */
629
+ hover(): Promise<void>;
630
+ /**
631
+ * Focuses the target element (triggers focus event and active document focus).
632
+ *
633
+ * @example
634
+ * ```ts
635
+ * await Spectra.get('#email-input').focus();
636
+ * ```
637
+ */
638
+ focus(): Promise<void>;
639
+ /**
640
+ * Moves the mouse cursor to the element (alias to `hover()`).
641
+ */
642
+ moveTo(): Promise<void>;
643
+ /**
644
+ * Drags this element and drops it onto the target element destination.
645
+ *
646
+ * @param target Destination element target selector or proxy.
647
+ * @example
648
+ * ```ts
649
+ * await Spectra.get('#drag-source').dragDrop('#drop-zone');
650
+ * ```
651
+ */
652
+ dragDrop(target: ElementTarget): Promise<void>;
653
+ /**
654
+ * Drags this element and drops it onto the target element destination (alias to `dragDrop()`).
655
+ */
656
+ dragAndDrop(target: ElementTarget): Promise<void>;
657
+ /**
658
+ * Scrolls the page until this element is aligned into the visible viewport.
659
+ *
660
+ * @example
661
+ * ```ts
662
+ * await Spectra.get('#footer-links').scrollIntoView();
663
+ * ```
664
+ */
665
+ scrollIntoView(): Promise<void>;
666
+ /**
667
+ * Long-presses on the element for touch/mobile gestures.
668
+ *
669
+ * @param options Long-press duration in milliseconds or configuration object.
670
+ * @example
671
+ * ```ts
672
+ * await Spectra.get('.draggable-card').longPress({ duration: 1500 });
673
+ * ```
674
+ */
675
+ longPress(options?: number | LongPressOptions): Promise<void>;
676
+ /**
677
+ * Waits until the element is displayed and visible in the viewport.
678
+ *
679
+ * @param opts Optional timeout configuration object.
680
+ */
681
+ waitForDisplayed(opts?: {
682
+ timeout?: number;
683
+ }): Promise<boolean>;
684
+ /**
685
+ * Returns the inner text content of the element.
686
+ *
687
+ * @example
688
+ * ```ts
689
+ * const headingText = await Spectra.get('h1').getText();
690
+ * ```
691
+ */
692
+ getText(): Promise<string>;
693
+ /**
694
+ * Returns the current `value` property of an input or textarea element.
695
+ *
696
+ * @example
697
+ * ```ts
698
+ * const query = await Spectra.get('input#search').getValue();
699
+ * ```
700
+ */
701
+ getValue(): Promise<string>;
702
+ /**
703
+ * Returns true if the element is currently visible and rendered in the DOM.
704
+ */
705
+ isDisplayed(): Promise<boolean>;
706
+ /**
707
+ * Returns true if the element is currently visible (alias to `isDisplayed()`).
708
+ */
709
+ isVisible(): Promise<boolean>;
710
+ /**
711
+ * Returns true if the element exists in the DOM.
712
+ */
713
+ isExisting(): Promise<boolean>;
714
+ /**
715
+ * Returns true if the element is enabled (not disabled).
716
+ */
717
+ isEnabled(): Promise<boolean>;
718
+ /**
719
+ * Returns true if the checkbox, radio, or `<option>` is selected.
720
+ */
721
+ isSelected(): Promise<boolean>;
722
+ /**
723
+ * Returns true if the checkbox or radio button is checked.
724
+ */
725
+ isChecked(): Promise<boolean>;
726
+ /**
727
+ * Returns true if the element is the active focused element in document.
728
+ */
729
+ isFocused(): Promise<boolean>;
730
+ /**
731
+ * Retrieves the value of a specified HTML attribute from the element.
732
+ *
733
+ * @param name Attribute name (e.g. 'href', 'src', 'data-id').
734
+ * @example
735
+ * ```ts
736
+ * const linkUrl = await Spectra.get('a#download').getAttribute('href');
737
+ * ```
738
+ */
739
+ getAttribute(name: string): Promise<string | null>;
740
+ /**
741
+ * Retrieves the computed CSS property value of the element.
742
+ *
743
+ * @param name CSS property name (e.g. 'background-color', 'font-size').
744
+ * @example
745
+ * ```ts
746
+ * const color = await Spectra.get('.btn-primary').getCSSProperty('background-color');
747
+ * ```
748
+ */
749
+ getCSSProperty(name: string): Promise<{
750
+ value: string;
751
+ }>;
752
+ }
753
+ /**
754
+ * TestSpectra native element interface alias.
755
+ */
756
+ export type SpectraElement = SingleElementProxy;
757
+ /**
758
+ * Native proxy interface for interacting with multiple matching elements in a collection.
759
+ */
760
+ export interface CollectionProxy extends CollectionReceiverAssertions<Promise<void>> {
761
+ /** Target CSS or XPath selector string for this collection. */
762
+ selector: string;
763
+ /**
764
+ * Returns the total count of elements matching this collection selector.
765
+ *
766
+ * @example
767
+ * ```ts
768
+ * const totalRows = await Spectra.getAll('.table-row').count();
769
+ * ```
770
+ */
771
+ count(): Promise<number>;
772
+ /**
773
+ * Total count of elements matching this collection selector (Promise).
774
+ */
775
+ readonly length: Promise<number>;
776
+ /**
777
+ * Returns a `SingleElementProxy` pointing to the first matching element in the collection (index 0).
778
+ *
779
+ * @example
780
+ * ```ts
781
+ * await Spectra.getAll('.list-item').first().click();
782
+ * ```
783
+ */
784
+ first(): SingleElementProxy;
785
+ /**
786
+ * Returns a `SingleElementProxy` pointing to the last matching element in the collection.
787
+ *
788
+ * @example
789
+ * ```ts
790
+ * await Spectra.getAll('.list-item').last().click();
791
+ * ```
792
+ */
793
+ last(): SingleElementProxy;
794
+ /**
795
+ * Returns a `SingleElementProxy` pointing to the matching element at the specified zero-based index.
796
+ *
797
+ * @param index Zero-based index of the target element.
798
+ * @example
799
+ * ```ts
800
+ * await Spectra.getAll('.list-item').nth(2).click();
801
+ * ```
802
+ */
803
+ nth(index: number): SingleElementProxy;
804
+ }
805
+ /**
806
+ * TestSpectra native collection interface alias.
807
+ */
808
+ export type SpectraCollection = CollectionProxy;
809
+ /**
810
+ * Native browser bridge interface for page navigation, execution, and network interception.
811
+ */
812
+ export interface SpectraBrowserBridge extends BrowserReceiverAssertions {
813
+ /**
814
+ * Navigates the browser to the specified absolute or relative URL.
815
+ *
816
+ * @param targetUrl Target destination URL.
817
+ * @example
818
+ * ```ts
819
+ * await Spectra.browser.url('/auth/login');
820
+ * ```
821
+ */
822
+ url(targetUrl: string): Promise<void>;
823
+ /**
824
+ * Retrieves the current browser URL.
825
+ *
826
+ * @example
827
+ * ```ts
828
+ * const currentUrl = await Spectra.browser.getUrl();
829
+ * ```
830
+ */
831
+ getUrl(): Promise<string>;
832
+ /**
833
+ * Retrieves the current page title.
834
+ *
835
+ * @example
836
+ * ```ts
837
+ * const title = await Spectra.browser.getTitle();
838
+ * ```
839
+ */
840
+ getTitle(): Promise<string>;
841
+ /**
842
+ * Navigates one step back in the browser history.
843
+ *
844
+ * @example
845
+ * ```ts
846
+ * await Spectra.browser.back();
847
+ * ```
848
+ */
849
+ back(): Promise<void>;
850
+ /**
851
+ * Navigates one step forward in the browser history.
852
+ *
853
+ * @example
854
+ * ```ts
855
+ * await Spectra.browser.forward();
856
+ * ```
857
+ */
858
+ forward(): Promise<void>;
859
+ /**
860
+ * Reloads / refreshes the current active page.
861
+ *
862
+ * @example
863
+ * ```ts
864
+ * await Spectra.browser.refresh();
865
+ * ```
866
+ */
867
+ refresh(): Promise<void>;
868
+ /**
869
+ * Pauses test execution for the specified number of milliseconds.
870
+ *
871
+ * @param ms Duration in milliseconds to pause.
872
+ * @example
873
+ * ```ts
874
+ * await Spectra.browser.pause(1000);
875
+ * ```
876
+ */
877
+ pause(ms: number): Promise<void>;
878
+ /**
879
+ * Sets the browser viewport dimensions (width and height in pixels).
880
+ *
881
+ * @param width Viewport width in pixels.
882
+ * @param height Viewport height in pixels.
883
+ * @example
884
+ * ```ts
885
+ * await Spectra.browser.setViewport(1920, 1080);
886
+ * ```
887
+ */
888
+ setViewport(width: number, height: number): Promise<void>;
889
+ /**
890
+ * Executes a JavaScript function or script snippet in the browser context and returns the result.
891
+ *
892
+ * @param fn Function or script string to execute.
893
+ * @param args Arguments to pass into the function.
894
+ * @example
895
+ * ```ts
896
+ * const docWidth = await Spectra.browser.execute(() => document.body.clientWidth);
897
+ * ```
898
+ */
899
+ execute<R = unknown>(fn: ((...args: unknown[]) => R) | string, ...args: unknown[]): Promise<R>;
900
+ /**
901
+ * Evaluates a JavaScript expression string in the browser context.
902
+ *
903
+ * @param expr JavaScript expression string.
904
+ * @example
905
+ * ```ts
906
+ * const isReady = await Spectra.browser.evaluate('document.readyState === "complete"');
907
+ * ```
908
+ */
909
+ evaluate<R = unknown>(expr: string): Promise<R>;
910
+ /**
911
+ * Repeatedly polls a condition function until it returns true or times out.
912
+ *
913
+ * @param fn Condition function returning a boolean or boolean promise.
914
+ * @param opts Optional timeout and message options.
915
+ * @example
916
+ * ```ts
917
+ * await Spectra.browser.waitUntil(async () => (await Spectra.get('#status').getText()) === 'Ready', {
918
+ * timeout: 5000,
919
+ * timeoutMsg: 'Status never reached Ready',
920
+ * });
921
+ * ```
922
+ */
923
+ waitUntil(fn: () => Promise<boolean> | boolean, opts?: {
924
+ timeout?: number;
925
+ timeoutMsg?: string;
926
+ }): Promise<boolean>;
927
+ /**
928
+ * Retrieves captured browser console log entries.
929
+ *
930
+ * @param type Optional log type filter (e.g. 'browser', 'error').
931
+ */
932
+ getLogs(type?: string): Promise<Array<{
933
+ level: string;
934
+ message: string;
935
+ }>>;
936
+ /**
937
+ * Intercepts and mocks HTTP network requests matching the specified URL pattern.
938
+ *
939
+ * @param pattern URL substring or glob pattern to intercept.
940
+ * @param method HTTP method (GET, POST, PUT, DELETE, etc.).
941
+ * @param fixture Mock response payload object or string.
942
+ * @param options Mock response options (status code, custom headers).
943
+ * @example
944
+ * ```ts
945
+ * const mock = await Spectra.browser.intercept('/api/v1/users', 'GET', [{ id: 1, name: 'Alice' }], {
946
+ * statusCode: 200,
947
+ * });
948
+ * ```
949
+ */
950
+ intercept(pattern: string, method?: string, fixture?: unknown, options?: {
951
+ statusCode?: number;
952
+ headers?: Record<string, string>;
953
+ }): Promise<MockInterceptHandle>;
954
+ }
955
+ /**
956
+ * Mock rule configuration for CDP network request interception.
130
957
  */
131
- export type MultiElementMatcher = "have.length" | "have.length.greaterThan" | "be.empty" | "exist";
958
+ export interface MockRule {
959
+ /** URL pattern or substring to match. */
960
+ pattern: string;
961
+ /** HTTP method (e.g. GET, POST). */
962
+ method: string;
963
+ /** Mock response payload. */
964
+ response: unknown;
965
+ /** HTTP status code (e.g. 200, 404). */
966
+ statusCode: number;
967
+ /** Custom HTTP response headers. */
968
+ headers?: Record<string, string>;
969
+ /** Total times this mock rule matched and intercepted requests. */
970
+ callCount: number;
971
+ }
972
+ /**
973
+ * Handle returned by `Spectra.intercept()` to dynamically inspect and update mock responses.
974
+ */
975
+ export interface MockInterceptHandle {
976
+ /**
977
+ * Dynamically updates the response payload for this active mock rule.
978
+ *
979
+ * @param newFixture New response payload object or string.
980
+ * @param newOptions Optional status code and header overrides.
981
+ */
982
+ respondWith: (newFixture: unknown, newOptions?: {
983
+ statusCode?: number;
984
+ headers?: Record<string, string>;
985
+ }) => Promise<void>;
986
+ /**
987
+ * Returns the number of times this mock intercepted network requests.
988
+ */
989
+ callCount: () => number;
990
+ }
991
+ /**
992
+ * Audit log entry for captured CDP network requests.
993
+ */
994
+ export interface CDPNetworkEntry {
995
+ /** Unique CDP request ID. */
996
+ requestId: string;
997
+ /** Target request URL. */
998
+ url: string;
999
+ /** HTTP request method. */
1000
+ method: string;
1001
+ /** Resource type (e.g. 'Fetch', 'XHR', 'Document', 'Stylesheet'). */
1002
+ type: string;
1003
+ /** HTTP response status code. */
1004
+ status: number;
1005
+ /** HTTP response status message. */
1006
+ statusText: string;
1007
+ /** Host domain name. */
1008
+ domain: string;
1009
+ /** Protocol name (e.g. 'h2', 'http/1.1'). */
1010
+ protocol: string;
1011
+ /** Request timing metrics in milliseconds. */
1012
+ timing: {
1013
+ waiting: number;
1014
+ download: number;
1015
+ };
1016
+ /** Content body size in bytes. */
1017
+ size: number;
1018
+ /** Wire transfer size in bytes. */
1019
+ transferSize: number;
1020
+ /** Start timestamp epoch. */
1021
+ startTime: number;
1022
+ }
1023
+ /**
1024
+ * Main TestSpectra cross-platform automation and assertion interface contract.
1025
+ */
1026
+ export interface SpectraStatic {
1027
+ /**
1028
+ * Locates a single DOM / UI element proxy by selector or target reference.
1029
+ *
1030
+ * @param target CSS selector string, XPath string, or element proxy.
1031
+ * @example
1032
+ * ```ts
1033
+ * const submitBtn = Spectra.get('#btn-submit');
1034
+ * await submitBtn.click();
1035
+ * ```
1036
+ */
1037
+ get(target: ElementTarget): SingleElementProxy;
1038
+ /**
1039
+ * Locates a collection proxy of multiple matching DOM / UI elements by selector.
1040
+ *
1041
+ * @param selector CSS or XPath selector matching multiple elements.
1042
+ * @example
1043
+ * ```ts
1044
+ * const rows = Spectra.getAll('table tr');
1045
+ * await rows.shouldHaveLength(5);
1046
+ * ```
1047
+ */
1048
+ getAll(selector: string): CollectionProxy;
1049
+ /**
1050
+ * Navigates the active browser window or mobile webview to the specified URL.
1051
+ *
1052
+ * @param url Absolute or relative URL destination.
1053
+ * @example
1054
+ * ```ts
1055
+ * await Spectra.navigate('/dashboard');
1056
+ * ```
1057
+ */
1058
+ navigate(url: string): Promise<void>;
1059
+ /**
1060
+ * Navigates one step backward in browser history.
1061
+ *
1062
+ * @example
1063
+ * ```ts
1064
+ * await Spectra.back();
1065
+ * ```
1066
+ */
1067
+ back(): Promise<void>;
1068
+ /**
1069
+ * Navigates one step forward in browser history.
1070
+ *
1071
+ * @example
1072
+ * ```ts
1073
+ * await Spectra.forward();
1074
+ * ```
1075
+ */
1076
+ forward(): Promise<void>;
1077
+ /**
1078
+ * Reloads / refreshes the current active page.
1079
+ *
1080
+ * @example
1081
+ * ```ts
1082
+ * await Spectra.refresh();
1083
+ * ```
1084
+ */
1085
+ refresh(): Promise<void>;
1086
+ /**
1087
+ * Sets the browser viewport dimensions (width and height in pixels).
1088
+ *
1089
+ * @param width Viewport width in pixels.
1090
+ * @param height Viewport height in pixels.
1091
+ * @example
1092
+ * ```ts
1093
+ * await Spectra.setViewport(1920, 1080);
1094
+ * ```
1095
+ */
1096
+ setViewport(width: number, height: number): Promise<void>;
1097
+ /**
1098
+ * Clicks on the specified element target.
1099
+ *
1100
+ * @param target Element selector string, Page Object element, or proxy.
1101
+ * @param textOrOptions Optional text filter or click options.
1102
+ * @example
1103
+ * ```ts
1104
+ * await Spectra.click('#submit-btn');
1105
+ * await Spectra.click(LoginPage.submitButton);
1106
+ * ```
1107
+ */
1108
+ click(target: ElementTarget, textOrOptions?: string | ClickOptions): Promise<void>;
1109
+ /**
1110
+ * Performs a double-click interaction on the specified element target.
1111
+ *
1112
+ * @param target Target element selector or proxy.
1113
+ * @example
1114
+ * ```ts
1115
+ * await Spectra.doubleClick('.grid-cell');
1116
+ * ```
1117
+ */
1118
+ doubleClick(target: ElementTarget): Promise<void>;
1119
+ /**
1120
+ * Performs a context-click (right-click) interaction on the specified element target.
1121
+ *
1122
+ * @param target Target element selector or proxy.
1123
+ * @example
1124
+ * ```ts
1125
+ * await Spectra.rightClick('#context-menu-area');
1126
+ * ```
1127
+ */
1128
+ rightClick(target: ElementTarget): Promise<void>;
1129
+ /**
1130
+ * Types text keystrokes into the specified element target.
1131
+ *
1132
+ * @param target Target input or textarea element selector or proxy.
1133
+ * @param text String content to type.
1134
+ * @param options Optional typing configuration (e.g. `{ clearFirst: true }`).
1135
+ * @example
1136
+ * ```ts
1137
+ * await Spectra.type('#username', 'john_doe', { clearFirst: true });
1138
+ * ```
1139
+ */
1140
+ type(target: ElementTarget, text: string, options?: TypeOptions): Promise<void>;
1141
+ /**
1142
+ * Clears the current text value from an input or textarea element.
1143
+ *
1144
+ * @param target Target element selector or proxy.
1145
+ * @example
1146
+ * ```ts
1147
+ * await Spectra.clear('#search-input');
1148
+ * ```
1149
+ */
1150
+ clear(target: ElementTarget): Promise<void>;
1151
+ /**
1152
+ * Selects an option in a `<select>` dropdown by its visible text or value.
1153
+ *
1154
+ * @param target Target select element selector or proxy.
1155
+ * @param option Visible text label or value of the option.
1156
+ * @example
1157
+ * ```ts
1158
+ * await Spectra.select('#country-dropdown', 'United States');
1159
+ * ```
1160
+ */
1161
+ select(target: ElementTarget, option: string): Promise<void>;
1162
+ /**
1163
+ * Hovers the mouse cursor over the specified element target.
1164
+ *
1165
+ * @param target Target element selector or proxy.
1166
+ * @example
1167
+ * ```ts
1168
+ * await Spectra.hover('.profile-menu-trigger');
1169
+ * ```
1170
+ */
1171
+ hover(target: ElementTarget): Promise<void>;
1172
+ /**
1173
+ * Focuses the target element (triggers focus event and active document focus).
1174
+ *
1175
+ * @param target Target element selector or proxy.
1176
+ * @example
1177
+ * ```ts
1178
+ * await Spectra.focus('#email-input');
1179
+ * ```
1180
+ */
1181
+ focus(target: ElementTarget): Promise<void>;
1182
+ /**
1183
+ * Drags a source element and drops it onto a destination element target.
1184
+ *
1185
+ * @param source Draggable source element selector or proxy.
1186
+ * @param destination Drop zone destination element selector or proxy.
1187
+ * @example
1188
+ * ```ts
1189
+ * await Spectra.dragDrop('#item-1', '#kanban-column-done');
1190
+ * ```
1191
+ */
1192
+ dragDrop(source: ElementTarget, destination: ElementTarget): Promise<void>;
1193
+ /**
1194
+ * Scrolls the page until the specified element is aligned into the visible viewport.
1195
+ *
1196
+ * @param target Target element selector or proxy.
1197
+ * @example
1198
+ * ```ts
1199
+ * await Spectra.scrollIntoView('#footer-contact');
1200
+ * ```
1201
+ */
1202
+ scrollIntoView(target: ElementTarget): Promise<void>;
1203
+ /**
1204
+ * Performs a directional scroll on the page.
1205
+ *
1206
+ * @param options Scroll options (direction, pixel distance, or target selector).
1207
+ * @example
1208
+ * ```ts
1209
+ * await Spectra.scroll({ direction: 'down', pixels: 400 });
1210
+ * ```
1211
+ */
1212
+ scroll(options?: ScrollOptions): Promise<void>;
1213
+ /**
1214
+ * Performs a directional touch swipe gesture (mobile & web).
1215
+ *
1216
+ * @param options Swipe options (direction, distance in pixels, anchor selector).
1217
+ * @example
1218
+ * ```ts
1219
+ * await Spectra.swipe({ direction: 'left', distance: 300 });
1220
+ * ```
1221
+ */
1222
+ swipe(options: SwipeOptions): Promise<void>;
1223
+ /**
1224
+ * Performs a long-press touch gesture on the target element.
1225
+ *
1226
+ * @param target Target element selector or proxy.
1227
+ * @param options Long-press duration in milliseconds or configuration object.
1228
+ * @example
1229
+ * ```ts
1230
+ * await Spectra.longPress('#sortable-item', { duration: 1500 });
1231
+ * ```
1232
+ */
1233
+ longPress(target: ElementTarget, options?: LongPressOptions | number): Promise<void>;
1234
+ /**
1235
+ * Presses a specific keyboard key into the active document element.
1236
+ *
1237
+ * @param key Key name to press (e.g. 'Enter', 'Tab', 'Escape', 'Backspace').
1238
+ * @example
1239
+ * ```ts
1240
+ * await Spectra.pressKey('Enter');
1241
+ * ```
1242
+ */
1243
+ pressKey(key: KeyOption | string): Promise<void>;
1244
+ /**
1245
+ * Pauses test execution for the specified number of milliseconds.
1246
+ *
1247
+ * @param ms Milliseconds to wait.
1248
+ * @example
1249
+ * ```ts
1250
+ * await Spectra.wait(1000);
1251
+ * ```
1252
+ */
1253
+ wait(ms: number): Promise<void>;
1254
+ /**
1255
+ * Waits for the specified element to appear and exist in the DOM.
1256
+ *
1257
+ * @param target Target element selector or proxy.
1258
+ * @param timeoutMs Maximum time to wait in milliseconds (default: 5000ms).
1259
+ * @example
1260
+ * ```ts
1261
+ * await Spectra.waitForElement('#dynamic-content', 10000);
1262
+ * ```
1263
+ */
1264
+ waitForElement(target: ElementTarget, timeoutMs?: number): Promise<void>;
1265
+ /**
1266
+ * Direct access to browser context commands and page assertions.
1267
+ */
1268
+ browser: SpectraBrowserBridge;
1269
+ /**
1270
+ * Intercepts and mocks HTTP network requests matching the specified pattern or options.
1271
+ *
1272
+ * @param patternOrOptions URL pattern string or structured intercept configuration object.
1273
+ * @param method HTTP method (GET, POST, etc.) when pattern string is used.
1274
+ * @param fixture Mock response payload.
1275
+ * @param options Additional response options (status code, custom headers).
1276
+ * @example
1277
+ * ```ts
1278
+ * const mock = await Spectra.intercept('/api/v1/profile', 'GET', { name: 'Admin', role: 'root' });
1279
+ * ```
1280
+ */
1281
+ intercept(patternOrOptions: string | {
1282
+ url: string;
1283
+ method?: string;
1284
+ response?: unknown;
1285
+ }, method?: string, fixture?: unknown, options?: {
1286
+ statusCode?: number;
1287
+ headers?: Record<string, string>;
1288
+ }): Promise<MockInterceptHandle>;
1289
+ /**
1290
+ * Clears and resets all active CDP network interception rules.
1291
+ *
1292
+ * @example
1293
+ * ```ts
1294
+ * Spectra.clearMocks();
1295
+ * ```
1296
+ */
1297
+ clearMocks(): void;
1298
+ }