You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Playwright is a framework for Web Testing and Automation. It allows testing [Chromium](https://www.chromium.org/Home), [Firefox](https://www.mozilla.org/en-US/firefox/new/) and [WebKit](https://webkit.org/) with a single API. Playwright is built to enable cross-browser web automation that is **ever-green**, **capable**, **reliable** and **fast**.
Note that soft assertions only work with Playwright test runner.
136
136
137
-
## Custom Expect Message
137
+
## Custom expect message
138
138
139
139
You can specify a custom error message as a second argument to the `expect` function, for example:
140
140
@@ -236,3 +236,86 @@ await expect(async () => {
236
236
timeout: 60_000
237
237
});
238
238
```
239
+
240
+
## Add custom matchers using expect.extend
241
+
242
+
You can extend Playwright assertions by providing custom matchers. These matchers will be available on the `expect` object.
243
+
244
+
In this example we add a custom `toHaveAmount` function. Custom matcher should return a `message` callback and a `pass` flag indicating whether the assertion passed.
245
+
246
+
```js title="fixtures.ts"
247
+
import { expect as baseExpect } from '@playwright/test';
248
+
import type { Page, Locator } from '@playwright/test';
Do not confuse Playwright's `expect` with the [`expect` library](https://jestjs.io/docs/expect). The latter is not fully integrated with Playwright test runner, so make sure to use Playwright's own `expect`.
300
+
:::
301
+
302
+
### Combine custom matchers from multiple modules
303
+
304
+
You can combine custom matchers from multiple files or modules.
305
+
306
+
```js title="fixtures.ts"
307
+
import { mergeTests, mergeExpects } from '@playwright/test';
308
+
import { test as dbTest, expect as dbExpect } from 'database-test-utils';
309
+
import { test as a11yTest, expect as a11yExpect } from 'a11y-test-utils';
|[`method: PageAssertions.toHaveScreenshot#1`]| Configuration for the `expect(locator).toHaveScreeshot()` method. |
151
151
|[`method: SnapshotAssertions.toMatchSnapshot#1`]| Configuration for the `expect(locator).toMatchSnapshot()` method.|
152
152
153
-
154
-
### Add custom matchers using expect.extend
155
-
156
-
You can extend Playwright assertions by providing custom matchers. These matchers will be available on the `expect` object.
157
-
158
-
In this example we add a custom `toHaveAmount` function. Custom matcher should return a `message` callback and a `pass` flag indicating whether the assertion passed.
Do not confuse Playwright's `expect` with the [`expect` library](https://jestjs.io/docs/expect). The latter is not fully integrated with Playwright test runner, so make sure to use Playwright's own `expect`.
214
-
:::
215
-
216
-
### Combine custom matchers from multiple modules
217
-
218
-
You can combine custom matchers from multiple files or modules.
Copy file name to clipboardExpand all lines: packages/playwright-core/src/server/chromium/protocol.d.ts
+1-1
Original file line number
Diff line number
Diff line change
@@ -878,7 +878,7 @@ Should be updated alongside RequestIdTokenStatus in
878
878
third_party/blink/public/mojom/devtools/inspector_issue.mojom to include
879
879
all cases except for success.
880
880
*/
881
-
export type FederatedAuthRequestIssueReason = "ShouldEmbargo"|"TooManyRequests"|"WellKnownHttpNotFound"|"WellKnownNoResponse"|"WellKnownInvalidResponse"|"WellKnownListEmpty"|"WellKnownInvalidContentType"|"ConfigNotInWellKnown"|"WellKnownTooBig"|"ConfigHttpNotFound"|"ConfigNoResponse"|"ConfigInvalidResponse"|"ConfigInvalidContentType"|"ClientMetadataHttpNotFound"|"ClientMetadataNoResponse"|"ClientMetadataInvalidResponse"|"ClientMetadataInvalidContentType"|"DisabledInSettings"|"ErrorFetchingSignin"|"InvalidSigninResponse"|"AccountsHttpNotFound"|"AccountsNoResponse"|"AccountsInvalidResponse"|"AccountsListEmpty"|"AccountsInvalidContentType"|"IdTokenHttpNotFound"|"IdTokenNoResponse"|"IdTokenInvalidResponse"|"IdTokenInvalidRequest"|"IdTokenInvalidContentType"|"ErrorIdToken"|"Canceled"|"RpPageNotVisible"|"SilentMediationFailure"|"ThirdPartyCookiesBlocked"|"NotSignedInWithIdp";
881
+
export type FederatedAuthRequestIssueReason = "ShouldEmbargo"|"TooManyRequests"|"WellKnownHttpNotFound"|"WellKnownNoResponse"|"WellKnownInvalidResponse"|"WellKnownListEmpty"|"WellKnownInvalidContentType"|"ConfigNotInWellKnown"|"WellKnownTooBig"|"ConfigHttpNotFound"|"ConfigNoResponse"|"ConfigInvalidResponse"|"ConfigInvalidContentType"|"ClientMetadataHttpNotFound"|"ClientMetadataNoResponse"|"ClientMetadataInvalidResponse"|"ClientMetadataInvalidContentType"|"DisabledInSettings"|"ErrorFetchingSignin"|"InvalidSigninResponse"|"AccountsHttpNotFound"|"AccountsNoResponse"|"AccountsInvalidResponse"|"AccountsListEmpty"|"AccountsInvalidContentType"|"IdTokenHttpNotFound"|"IdTokenNoResponse"|"IdTokenInvalidResponse"|"IdTokenIdpErrorResponse"|"IdTokenCrossSiteIdpErrorResponse"|"IdTokenInvalidRequest"|"IdTokenInvalidContentType"|"ErrorIdToken"|"Canceled"|"RpPageNotVisible"|"SilentMediationFailure"|"ThirdPartyCookiesBlocked"|"NotSignedInWithIdp";
0 commit comments