ex-pw 0.0.1

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.
@@ -0,0 +1,1116 @@
1
+ import * as playwright_test from 'playwright/test';
2
+ import { ExpectMatcherState, Locator, TestType, Page, APIResponse } from '@playwright/test';
3
+ import { ZodSchema } from 'zod';
4
+
5
+ interface ToBeClickableOptions {
6
+ timeout?: number;
7
+ }
8
+ /**
9
+ * Asserts that an element is in a clickable state.
10
+ * Uses Playwright's `click({ trial: true })` which performs all actionability checks
11
+ * without actually clicking - including visibility, enabled state, and not being obscured.
12
+ *
13
+ * @example
14
+ * await expect(page.getByRole('button')).toBeClickable();
15
+ * await expect(page.getByRole('button')).toBeClickable({ timeout: 5000 });
16
+ */
17
+ declare function toBeClickable(this: ExpectMatcherState, locator: Locator, options?: ToBeClickableOptions): Promise<{
18
+ pass: boolean;
19
+ message: () => string;
20
+ name: string;
21
+ }>;
22
+
23
+ interface ToBeCheckableOptions {
24
+ timeout?: number;
25
+ }
26
+ /**
27
+ * Asserts that a checkbox or radio button is in a checkable state.
28
+ * Uses Playwright's `check({ trial: true })` which performs all actionability checks
29
+ * without actually checking - including visibility, enabled state, and not being obscured.
30
+ *
31
+ * @example
32
+ * await expect(page.getByRole('checkbox')).toBeCheckable();
33
+ * await expect(page.getByRole('radio')).toBeCheckable({ timeout: 5000 });
34
+ */
35
+ declare function toBeCheckable(this: ExpectMatcherState, locator: Locator, options?: ToBeCheckableOptions): Promise<{
36
+ pass: boolean;
37
+ message: () => string;
38
+ name: string;
39
+ }>;
40
+
41
+ interface ToBeRequiredOptions {
42
+ timeout?: number;
43
+ intervals?: number[];
44
+ }
45
+ /**
46
+ * Asserts that a form element is required.
47
+ * Checks multiple conditions for comprehensive coverage:
48
+ * - `required` HTML attribute
49
+ * - `aria-required="true"` attribute
50
+ * - Element's `required` property (covers dynamic JS-set required)
51
+ *
52
+ * @example
53
+ * await expect(page.getByLabel('Email')).toBeRequired();
54
+ * await expect(page.getByLabel('Optional')).not.toBeRequired();
55
+ */
56
+ declare function toBeRequired(this: ExpectMatcherState, locator: Locator, options?: ToBeRequiredOptions): Promise<{
57
+ pass: boolean;
58
+ message: () => string;
59
+ name: string;
60
+ }>;
61
+
62
+ interface ToBeInvalidOptions {
63
+ timeout?: number;
64
+ intervals?: number[];
65
+ }
66
+ /**
67
+ * Asserts that a form element is in an invalid validation state.
68
+ * Checks multiple validation indicators:
69
+ * - `aria-invalid="true"` attribute
70
+ * - `element.validity.valid === false` (native validation)
71
+ * - Framework-specific classes: ng-invalid (Angular), is-invalid (Bootstrap), etc.
72
+ *
73
+ * @example
74
+ * await expect(page.getByLabel('Email')).toBeInvalid();
75
+ * await expect(page.getByLabel('Valid Field')).not.toBeInvalid();
76
+ */
77
+ declare function toBeInvalid(this: ExpectMatcherState, locator: Locator, options?: ToBeInvalidOptions): Promise<{
78
+ pass: boolean;
79
+ message: () => string;
80
+ name: string;
81
+ }>;
82
+
83
+ interface ToBeValidOptions {
84
+ timeout?: number;
85
+ intervals?: number[];
86
+ }
87
+ /**
88
+ * Asserts that a form element is in a valid validation state.
89
+ * This is the opposite of toBeInvalid - checks that:
90
+ * - `aria-invalid` is NOT "true"
91
+ * - `element.validity.valid === true` (native validation)
92
+ * - No framework-specific invalid classes present
93
+ *
94
+ * @example
95
+ * await expect(page.getByLabel('Email')).toBeValid();
96
+ * await expect(page.getByLabel('Invalid Field')).not.toBeValid();
97
+ */
98
+ declare function toBeValid(this: ExpectMatcherState, locator: Locator, options?: ToBeValidOptions): Promise<{
99
+ pass: boolean;
100
+ message: () => string;
101
+ name: string;
102
+ }>;
103
+
104
+ interface CountOptions {
105
+ timeout?: number;
106
+ intervals?: number[];
107
+ }
108
+ /**
109
+ * Asserts that a locator matches more than N elements.
110
+ *
111
+ * @example
112
+ * await expect(page.locator('.item')).toHaveCountGreaterThan(3);
113
+ * await expect(page.locator('.item')).toHaveCountGreaterThan(0, { timeout: 5000 });
114
+ */
115
+ declare function toHaveCountGreaterThan(this: ExpectMatcherState, locator: Locator, count: number, options?: CountOptions): Promise<{
116
+ pass: boolean;
117
+ message: () => string;
118
+ name: string;
119
+ expected: string;
120
+ actual: number;
121
+ }>;
122
+ /**
123
+ * Asserts that a locator matches N or more elements.
124
+ *
125
+ * @example
126
+ * await expect(page.locator('.item')).toHaveCountGreaterThanOrEqual(5);
127
+ */
128
+ declare function toHaveCountGreaterThanOrEqual(this: ExpectMatcherState, locator: Locator, count: number, options?: CountOptions): Promise<{
129
+ pass: boolean;
130
+ message: () => string;
131
+ name: string;
132
+ expected: string;
133
+ actual: number;
134
+ }>;
135
+ /**
136
+ * Asserts that a locator matches fewer than N elements.
137
+ *
138
+ * @example
139
+ * await expect(page.locator('.item')).toHaveCountLessThan(10);
140
+ */
141
+ declare function toHaveCountLessThan(this: ExpectMatcherState, locator: Locator, count: number, options?: CountOptions): Promise<{
142
+ pass: boolean;
143
+ message: () => string;
144
+ name: string;
145
+ expected: string;
146
+ actual: number;
147
+ }>;
148
+ /**
149
+ * Asserts that a locator matches N or fewer elements.
150
+ *
151
+ * @example
152
+ * await expect(page.locator('.item')).toHaveCountLessThanOrEqual(5);
153
+ */
154
+ declare function toHaveCountLessThanOrEqual(this: ExpectMatcherState, locator: Locator, count: number, options?: CountOptions): Promise<{
155
+ pass: boolean;
156
+ message: () => string;
157
+ name: string;
158
+ expected: string;
159
+ actual: number;
160
+ }>;
161
+
162
+ // Options interfaces
163
+ interface TimeoutOptions {
164
+ timeout?: number;
165
+ intervals?: number[];
166
+ }
167
+
168
+ interface ToHaveCookieOptions$1 {
169
+ value?: string | RegExp;
170
+ domain?: string;
171
+ timeout?: number;
172
+ intervals?: number[];
173
+ }
174
+
175
+ interface ToHaveStorageOptions {
176
+ value?: unknown;
177
+ timeout?: number;
178
+ intervals?: number[];
179
+ }
180
+
181
+ interface ToHaveNoErrorsOptions$1 {
182
+ ignore?: RegExp;
183
+ }
184
+
185
+ interface ToBeURLAsymmetricOptions {
186
+ protocol?: string | string[];
187
+ }
188
+
189
+ interface ToHaveRequestOptions$1 {
190
+ method?: string;
191
+ status?: number;
192
+ url?: string | RegExp;
193
+ timeout?: number;
194
+ intervals?: number[];
195
+ }
196
+
197
+ type ConsoleMessageType$1 = 'log' | 'debug' | 'info' | 'error' | 'warning' | 'dir' | 'dirxml' | 'table' | 'trace' | 'clear' | 'startGroup' | 'startGroupCollapsed' | 'endGroup' | 'assert' | 'profile' | 'profileEnd' | 'count' | 'timeEnd';
198
+
199
+ interface ToHaveConsoleMessageOptions$1 {
200
+ type?: ConsoleMessageType$1;
201
+ text?: string | RegExp;
202
+ timeout?: number;
203
+ intervals?: number[];
204
+ }
205
+
206
+ interface ToHavePageErrorOptions$1 {
207
+ message?: string | RegExp;
208
+ name?: string;
209
+ timeout?: number;
210
+ intervals?: number[];
211
+ }
212
+
213
+ // Locator matchers
214
+ interface ExPwLocatorMatchers {
215
+ /**
216
+ * Asserts that an element is in a clickable state.
217
+ * Uses Playwright's `click({ trial: true })` which performs all actionability checks.
218
+ */
219
+ toBeClickable(options?: TimeoutOptions): Promise<void>;
220
+
221
+ /**
222
+ * Asserts that a checkbox or radio button is in a checkable state.
223
+ * Uses Playwright's `check({ trial: true })` which performs all actionability checks.
224
+ */
225
+ toBeCheckable(options?: TimeoutOptions): Promise<void>;
226
+
227
+ /**
228
+ * Asserts that a form element is required.
229
+ * Checks `required` attribute, `aria-required`, and element's required property.
230
+ */
231
+ toBeRequired(options?: TimeoutOptions): Promise<void>;
232
+
233
+ /**
234
+ * Asserts that a form element is in an invalid validation state.
235
+ * Checks `aria-invalid`, native validity, and framework classes (ng-invalid, is-invalid, etc).
236
+ */
237
+ toBeInvalid(options?: TimeoutOptions): Promise<void>;
238
+
239
+ /**
240
+ * Asserts that a form element is in a valid validation state.
241
+ */
242
+ toBeValid(options?: TimeoutOptions): Promise<void>;
243
+
244
+ /**
245
+ * Asserts that a locator matches more than N elements.
246
+ */
247
+ toHaveCountGreaterThan(count: number, options?: TimeoutOptions): Promise<void>;
248
+
249
+ /**
250
+ * Asserts that a locator matches N or more elements.
251
+ */
252
+ toHaveCountGreaterThanOrEqual(count: number, options?: TimeoutOptions): Promise<void>;
253
+
254
+ /**
255
+ * Asserts that a locator matches fewer than N elements.
256
+ */
257
+ toHaveCountLessThan(count: number, options?: TimeoutOptions): Promise<void>;
258
+
259
+ /**
260
+ * Asserts that a locator matches N or fewer elements.
261
+ */
262
+ toHaveCountLessThanOrEqual(count: number, options?: TimeoutOptions): Promise<void>;
263
+
264
+ /**
265
+ * Asserts that an element has a specific width.
266
+ */
267
+ toHaveWidth(expected: number, options?: TimeoutOptions): Promise<void>;
268
+
269
+ /**
270
+ * Asserts that an element has a specific height.
271
+ */
272
+ toHaveHeight(expected: number, options?: TimeoutOptions): Promise<void>;
273
+
274
+ /**
275
+ * Asserts that an element has a specific size.
276
+ */
277
+ toHaveSize(width: number, height: number, options?: TimeoutOptions): Promise<void>;
278
+
279
+ /**
280
+ * Asserts that an img element has loaded its image (complete and naturalWidth > 0).
281
+ */
282
+ toHaveLoadedImage(options?: TimeoutOptions): Promise<void>;
283
+ }
284
+
285
+
286
+
287
+
288
+ // Page matchers
289
+ interface ExPwPageMatchers {
290
+ /**
291
+ * Asserts that the page's context has a specific cookie.
292
+ */
293
+ toHaveCookie(name: string, options?: ToHaveCookieOptions$1): Promise<void>;
294
+
295
+ /**
296
+ * Asserts that localStorage contains a specific key.
297
+ */
298
+ toHaveLocalStorage(key: string, options?: ToHaveStorageOptions): Promise<void>;
299
+
300
+ /**
301
+ * Asserts that sessionStorage contains a specific key.
302
+ */
303
+ toHaveSessionStorage(key: string, options?: ToHaveStorageOptions): Promise<void>;
304
+
305
+ /**
306
+ * Asserts that the clipboard has specific text.
307
+ */
308
+ toHaveClipboardText(expected: string | RegExp, options?: TimeoutOptions): Promise<void>;
309
+
310
+ /**
311
+ * Asserts that the page has made a network request matching the specified criteria.
312
+ * Uses `page.requests()` to check already captured requests.
313
+ *
314
+ * **Limitations:**
315
+ * - Only returns up to 100 most recent requests (Playwright limit)
316
+ * - Does not wait for future requests; only checks already captured ones
317
+ */
318
+ toHaveRequest(options?: ToHaveRequestOptions$1): Promise<void>;
319
+
320
+ /**
321
+ * Asserts that the page has a console message matching the specified criteria.
322
+ * Uses `page.consoleMessages()` to check already captured console output.
323
+ *
324
+ * **Limitations:**
325
+ * - Only returns up to 200 most recent console messages (Playwright limit)
326
+ * - Does not wait for future messages; only checks already captured ones
327
+ */
328
+ toHaveConsoleMessage(options?: ToHaveConsoleMessageOptions$1): Promise<void>;
329
+
330
+ /**
331
+ * Asserts that the page has encountered a JavaScript error matching the specified criteria.
332
+ * Uses `page.pageErrors()` to check already captured uncaught exceptions.
333
+ *
334
+ * **Limitations:**
335
+ * - Only returns up to 200 most recent page errors (Playwright limit)
336
+ * - Does not wait for future errors; only checks already captured ones
337
+ */
338
+ toHavePageError(options?: ToHavePageErrorOptions$1): Promise<void>;
339
+ }
340
+
341
+
342
+
343
+ // Test matchers (when T is test object)
344
+ interface ExPwTestMatchers {
345
+ /**
346
+ * Asserts that there are no test errors (useful with soft assertions).
347
+ * Pass the `test` object and it calls `.info()` internally to check for errors.
348
+ *
349
+ * @example
350
+ * await expect(test).toHaveNoErrors();
351
+ */
352
+ toHaveNoErrors(options?: ToHaveNoErrorsOptions$1): void;
353
+ }
354
+
355
+ // API matchers
356
+ interface ExPwAPIMatchers {
357
+ /**
358
+ * Asserts that an API response body matches the expected JSON.
359
+ */
360
+ toMatchJSON(expected: unknown): Promise<void>;
361
+
362
+ /**
363
+ * Asserts that an API response body matches a Zod schema.
364
+ */
365
+ toMatchSchema(schema: ZodSchema): Promise<void>;
366
+
367
+ /**
368
+ * Asserts that an API response has a specific HTTP status code.
369
+ */
370
+ toHaveStatus(expected: number | { min: number; max: number }): Promise<void>;
371
+
372
+ /**
373
+ * Asserts that an API response has a specific header.
374
+ */
375
+ toHaveHeader(name: string, options?: { value?: string | RegExp }): Promise<void>;
376
+
377
+ /**
378
+ * Asserts that an API request/response responds within a specified timeout.
379
+ * Expects a Promise or function returning a Promise.
380
+ */
381
+ toRespondWithin(timeout: number): Promise<void>;
382
+ }
383
+
384
+
385
+ // General matchers
386
+ interface ToBeSortedOptions$1 {
387
+ descending?: boolean;
388
+ /**
389
+ * For array of objects, extract value using this key or function.
390
+ */
391
+ key?: string | ((item: any) => any);
392
+ /**
393
+ * When used with Locator, use allTextContents() instead of allInnerTexts().
394
+ * @default false
395
+ */
396
+ useTextContent?: boolean;
397
+ /**
398
+ * Whether to parse values as numbers for comparison.
399
+ * @default false
400
+ */
401
+ compareAsNumbers?: boolean;
402
+ timeout?: number;
403
+ intervals?: number[];
404
+ }
405
+
406
+
407
+ // Asymmetric matchers (added to expect object)
408
+ interface ExPwAsymmetricMatchers {
409
+ /**
410
+ * Asymmetric matcher that checks if a number is within a specified range.
411
+ */
412
+ toBeWithinRange(min: number, max: number): any;
413
+
414
+ /**
415
+ * Asymmetric matcher that checks if a string is a valid UUID.
416
+ */
417
+ toBeUUID(version?: 'v1' | 'v4' | 'v5'): any;
418
+
419
+ /**
420
+ * Asymmetric matcher that checks if a string is a valid ISO 8601 date.
421
+ */
422
+ toBeISODate(): any;
423
+
424
+ /**
425
+ * Asymmetric matcher that checks if a string matches a date format.
426
+ */
427
+ toBeDateString(format: string): any;
428
+
429
+ /**
430
+ * Asymmetric matcher that checks if a string is a valid email address.
431
+ */
432
+ toBeEmail(): any;
433
+
434
+ /**
435
+ * Asymmetric matcher that checks if a string is a valid URL.
436
+ */
437
+ toBeURL(options?: ToBeURLAsymmetricOptions): any;
438
+
439
+ /**
440
+ * Matches any string that is valid JSON.
441
+ */
442
+ toBeJSON(): any;
443
+
444
+ /**
445
+ * Matches string starting with expected prefix
446
+ */
447
+ toStartWith(expected: string): any;
448
+
449
+ /**
450
+ * Matches string ending with expected suffix
451
+ */
452
+ toEndWith(expected: string): any;
453
+
454
+ /**
455
+ * Matches any string that is uppercase
456
+ */
457
+ toBeUpperCase(): any;
458
+
459
+ /**
460
+ * Matches any string that is lowercase
461
+ */
462
+ toBeLowerCase(): any;
463
+
464
+ /**
465
+ * Matches any string that is kebab-case
466
+ */
467
+ toBeKebabCase(): any;
468
+
469
+ /**
470
+ * Matches any string that is camelCase
471
+ */
472
+ toBeCamelCase(): any;
473
+
474
+ /**
475
+ * Matches any string that is snake_case
476
+ */
477
+ toBeSnakeCase(): any;
478
+
479
+ /**
480
+ * Matches any string that is PascalCase
481
+ */
482
+ toBePascalCase(): any;
483
+ }
484
+
485
+
486
+ // Augment Playwright's types
487
+ declare module '@playwright/test' {
488
+ interface Matchers<R, T = unknown> {
489
+ // Locator matchers (when T is Locator)
490
+ toBeClickable(options?: TimeoutOptions): Promise<R>;
491
+ toBeCheckable(options?: TimeoutOptions): Promise<R>;
492
+ toBeRequired(options?: TimeoutOptions): Promise<R>;
493
+ toBeInvalid(options?: TimeoutOptions): Promise<R>;
494
+ toBeValid(options?: TimeoutOptions): Promise<R>;
495
+ toHaveCountGreaterThan(count: number, options?: TimeoutOptions): Promise<R>;
496
+ toHaveCountGreaterThanOrEqual(count: number, options?: TimeoutOptions): Promise<R>;
497
+ toHaveCountLessThan(count: number, options?: TimeoutOptions): Promise<R>;
498
+ toHaveCountLessThanOrEqual(count: number, options?: TimeoutOptions): Promise<R>;
499
+ toHaveWidth(expected: number, options?: TimeoutOptions): Promise<R>;
500
+ toHaveHeight(expected: number, options?: TimeoutOptions): Promise<R>;
501
+ toHaveSize(width: number, height: number, options?: TimeoutOptions): Promise<R>;
502
+ toHaveLoadedImage(options?: TimeoutOptions): Promise<R>;
503
+
504
+
505
+ // Page matchers (when T is Page)
506
+ toHaveCookie(name: string, options?: ToHaveCookieOptions$1): Promise<R>;
507
+ toHaveLocalStorage(key: string, options?: ToHaveStorageOptions): Promise<R>;
508
+ toHaveSessionStorage(key: string, options?: ToHaveStorageOptions): Promise<R>;
509
+ toHaveClipboardText(expected: string | RegExp, options?: TimeoutOptions): Promise<R>;
510
+ toHaveRequest(options?: ToHaveRequestOptions$1): Promise<R>;
511
+ toHaveConsoleMessage(options?: ToHaveConsoleMessageOptions$1): Promise<R>;
512
+ toHavePageError(options?: ToHavePageErrorOptions$1): Promise<R>;
513
+
514
+
515
+ // TestInfo matchers (when T is TestInfo)
516
+ toHaveNoErrors(options?: ToHaveNoErrorsOptions$1): R;
517
+
518
+ // API matchers (when T is APIResponse)
519
+ toMatchJSON(expected: unknown): Promise<R>;
520
+ toMatchSchema(schema: ZodSchema): Promise<R>;
521
+ toHaveStatus(expected: number | { min: number; max: number }): Promise<R>;
522
+ toHaveHeader(name: string, options?: { value?: string | RegExp }): Promise<R>;
523
+ toRespondWithin(timeout: number): Promise<R>;
524
+
525
+ // General matchers (when T is Array or Locator)
526
+ toBeSorted(options?: ToBeSortedOptions$1): Promise<R>;
527
+
528
+ // Asymmetric matchers available as symmetric matchers
529
+ toBeWithinRange(min: number, max: number): R;
530
+ toBeUUID(version?: 'v1' | 'v4' | 'v5'): R;
531
+ toBeISODate(): R;
532
+ toBeDateString(format: string): R;
533
+ toBeEmail(): R;
534
+ toBeURL(options?: ToBeURLAsymmetricOptions): R;
535
+ toBeJSON(): R;
536
+ toStartWith(expected: string): R;
537
+ toEndWith(expected: string): R;
538
+ toBeUpperCase(): R;
539
+ toBeLowerCase(): R;
540
+ toBeKebabCase(): R;
541
+ toBeCamelCase(): R;
542
+ toBeSnakeCase(): R;
543
+ toBePascalCase(): R;
544
+ }
545
+
546
+
547
+ interface Expect extends ExPwAsymmetricMatchers { }
548
+ }
549
+
550
+ declare function toHaveWidth(this: ExpectMatcherState, locator: Locator, expected: number, options?: TimeoutOptions): Promise<{
551
+ message: () => string;
552
+ pass: boolean;
553
+ }>;
554
+
555
+ declare function toHaveHeight(this: ExpectMatcherState, locator: Locator, expected: number, options?: TimeoutOptions): Promise<{
556
+ message: () => string;
557
+ pass: boolean;
558
+ }>;
559
+
560
+ declare function toHaveSize(this: ExpectMatcherState, locator: Locator, width: number, height: number, options?: TimeoutOptions): Promise<{
561
+ message: () => string;
562
+ pass: boolean;
563
+ }>;
564
+
565
+ declare function toHaveLoadedImage(this: ExpectMatcherState, locator: Locator, options?: TimeoutOptions): Promise<{
566
+ message: () => string;
567
+ pass: boolean;
568
+ }>;
569
+
570
+ declare const locatorMatchers: {
571
+ toBeClickable: typeof toBeClickable;
572
+ toBeCheckable: typeof toBeCheckable;
573
+ toBeRequired: typeof toBeRequired;
574
+ toBeInvalid: typeof toBeInvalid;
575
+ toBeValid: typeof toBeValid;
576
+ toHaveCountGreaterThan: typeof toHaveCountGreaterThan;
577
+ toHaveCountGreaterThanOrEqual: typeof toHaveCountGreaterThanOrEqual;
578
+ toHaveCountLessThan: typeof toHaveCountLessThan;
579
+ toHaveCountLessThanOrEqual: typeof toHaveCountLessThanOrEqual;
580
+ toHaveWidth: typeof toHaveWidth;
581
+ toHaveHeight: typeof toHaveHeight;
582
+ toHaveSize: typeof toHaveSize;
583
+ toHaveLoadedImage: typeof toHaveLoadedImage;
584
+ };
585
+
586
+ interface ToHaveNoErrorsOptions {
587
+ ignore?: RegExp;
588
+ }
589
+ /**
590
+ * Asserts that there are no test errors (useful with soft assertions).
591
+ * Pass the `test` object and it will call `.info()` internally to check for errors.
592
+ *
593
+ * @example
594
+ * await expect.soft(page.getByTestId('status')).toHaveText('Success');
595
+ * await expect.soft(page.getByTestId('eta')).toHaveText('1 day');
596
+ * await expect(test).toHaveNoErrors();
597
+ *
598
+ * @example
599
+ * // Ignore specific errors
600
+ * await expect(test).toHaveNoErrors({ ignore: /Warning:/ });
601
+ */
602
+ declare function toHaveNoErrors(this: ExpectMatcherState, testObject: TestType<any, any>, options?: ToHaveNoErrorsOptions): {
603
+ pass: boolean;
604
+ message: () => string;
605
+ name: string;
606
+ expected: number;
607
+ actual: number;
608
+ };
609
+
610
+ interface ToHaveCookieOptions {
611
+ value?: string | RegExp;
612
+ domain?: string;
613
+ timeout?: number;
614
+ intervals?: number[];
615
+ }
616
+ /**
617
+ * Asserts that the page's context has a specific cookie.
618
+ * Optionally matches by value and/or domain.
619
+ *
620
+ * @example
621
+ * await expect(page).toHaveCookie('session');
622
+ * await expect(page).toHaveCookie('session', { value: 'abc123' });
623
+ * await expect(page).toHaveCookie('session', { value: /^abc/ });
624
+ * await expect(page).toHaveCookie('session', { domain: 'example.com' });
625
+ */
626
+ declare function toHaveCookie(this: ExpectMatcherState, page: Page, name: string, options?: ToHaveCookieOptions): Promise<{
627
+ pass: boolean;
628
+ message: () => string;
629
+ name: string;
630
+ expected: string | RegExp;
631
+ actual: string | undefined;
632
+ }>;
633
+
634
+ interface ToHaveLocalStorageOptions {
635
+ value?: unknown;
636
+ timeout?: number;
637
+ intervals?: number[];
638
+ }
639
+ /**
640
+ * Asserts that localStorage contains a specific key with optional value matching.
641
+ * Uses `page.context().storageState()` to retrieve localStorage.
642
+ *
643
+ * @example
644
+ * await expect(page).toHaveLocalStorage('authToken');
645
+ * await expect(page).toHaveLocalStorage('authToken', { value: 'secret' });
646
+ * await expect(page).toHaveLocalStorage('settings', { value: expect.objectContaining({ theme: 'dark' }) });
647
+ */
648
+ declare function toHaveLocalStorage(this: ExpectMatcherState, page: Page, key: string, options?: ToHaveLocalStorageOptions): Promise<{
649
+ pass: boolean;
650
+ message: () => string;
651
+ name: string;
652
+ expected: {};
653
+ actual: unknown;
654
+ }>;
655
+
656
+ interface ToHaveSessionStorageOptions {
657
+ value?: unknown;
658
+ timeout?: number;
659
+ intervals?: number[];
660
+ }
661
+ /**
662
+ * Asserts that sessionStorage contains a specific key with optional value matching.
663
+ * Note: sessionStorage is not included in storageState(), so this uses page.evaluate().
664
+ *
665
+ * @example
666
+ * await expect(page).toHaveSessionStorage('tempData');
667
+ * await expect(page).toHaveSessionStorage('cart', { value: expect.arrayContaining([{ id: 1 }]) });
668
+ */
669
+ declare function toHaveSessionStorage(this: ExpectMatcherState, page: Page, key: string, options?: ToHaveSessionStorageOptions): Promise<{
670
+ pass: boolean;
671
+ message: () => string;
672
+ name: string;
673
+ expected: {};
674
+ actual: unknown;
675
+ }>;
676
+
677
+ /**
678
+ * Asserts that the clipboard contains the expected text.
679
+ *
680
+ * @note This matcher requires clipboard permissions to be granted in the browser context.
681
+ * Make sure to set `permissions: ["clipboard-read"]` when launching the browser.
682
+ *
683
+ * @example
684
+ * ```ts
685
+ * // playwright.config.ts
686
+ * export default defineConfig({
687
+ * use: {
688
+ * permissions: ["clipboard-read"],
689
+ * },
690
+ * });
691
+ * ```
692
+ */
693
+ declare function toHaveClipboardText(this: ExpectMatcherState, page: Page, expected: string | RegExp, options?: TimeoutOptions): Promise<{
694
+ message: () => string;
695
+ pass: boolean;
696
+ }>;
697
+
698
+ interface ToHaveRequestOptions {
699
+ method?: string;
700
+ status?: number;
701
+ url?: string | RegExp;
702
+ timeout?: number;
703
+ intervals?: number[];
704
+ }
705
+ /**
706
+ * Asserts that the page has made a network request matching the specified criteria.
707
+ * Uses `page.requests()` with polling to wait for matching requests.
708
+ *
709
+ * **Limitations:**
710
+ * - Only returns up to 100 most recent requests (Playwright limit)
711
+ * - Requests may be garbage collected if not accessed promptly
712
+ * - Collected requests may have limited information available
713
+ *
714
+ * @example
715
+ * await expect(page).toHaveRequest({ url: /api\/users/ });
716
+ * await expect(page).toHaveRequest({ method: 'POST', url: /api\/login/ });
717
+ * await expect(page).toHaveRequest({ url: 'https://example.com/api', status: 200 });
718
+ */
719
+ declare function toHaveRequest(this: ExpectMatcherState, page: Page, options?: ToHaveRequestOptions): Promise<{
720
+ pass: boolean;
721
+ message: () => string;
722
+ name: string;
723
+ }>;
724
+
725
+ type ConsoleMessageType = 'log' | 'debug' | 'info' | 'error' | 'warning' | 'dir' | 'dirxml' | 'table' | 'trace' | 'clear' | 'startGroup' | 'startGroupCollapsed' | 'endGroup' | 'assert' | 'profile' | 'profileEnd' | 'count' | 'timeEnd';
726
+ interface ToHaveConsoleMessageOptions {
727
+ type?: ConsoleMessageType;
728
+ text?: string | RegExp;
729
+ timeout?: number;
730
+ intervals?: number[];
731
+ }
732
+ /**
733
+ * Asserts that the page has a console message matching the specified criteria.
734
+ * Uses `page.consoleMessages()` with polling to wait for matching messages.
735
+ *
736
+ * **Limitations:**
737
+ * - Only returns up to 200 most recent console messages (Playwright limit)
738
+ *
739
+ * @example
740
+ * await expect(page).toHaveConsoleMessage({ text: 'Hello' });
741
+ * await expect(page).toHaveConsoleMessage({ type: 'error' });
742
+ * await expect(page).toHaveConsoleMessage({ type: 'warning', text: /deprecated/ });
743
+ */
744
+ declare function toHaveConsoleMessage(this: ExpectMatcherState, page: Page, options?: ToHaveConsoleMessageOptions): Promise<{
745
+ pass: boolean;
746
+ message: () => string;
747
+ name: string;
748
+ }>;
749
+
750
+ interface ToHavePageErrorOptions {
751
+ message?: string | RegExp;
752
+ name?: string;
753
+ timeout?: number;
754
+ intervals?: number[];
755
+ }
756
+ /**
757
+ * Asserts that the page has encountered a JavaScript error matching the specified criteria.
758
+ * Uses `page.pageErrors()` with polling to wait for matching errors.
759
+ *
760
+ * **Limitations:**
761
+ * - Only returns up to 200 most recent page errors (Playwright limit)
762
+ * - Only captures uncaught exceptions in the page's JavaScript context
763
+ *
764
+ * @example
765
+ * await expect(page).toHavePageError();
766
+ * await expect(page).toHavePageError({ message: 'undefined is not a function' });
767
+ * await expect(page).toHavePageError({ message: /TypeError/, name: 'TypeError' });
768
+ */
769
+ declare function toHavePageError(this: ExpectMatcherState, page: Page, options?: ToHavePageErrorOptions): Promise<{
770
+ pass: boolean;
771
+ message: () => string;
772
+ name: string;
773
+ }>;
774
+
775
+ declare const pageMatchers: {
776
+ toHaveNoErrors: typeof toHaveNoErrors;
777
+ toHaveCookie: typeof toHaveCookie;
778
+ toHaveLocalStorage: typeof toHaveLocalStorage;
779
+ toHaveSessionStorage: typeof toHaveSessionStorage;
780
+ toHaveClipboardText: typeof toHaveClipboardText;
781
+ toHaveRequest: typeof toHaveRequest;
782
+ toHaveConsoleMessage: typeof toHaveConsoleMessage;
783
+ toHavePageError: typeof toHavePageError;
784
+ };
785
+
786
+ /**
787
+ * Asserts that an API response body matches the expected JSON.
788
+ * Supports asymmetric matchers like expect.toBeEmail(), expect.toBeUUID(), etc.
789
+ *
790
+ * @example
791
+ * const response = await request.get('/api/user');
792
+ * await expect(response).toMatchJSON({ id: 1, name: 'John' });
793
+ * await expect(response).toMatchJSON(expect.objectContaining({ id: 1 }));
794
+ * await expect(response).toMatchJSON({
795
+ * email: expect.toBeEmail(),
796
+ * id: expect.toBeUUID()
797
+ * });
798
+ */
799
+ declare function toMatchJSON(this: ExpectMatcherState, response: APIResponse, expected: unknown): Promise<{
800
+ pass: boolean;
801
+ message: () => string;
802
+ name: string;
803
+ expected: unknown;
804
+ actual: unknown;
805
+ }>;
806
+
807
+ /**
808
+ * Asserts that an API response body matches a Zod schema.
809
+ * Provides detailed validation error messages.
810
+ *
811
+ * @example
812
+ * import { z } from 'zod';
813
+ *
814
+ * const UserSchema = z.object({
815
+ * id: z.number(),
816
+ * name: z.string(),
817
+ * email: z.string().email(),
818
+ * });
819
+ *
820
+ * const response = await request.get('/api/user');
821
+ * await expect(response).toMatchSchema(UserSchema);
822
+ */
823
+ declare function toMatchSchema(this: ExpectMatcherState, response: APIResponse, schema: ZodSchema): Promise<{
824
+ pass: boolean;
825
+ message: () => string;
826
+ name: string;
827
+ expected: string;
828
+ actual: unknown;
829
+ }>;
830
+
831
+ /**
832
+ * Asserts that an API response has a specific HTTP status code.
833
+ * Supports exact match or range matching.
834
+ *
835
+ * @example
836
+ * await expect(response).toHaveStatus(200);
837
+ * await expect(response).toHaveStatus({ min: 200, max: 299 }); // Any 2xx
838
+ */
839
+ declare function toHaveStatus(this: ExpectMatcherState, response: APIResponse, expected: number | {
840
+ min: number;
841
+ max: number;
842
+ }): Promise<{
843
+ pass: boolean;
844
+ message: () => string;
845
+ name: string;
846
+ expected: string;
847
+ actual: number;
848
+ }>;
849
+
850
+ interface ToHaveHeaderOptions {
851
+ value?: string | RegExp;
852
+ }
853
+ /**
854
+ * Asserts that an API response has a specific header.
855
+ * Optionally matches by value.
856
+ *
857
+ * @example
858
+ * await expect(response).toHaveHeader('content-type');
859
+ * await expect(response).toHaveHeader('content-type', { value: 'application/json' });
860
+ * await expect(response).toHaveHeader('content-type', { value: /json/ });
861
+ */
862
+ declare function toHaveHeader(this: ExpectMatcherState, response: APIResponse, name: string, options?: ToHaveHeaderOptions): Promise<{
863
+ pass: boolean;
864
+ message: () => string;
865
+ name: string;
866
+ expected: string | RegExp;
867
+ actual: string | undefined;
868
+ }>;
869
+
870
+ declare function toRespondWithin(response: APIResponse | Promise<APIResponse> | (() => Promise<APIResponse>), timeout: number): Promise<{
871
+ message: () => string;
872
+ pass: boolean;
873
+ }>;
874
+
875
+ declare const apiMatchers: {
876
+ toMatchJSON: typeof toMatchJSON;
877
+ toMatchSchema: typeof toMatchSchema;
878
+ toHaveStatus: typeof toHaveStatus;
879
+ toHaveHeader: typeof toHaveHeader;
880
+ toRespondWithin: typeof toRespondWithin;
881
+ };
882
+
883
+ interface ToBeSortedOptions {
884
+ descending?: boolean;
885
+ /**
886
+ * For array of objects, extract value using this key or function.
887
+ */
888
+ key?: string | ((item: any) => any);
889
+ /**
890
+ * When used with Locator, specifies which method to use for extracting text.
891
+ * - false (default): uses allInnerTexts() - excludes hidden elements
892
+ * - true: uses allTextContents() - includes hidden elements
893
+ * @default false
894
+ */
895
+ useTextContent?: boolean;
896
+ /**
897
+ * Whether to parse values as numbers for comparison.
898
+ * @default false - compares as strings
899
+ */
900
+ compareAsNumbers?: boolean;
901
+ timeout?: number;
902
+ intervals?: number[];
903
+ }
904
+ /**
905
+ * Asserts that an array or locator elements are sorted.
906
+ *
907
+ * When used with a Locator, it extracts text from all matching elements
908
+ * using `allInnerTexts()` (default) or `allTextContents()`.
909
+ *
910
+ * @example
911
+ * // With arrays
912
+ * expect([1, 2, 3]).toBeSorted();
913
+ * expect(['c', 'b', 'a']).toBeSorted({ descending: true });
914
+ * expect([{ val: 1 }, { val: 2 }]).toBeSorted({ key: 'val' });
915
+ *
916
+ * @example
917
+ * // With Locators
918
+ * await expect(page.locator('.price')).toBeSorted({ compareAsNumbers: true });
919
+ * await expect(page.locator('.name')).toBeSorted({ descending: true });
920
+ */
921
+ declare function toBeSorted(this: ExpectMatcherState, received: Locator | any[], options?: ToBeSortedOptions): Promise<{
922
+ message: () => string;
923
+ pass: boolean;
924
+ }>;
925
+
926
+ declare const generalMatchers: {
927
+ toBeSorted: typeof toBeSorted;
928
+ };
929
+
930
+ declare function toBeWithinRange(received: unknown, min: number, max: number): {
931
+ message: () => string;
932
+ pass: boolean;
933
+ };
934
+
935
+ declare function toBeUUID(received: unknown, version?: 'v1' | 'v4' | 'v5'): {
936
+ message: () => string;
937
+ pass: boolean;
938
+ };
939
+
940
+ declare function toBeISODate(received: unknown): {
941
+ message: () => string;
942
+ pass: boolean;
943
+ };
944
+
945
+ declare function toBeDateString(received: unknown, format: string): {
946
+ message: () => string;
947
+ pass: boolean;
948
+ };
949
+
950
+ declare function toBeEmail(received: unknown): {
951
+ message: () => string;
952
+ pass: boolean;
953
+ };
954
+
955
+ interface ToBeURLOptions {
956
+ protocol?: string | string[];
957
+ }
958
+ declare function toBeURL(received: unknown, options?: ToBeURLOptions): {
959
+ message: () => string;
960
+ pass: boolean;
961
+ };
962
+
963
+ declare function toBeJSON(received: unknown): {
964
+ message: () => string;
965
+ pass: boolean;
966
+ };
967
+
968
+ declare function toStartWith(received: unknown, expected: string): {
969
+ message: () => string;
970
+ pass: boolean;
971
+ };
972
+
973
+ declare function toEndWith(received: unknown, expected: string): {
974
+ message: () => string;
975
+ pass: boolean;
976
+ };
977
+
978
+ declare function toBeUpperCase(received: unknown): {
979
+ message: () => string;
980
+ pass: boolean;
981
+ };
982
+
983
+ declare function toBeLowerCase(received: unknown): {
984
+ message: () => string;
985
+ pass: boolean;
986
+ };
987
+
988
+ declare function toBeKebabCase(received: unknown): {
989
+ message: () => string;
990
+ pass: boolean;
991
+ };
992
+
993
+ declare function toBeCamelCase(received: unknown): {
994
+ message: () => string;
995
+ pass: boolean;
996
+ };
997
+
998
+ declare function toBeSnakeCase(received: unknown): {
999
+ message: () => string;
1000
+ pass: boolean;
1001
+ };
1002
+
1003
+ declare function toBePascalCase(received: unknown): {
1004
+ message: () => string;
1005
+ pass: boolean;
1006
+ };
1007
+
1008
+ declare const asymmetricMatchers: {
1009
+ toBeWithinRange: typeof toBeWithinRange;
1010
+ toBeUUID: typeof toBeUUID;
1011
+ toBeISODate: typeof toBeISODate;
1012
+ toBeDateString: typeof toBeDateString;
1013
+ toBeEmail: typeof toBeEmail;
1014
+ toBeURL: typeof toBeURL;
1015
+ toBeJSON: typeof toBeJSON;
1016
+ toStartWith: typeof toStartWith;
1017
+ toEndWith: typeof toEndWith;
1018
+ toBeUpperCase: typeof toBeUpperCase;
1019
+ toBeLowerCase: typeof toBeLowerCase;
1020
+ toBeKebabCase: typeof toBeKebabCase;
1021
+ toBeCamelCase: typeof toBeCamelCase;
1022
+ toBeSnakeCase: typeof toBeSnakeCase;
1023
+ toBePascalCase: typeof toBePascalCase;
1024
+ };
1025
+
1026
+ declare const exPwExpect: playwright_test.Expect<{
1027
+ toBeWithinRange: typeof toBeWithinRange;
1028
+ toBeUUID: typeof toBeUUID;
1029
+ toBeISODate: typeof toBeISODate;
1030
+ toBeDateString: typeof toBeDateString;
1031
+ toBeEmail: typeof toBeEmail;
1032
+ toBeURL: typeof toBeURL;
1033
+ toBeJSON: typeof toBeJSON;
1034
+ toStartWith: typeof toStartWith;
1035
+ toEndWith: typeof toEndWith;
1036
+ toBeUpperCase: typeof toBeUpperCase;
1037
+ toBeLowerCase: typeof toBeLowerCase;
1038
+ toBeKebabCase: typeof toBeKebabCase;
1039
+ toBeCamelCase: typeof toBeCamelCase;
1040
+ toBeSnakeCase: typeof toBeSnakeCase;
1041
+ toBePascalCase: typeof toBePascalCase;
1042
+ toBeSorted: typeof toBeSorted;
1043
+ toMatchJSON: typeof toMatchJSON;
1044
+ toMatchSchema: typeof toMatchSchema;
1045
+ toHaveStatus: typeof toHaveStatus;
1046
+ toHaveHeader: typeof toHaveHeader;
1047
+ toRespondWithin: typeof toRespondWithin;
1048
+ toHaveNoErrors: typeof toHaveNoErrors;
1049
+ toHaveCookie: typeof toHaveCookie;
1050
+ toHaveLocalStorage: typeof toHaveLocalStorage;
1051
+ toHaveSessionStorage: typeof toHaveSessionStorage;
1052
+ toHaveClipboardText: typeof toHaveClipboardText;
1053
+ toHaveRequest: typeof toHaveRequest;
1054
+ toHaveConsoleMessage: typeof toHaveConsoleMessage;
1055
+ toHavePageError: typeof toHavePageError;
1056
+ toBeClickable: typeof toBeClickable;
1057
+ toBeCheckable: typeof toBeCheckable;
1058
+ toBeRequired: typeof toBeRequired;
1059
+ toBeInvalid: typeof toBeInvalid;
1060
+ toBeValid: typeof toBeValid;
1061
+ toHaveCountGreaterThan: typeof toHaveCountGreaterThan;
1062
+ toHaveCountGreaterThanOrEqual: typeof toHaveCountGreaterThanOrEqual;
1063
+ toHaveCountLessThan: typeof toHaveCountLessThan;
1064
+ toHaveCountLessThanOrEqual: typeof toHaveCountLessThanOrEqual;
1065
+ toHaveWidth: typeof toHaveWidth;
1066
+ toHaveHeight: typeof toHaveHeight;
1067
+ toHaveSize: typeof toHaveSize;
1068
+ toHaveLoadedImage: typeof toHaveLoadedImage;
1069
+ }>;
1070
+ declare const expect: typeof exPwExpect & ExPwAsymmetricMatchers;
1071
+ declare const exPw: {
1072
+ toBeWithinRange: typeof toBeWithinRange;
1073
+ toBeUUID: typeof toBeUUID;
1074
+ toBeISODate: typeof toBeISODate;
1075
+ toBeDateString: typeof toBeDateString;
1076
+ toBeEmail: typeof toBeEmail;
1077
+ toBeURL: typeof toBeURL;
1078
+ toBeJSON: typeof toBeJSON;
1079
+ toStartWith: typeof toStartWith;
1080
+ toEndWith: typeof toEndWith;
1081
+ toBeUpperCase: typeof toBeUpperCase;
1082
+ toBeLowerCase: typeof toBeLowerCase;
1083
+ toBeKebabCase: typeof toBeKebabCase;
1084
+ toBeCamelCase: typeof toBeCamelCase;
1085
+ toBeSnakeCase: typeof toBeSnakeCase;
1086
+ toBePascalCase: typeof toBePascalCase;
1087
+ toBeSorted: typeof toBeSorted;
1088
+ toMatchJSON: typeof toMatchJSON;
1089
+ toMatchSchema: typeof toMatchSchema;
1090
+ toHaveStatus: typeof toHaveStatus;
1091
+ toHaveHeader: typeof toHaveHeader;
1092
+ toRespondWithin: typeof toRespondWithin;
1093
+ toHaveNoErrors: typeof toHaveNoErrors;
1094
+ toHaveCookie: typeof toHaveCookie;
1095
+ toHaveLocalStorage: typeof toHaveLocalStorage;
1096
+ toHaveSessionStorage: typeof toHaveSessionStorage;
1097
+ toHaveClipboardText: typeof toHaveClipboardText;
1098
+ toHaveRequest: typeof toHaveRequest;
1099
+ toHaveConsoleMessage: typeof toHaveConsoleMessage;
1100
+ toHavePageError: typeof toHavePageError;
1101
+ toBeClickable: typeof toBeClickable;
1102
+ toBeCheckable: typeof toBeCheckable;
1103
+ toBeRequired: typeof toBeRequired;
1104
+ toBeInvalid: typeof toBeInvalid;
1105
+ toBeValid: typeof toBeValid;
1106
+ toHaveCountGreaterThan: typeof toHaveCountGreaterThan;
1107
+ toHaveCountGreaterThanOrEqual: typeof toHaveCountGreaterThanOrEqual;
1108
+ toHaveCountLessThan: typeof toHaveCountLessThan;
1109
+ toHaveCountLessThanOrEqual: typeof toHaveCountLessThanOrEqual;
1110
+ toHaveWidth: typeof toHaveWidth;
1111
+ toHaveHeight: typeof toHaveHeight;
1112
+ toHaveSize: typeof toHaveSize;
1113
+ toHaveLoadedImage: typeof toHaveLoadedImage;
1114
+ };
1115
+
1116
+ export { type ExPwAPIMatchers, type ExPwAsymmetricMatchers, type ExPwLocatorMatchers, type ExPwPageMatchers, type ExPwTestMatchers, type TimeoutOptions, type ToBeSortedOptions$1 as ToBeSortedOptions, type ToBeURLAsymmetricOptions, type ToHaveConsoleMessageOptions$1 as ToHaveConsoleMessageOptions, type ToHaveCookieOptions$1 as ToHaveCookieOptions, type ToHaveNoErrorsOptions$1 as ToHaveNoErrorsOptions, type ToHavePageErrorOptions$1 as ToHavePageErrorOptions, type ToHaveRequestOptions$1 as ToHaveRequestOptions, type ToHaveStorageOptions, apiMatchers, asymmetricMatchers, exPw as default, expect, generalMatchers, locatorMatchers, pageMatchers, toBeCamelCase, toBeCheckable, toBeClickable, toBeDateString, toBeEmail, toBeISODate, toBeInvalid, toBeJSON, toBeKebabCase, toBeLowerCase, toBePascalCase, toBeRequired, toBeSnakeCase, toBeSorted, toBeURL, toBeUUID, toBeUpperCase, toBeValid, toBeWithinRange, toEndWith, toHaveClipboardText, toHaveConsoleMessage, toHaveCookie, toHaveCountGreaterThan, toHaveCountGreaterThanOrEqual, toHaveCountLessThan, toHaveCountLessThanOrEqual, toHaveHeader, toHaveHeight, toHaveLoadedImage, toHaveLocalStorage, toHaveNoErrors, toHavePageError, toHaveRequest, toHaveSessionStorage, toHaveSize, toHaveStatus, toHaveWidth, toMatchJSON, toMatchSchema, toRespondWithin, toStartWith };