expect-playwright
Advanced tools
Comparing version 0.6.0 to 0.7.0
@@ -89,2 +89,19 @@ // copied into our codebase for autocompletion purposes from 'playwright/types/types.d.ts' so we don't depend on it. | ||
/** | ||
* Will check if an element's computed style property on the page determined by the selector matches the given string. | ||
*/ | ||
toMatchComputedStyle( | ||
selector: string, | ||
property: string, | ||
value: RegExp | string, | ||
options?: PageWaitForSelectorOptions | ||
): Promise<R> | ||
/** | ||
* Will check if an element's computed style property matches the given string. | ||
*/ | ||
toMatchComputedStyle( | ||
property: string, | ||
value: RegExp | string, | ||
options?: PageWaitForSelectorOptions | ||
): Promise<R> | ||
/** | ||
* Will check if the element's textContent on the page determined by the selector matches the given pattern. | ||
@@ -149,3 +166,3 @@ */ | ||
/** | ||
* Will ensure that the element has focus. | ||
* Will check that an element on the page determined by the selector has focus. | ||
*/ | ||
@@ -157,2 +174,6 @@ toHaveFocus( | ||
/** | ||
* Will check that an element has focus. | ||
*/ | ||
toHaveFocus(options?: PageWaitForSelectorOptions): Promise<R> | ||
/** | ||
* Will assert that N elements with the given selector are on the page and wait for it by default. | ||
@@ -159,0 +180,0 @@ * If its 0 elements, then it will throw since the element can't be found. |
{ | ||
"name": "expect-playwright", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "types": "./global.d.ts", |
@@ -77,2 +77,4 @@ # expect-playwright | ||
- [toHaveSelectorCount](#toHaveSelectorCount) | ||
- [toMatchAttribute](#toMatchAttribute) | ||
- [toMatchComputedStyle](#toMatchComputedStyle) | ||
- [toMatchText](#toMatchText) | ||
@@ -136,12 +138,17 @@ - [toMatchTitle](#toMatchTitle) | ||
This function checks if the given selector has focus. | ||
This function checks if a given element is focused. | ||
You can do this via a selector on the whole page: | ||
```js | ||
await expect(page).toHaveFocus("#foobar") | ||
// or via not, useful to only wait 1 second instead of for the default timeout by Playwright which is 30 seconds. | ||
await expect(page).not.toHaveFocus("#foobar", { | ||
timeout: 1 * 1000, | ||
}) | ||
``` | ||
Or by passing a Playwright [ElementHandle]: | ||
```javascript | ||
const element = await page.$("#foobar") | ||
await expect(element).toHaveFocus() | ||
``` | ||
### toHaveSelector | ||
@@ -169,2 +176,40 @@ | ||
### toMatchAttribute | ||
This function checks if an element's attribute matches the provided string or regex pattern. | ||
You can do this via a selector on the whole page: | ||
```javascript | ||
await expect(page).toMatchAttribute("#foo", "href", "https://playwright.dev") | ||
await expect(page).toMatchAttribute("#foo", "href", /playwright/) | ||
``` | ||
Or by passing a Playwright [ElementHandle]: | ||
```javascript | ||
const element = await page.$("#foo") | ||
await expect(element).toMatchAttribute("href", "https://playwright.dev") | ||
await expect(element).toMatchAttribute("href", /playwright/) | ||
``` | ||
### toMatchComputedStyle | ||
This function checks if an element's computed style property matches the provided string or regex pattern. | ||
You can do this via a selector on the whole page: | ||
```javascript | ||
await expect(page).toMatchComputedStyle("#my-element", "color", "rgb(0, 0, 0)") | ||
await expect(page).toMatchComputedStyle("#my-element", "color", /rgb/) | ||
``` | ||
Or by passing a Playwright [ElementHandle]: | ||
```javascript | ||
const element = await page.$("#my-element") | ||
await expect(element).toMatchComputedStyle("color", "rgb(0, 0, 0)") | ||
await expect(element).toMatchComputedStyle("color", /rgb/) | ||
``` | ||
### toMatchText | ||
@@ -171,0 +216,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36014
31
684
312
1