Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

expect-playwright

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expect-playwright - npm Package Compare versions

Comparing version 0.1.1 to 0.2.1

lib/matchers/toEqualValue/index.js

23

global.d.ts
import { PageWaitForSelectorOptions } from "playwright-core";
export interface PlaywrightMatchers<R> {
/**
* Will check if the element's textContent on the page determined by the selector includes the given text.
*/
toHaveText(selector: string, value: string, options?: PageWaitForSelectorOptions): Promise<R>;
/**
* Will check if the element's value includes the given text.
*/
toHaveText(value: string, options?: PageWaitForSelectorOptions): Promise<R>;
/**
* Will compare the element's textContent on the page determined by the selector with the given text.
*/
toEqualText(selector: string, value: string, options?: PageWaitForSelectorOptions): Promise<R>;
/**
* Will compare the element's textContent by the given text.
*/
toEqualText(value: string, options?: PageWaitForSelectorOptions): Promise<R>;
/**
* Will ensure that the element is one the page in a given timeout (default 1 second).
*/
toHaveSelector(selector: string, options?: PageWaitForSelectorOptions): Promise<R>;
/**
* Will compare the element's value on the page determined by the selector with the given value.
*/
toEqualValue(selector: string, value: string, options?: PageWaitForSelectorOptions): Promise<R>;
/**
* Will compare element's value with the given value.
*/
toEqualValue(value: string, options?: PageWaitForSelectorOptions): Promise<R>;
}

@@ -10,0 +33,0 @@

2

lib/matchers/index.js

@@ -9,2 +9,3 @@ "use strict";

const toHaveSelector_1 = __importDefault(require("./toHaveSelector"));
const toEqualValue_1 = __importDefault(require("./toEqualValue"));
exports.default = {

@@ -14,2 +15,3 @@ toHaveText: toHaveText_1.default,

toHaveSelector: toHaveSelector_1.default,
toEqualValue: toEqualValue_1.default,
};

2

lib/matchers/toEqualText/index.js

@@ -12,3 +12,3 @@ "use strict";

pass: true,
message: () => `${utils_1.quote(expectedValue)} does not equal ${utils_1.quote(actualTextContent)}.`
message: () => `${utils_1.quote(expectedValue)} does equal ${utils_1.quote(actualTextContent)}.`
};

@@ -15,0 +15,0 @@ }

{
"name": "expect-playwright",
"version": "0.1.1",
"version": "0.2.1",
"main": "lib/index.js",

@@ -5,0 +5,0 @@ "types": "./global.d.ts",

@@ -56,2 +56,3 @@ # expect-playwright

- [toEqualText](#toEqualText)
- [toEqualValue](#toEqualValue)

@@ -90,3 +91,3 @@ ### toHaveSelector

Or by passing an Playwright [ElementHandle]:
Or by passing a Playwright [ElementHandle]:

@@ -122,3 +123,3 @@ **expect(page: [ElementHandle]).toHaveText(value: string, options?: [PageWaitForSelectorOptions](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforselectorselector-options))**

Or by passing an Playwright [ElementHandle]:
Or by passing a Playwright [ElementHandle]:

@@ -134,2 +135,25 @@ **expect(page: [ElementHandle]).toEqualText(value: string, options?: [PageWaitForSelectorOptions](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforselectorselector-options))**

### toEqualValue
This function checks if the `value` of a given element is the same as the provided value.
You can do this via a selector or the element directly:
**expect(page: [Page]).toEqualValue(selector: string, value: string, options?: [PageWaitForSelectorOptions](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforselectorselector-options))**
```javascript
await expect(page).toEqualValue("#my-element", "Playwright")
```
Or by passing a Playwright [ElementHandle]:
**expect(page: [ElementHandle]).toEqualValue(value: string, options?: [PageWaitForSelectorOptions](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforselectorselector-options))**
```javascript
const element = await page.$('#my-element');
await expect(element).toEqualValue("Playwright")
```
By default it waits 1 second for the element which you can overwrite via the options.
## Examples

@@ -136,0 +160,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc