expect-playwright
Advanced tools
Comparing version 0.3.2 to 0.3.3
@@ -42,7 +42,10 @@ // copied into our codebase for autocompletion purposes | ||
/** | ||
* Will ensure that the element is one the page in a given timeout (default 1 second). | ||
* Will ensure that the element is on the page. | ||
*/ | ||
toHaveSelector(selector: string, options?: PageWaitForSelectorOptions): Promise<R>; | ||
/** | ||
* Will ensure that the element has focus. | ||
*/ | ||
toHaveFocus(selector: string, options?: PageWaitForSelectorOptions): Promise<R>; | ||
/** | ||
* Will assert that N elements with the given selector are on the page and wait for it by default. | ||
@@ -60,2 +63,6 @@ * If its 0 elements, then it will throw since the element can't be found. | ||
toEqualValue(value: string, options?: PageWaitForSelectorOptions): Promise<R>; | ||
/** | ||
* Will assert the given URL with the page's URL | ||
*/ | ||
toEqualUrl(value: string): Promise<R>; | ||
} | ||
@@ -68,2 +75,1 @@ | ||
} | ||
@@ -11,2 +11,4 @@ "use strict"; | ||
const toHaveSelectorCount_1 = __importDefault(require("./toHaveSelectorCount")); | ||
const toEqualUrl_1 = __importDefault(require("./toEqualUrl")); | ||
const toHaveFocus_1 = __importDefault(require("./toHaveFocus")); | ||
exports.default = { | ||
@@ -18,2 +20,4 @@ toHaveText: toHaveText_1.default, | ||
toHaveSelectorCount: toHaveSelectorCount_1.default, | ||
toEqualUrl: toEqualUrl_1.default, | ||
toHaveFocus: toHaveFocus_1.default, | ||
}; |
{ | ||
"name": "expect-playwright", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"main": "lib/index.js", | ||
"types": "./global.d.ts", | ||
"repository": "https://github.com/mxschmitt/expect-playwright.git", | ||
"repository": "https://github.com/playwright-community/expect-playwright", | ||
"author": "Max Schmitt <max@schmitt.mx>", | ||
@@ -15,14 +15,14 @@ "license": "MIT", | ||
"peerDependencies": { | ||
"playwright-core": "^1.8.0" | ||
"playwright-core": "^1.9.1" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^26.0.20", | ||
"@types/node": "^14.14.22", | ||
"@types/node": "^14.14.31", | ||
"jest": "^26.6.3", | ||
"jest-playwright-preset": "^1.4.5", | ||
"playwright-chromium": "^1.8.0", | ||
"playwright-core": "^1.8.0", | ||
"ts-jest": "^26.4.4", | ||
"typescript": "^4.1.3" | ||
"jest-playwright-preset": "^1.4.7", | ||
"playwright-chromium": "^1.9.1", | ||
"playwright-core": "^1.9.1", | ||
"ts-jest": "^26.5.2", | ||
"typescript": "^4.2.2" | ||
} | ||
} |
# expect-playwright | ||
![Node.js CI](https://github.com/mxschmitt/expect-playwright/workflows/Node.js%20CI/badge.svg) | ||
[![codecov](https://codecov.io/gh/mxschmitt/expect-playwright/branch/master/graph/badge.svg?token=Eay491HC49)](https://codecov.io/gh/mxschmitt/expect-playwright) | ||
![Node.js CI](https://github.com/playwright-community/expect-playwright/workflows/Node.js%20CI/badge.svg) | ||
[![codecov](https://codecov.io/gh/playwright-community/expect-playwright/branch/master/graph/badge.svg?token=Eay491HC49)](https://codecov.io/gh/playwright-community/expect-playwright) | ||
[![NPM](https://img.shields.io/npm/v/expect-playwright)](https://www.npmjs.com/package/expect-playwright) | ||
@@ -58,2 +58,4 @@ | ||
- [toEqualValue](#toEqualValue) | ||
- [toEqualUrl](#toEqualUrl) | ||
- [toHaveFocus](#toHaveFocus) | ||
@@ -74,2 +76,26 @@ ### toHaveSelector | ||
### toHaveFocus | ||
**expect(page: [Page]).toHaveFocus(selector: string, options?: [PageWaitForSelectorOptions](https://playwright.dev/docs/api/class-page/#pagewaitforselectorselector-options))** | ||
This function checks if the given selector has focus. | ||
```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 | ||
}) | ||
``` | ||
### toEqualUrl | ||
**expect(page: [Page]).toHaveSelector(value: string)** | ||
This function checks if the given URL matches the current page's URL | ||
```javascript | ||
await expect(page).toEqualUrl("https://github.com") | ||
``` | ||
### toHaveSelectorCount | ||
@@ -85,3 +111,2 @@ | ||
### toHaveText | ||
@@ -116,4 +141,2 @@ | ||
By default it waits 1 second for the element which you can overwrite via the options. | ||
### toEqualText | ||
@@ -148,4 +171,2 @@ | ||
By default it waits 1 second for the element which you can overwrite via the options. | ||
### toEqualValue | ||
@@ -172,4 +193,2 @@ | ||
By default it waits 1 second for the element which you can overwrite via the options. | ||
## Examples | ||
@@ -176,0 +195,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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
31395
20
366
223