| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | 
					
						
							|  |  |  |  * Modifications copyright (c) Microsoft Corporation. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This source code is licensed under the MIT license found in the | 
					
						
							|  |  |  |  * LICENSE file in the root directory of this source tree. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-14 12:58:10 -07:00
										 |  |  | import type * as expect from 'expect'; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  | import type { ExpectedAssertionsErrors } from 'expect/build/types'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export declare type AsymmetricMatcher = Record<string, any>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export declare type Expect = { | 
					
						
							| 
									
										
										
										
											2021-06-07 08:02:01 -07:00
										 |  |  |   <T = unknown>(actual: T): PlaywrightTest.Matchers<T>; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // Sourced from node_modules/expect/build/types.d.ts
 | 
					
						
							|  |  |  |   assertions(arg0: number): void; | 
					
						
							|  |  |  |   extend(arg0: any): void; | 
					
						
							|  |  |  |   extractExpectedAssertionsErrors: () => ExpectedAssertionsErrors; | 
					
						
							|  |  |  |   getState(): expect.MatcherState; | 
					
						
							|  |  |  |   hasAssertions(): void; | 
					
						
							|  |  |  |   setState(state: Partial<expect.MatcherState>): void; | 
					
						
							|  |  |  |   any(expectedObject: any): AsymmetricMatcher; | 
					
						
							|  |  |  |   anything(): AsymmetricMatcher; | 
					
						
							|  |  |  |   arrayContaining(sample: Array<unknown>): AsymmetricMatcher; | 
					
						
							|  |  |  |   objectContaining(sample: Record<string, unknown>): AsymmetricMatcher; | 
					
						
							|  |  |  |   stringContaining(expected: string): AsymmetricMatcher; | 
					
						
							|  |  |  |   stringMatching(expected: string | RegExp): AsymmetricMatcher; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-25 17:27:39 +02:00
										 |  |  | type OverriddenExpectProperties =  | 
					
						
							|  |  |  | 'not' | | 
					
						
							|  |  |  | 'resolves' | | 
					
						
							|  |  |  | 'rejects' | | 
					
						
							|  |  |  | 'toMatchInlineSnapshot' | | 
					
						
							|  |  |  | 'toThrowErrorMatchingInlineSnapshot' | | 
					
						
							| 
									
										
										
										
											2021-07-27 20:26:12 -07:00
										 |  |  | 'toMatchSnapshot' | | 
					
						
							| 
									
										
										
										
											2021-06-25 17:27:39 +02:00
										 |  |  | 'toThrowErrorMatchingSnapshot'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  | declare global { | 
					
						
							| 
									
										
										
										
											2021-06-07 08:02:01 -07:00
										 |  |  |   export namespace PlaywrightTest { | 
					
						
							| 
									
										
										
										
											2021-06-25 17:27:39 +02:00
										 |  |  |     export interface Matchers<R> extends Omit<expect.Matchers<R>, OverriddenExpectProperties> { | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       /** | 
					
						
							|  |  |  |        * If you know how to test something, `.not` lets you test its opposite. | 
					
						
							|  |  |  |        */ | 
					
						
							| 
									
										
										
										
											2021-06-07 08:02:01 -07:00
										 |  |  |       not: PlaywrightTest.Matchers<R>; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       /** | 
					
						
							|  |  |  |        * Use resolves to unwrap the value of a fulfilled promise so any other | 
					
						
							|  |  |  |        * matcher can be chained. If the promise is rejected the assertion fails. | 
					
						
							|  |  |  |        */ | 
					
						
							| 
									
										
										
										
											2021-06-07 08:02:01 -07:00
										 |  |  |       resolves: PlaywrightTest.Matchers<Promise<R>>; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       /** | 
					
						
							|  |  |  |       * Unwraps the reason of a rejected promise so any other matcher can be chained. | 
					
						
							|  |  |  |       * If the promise is fulfilled the assertion fails. | 
					
						
							|  |  |  |       */ | 
					
						
							| 
									
										
										
										
											2021-06-07 08:02:01 -07:00
										 |  |  |       rejects: PlaywrightTest.Matchers<Promise<R>>; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       /** | 
					
						
							|  |  |  |        * Match snapshot | 
					
						
							|  |  |  |        */ | 
					
						
							| 
									
										
										
										
											2021-06-24 02:08:02 -07:00
										 |  |  |       toMatchSnapshot(options: { | 
					
						
							|  |  |  |         name: string, | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |         threshold?: number | 
					
						
							|  |  |  |       }): R; | 
					
						
							|  |  |  |       /** | 
					
						
							|  |  |  |        * Match snapshot | 
					
						
							|  |  |  |        */ | 
					
						
							|  |  |  |       toMatchSnapshot(name: string, options?: { | 
					
						
							|  |  |  |         threshold?: number | 
					
						
							|  |  |  |       }): R; | 
					
						
							| 
									
										
										
										
											2021-07-27 20:26:12 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |       /** | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |        * Asserts input is checked. | 
					
						
							| 
									
										
										
										
											2021-07-27 20:26:12 -07:00
										 |  |  |        */ | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |       toBeChecked(options?: { timeout?: number }): Promise<R>; | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |       /** | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |        * Asserts input is disabled. | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  |        */ | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |       toBeDisabled(options?: { timeout?: number }): Promise<R>; | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |       /** | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |        * Asserts input is editable. | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  |        */ | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |       toBeEditable(options?: { timeout?: number }): Promise<R>; | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |       /** | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |        * Asserts given DOM node or input has no text content or no input value. | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  |        */ | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |       toBeEmpty(options?: { timeout?: number }): Promise<R>; | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |       /** | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |        * Asserts input is enabled. | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  |        */ | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |       toBeEnabled(options?: { timeout?: number }): Promise<R>; | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |       /** | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |        * Asserts given DOM is a focused (active) in document. | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  |        */ | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |       toBeFocused(options?: { timeout?: number }): Promise<R>; | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |       /** | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |        * Asserts given DOM node is hidden or detached from DOM. | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  |        */ | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |       toBeHidden(options?: { timeout?: number }): Promise<R>; | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |       /** | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |        * Asserts given DOM node visible on the screen. | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  |        */ | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |       toBeVisible(options?: { timeout?: number }): Promise<R>; | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |       /** | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |        * Asserts given select option is selected | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  |        */ | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |       toBeSelected(options?: { timeout?: number }): Promise<R>; | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |       /** | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |        * Asserts element's text content matches given pattern or contains given substring. | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  |        */ | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |       toContainText(expected: string, options?: { timeout?: number, useInnerText?: boolean }): Promise<R>; | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |       /** | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |        * Asserts element's attributes `name` matches expected value. | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  |        */ | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |       toHaveAttr(expected: string | RegExp, name: string, options?: { timeout?: number }): Promise<R>; | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |       /** | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |        * Asserts that DOM node has a given CSS class. | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  |        */ | 
					
						
							| 
									
										
										
										
											2021-07-29 07:33:19 -07:00
										 |  |  |       toHaveClass(className: string | RegExp | string[], options?: { timeout?: number }): Promise<R>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       /** | 
					
						
							|  |  |  |        * Asserts number of DOM nodes matching given locator. | 
					
						
							|  |  |  |        */ | 
					
						
							|  |  |  |       toHaveCount(expected: number, options?: { timeout?: number }): Promise<R>; | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |       /** | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |        * Asserts element's computed CSS property `name` matches expected value. | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  |        */ | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |       toHaveCSS(expected: string | RegExp, name: string, options?: { timeout?: number }): Promise<R>; | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |       /** | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |        * Asserts element's data attribute data-`name` matches expected value. | 
					
						
							| 
									
										
										
										
											2021-07-28 12:07:11 -07:00
										 |  |  |        */ | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |       toHaveData(expected: string | RegExp, name: string, options?: { timeout?: number }): Promise<R>; | 
					
						
							| 
									
										
										
										
											2021-07-28 15:44:44 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |       /** | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |        * Asserts element's `id` attribute matches expected value. | 
					
						
							| 
									
										
										
										
											2021-07-28 15:44:44 -07:00
										 |  |  |        */ | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |       toHaveId(expected: string | RegExp, options?: { timeout?: number }): Promise<R>; | 
					
						
							| 
									
										
										
										
											2021-07-28 15:44:44 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |       /** | 
					
						
							|  |  |  |        * Asserts JavaScript object that corresponds to the Node has a property with given value. | 
					
						
							|  |  |  |        */ | 
					
						
							|  |  |  |       toHaveProp(name: string, value: any, options?: { timeout?: number }): Promise<R>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       /** | 
					
						
							| 
									
										
										
										
											2021-07-29 07:33:19 -07:00
										 |  |  |        * Asserts element's text content. | 
					
						
							| 
									
										
										
										
											2021-07-28 15:44:44 -07:00
										 |  |  |        */ | 
					
						
							| 
									
										
										
										
											2021-07-29 07:33:19 -07:00
										 |  |  |       toHaveText(expected: string | RegExp | string[], options?: { timeout?: number, useInnerText?: boolean }): Promise<R>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |       /** | 
					
						
							| 
									
										
										
										
											2021-07-29 07:33:19 -07:00
										 |  |  |        * Asserts page's title. | 
					
						
							|  |  |  |        */ | 
					
						
							|  |  |  |       toHaveTitle(expected: string | RegExp, options?: { timeout?: number }): Promise<R>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       /** | 
					
						
							|  |  |  |        * Asserts page's title. | 
					
						
							|  |  |  |        */ | 
					
						
							|  |  |  |       toHaveURL(expected: string | RegExp, options?: { timeout?: number }): Promise<R>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |        /** | 
					
						
							| 
									
										
										
										
											2021-07-28 22:30:37 -07:00
										 |  |  |        * Asserts input element's value. | 
					
						
							|  |  |  |        */ | 
					
						
							|  |  |  |       toHaveValue(expected: string | RegExp, options?: { timeout?: number }): Promise<R>; | 
					
						
							| 
									
										
										
										
											2021-07-28 15:44:44 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export { }; |