expect-webdriverio 4.14.0 → 4.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/matchers/element/toHaveAttribute.js +1 -1
- package/lib/matchers/element/toHaveChildren.js +1 -1
- package/lib/matchers/element/toHaveClass.js +1 -1
- package/lib/matchers/element/toHaveComputedLabel.js +1 -1
- package/lib/matchers/element/toHaveComputedRole.js +1 -1
- package/lib/matchers/element/toHaveElementProperty.js +1 -1
- package/lib/matchers/element/toHaveHTML.js +1 -1
- package/lib/matchers/element/toHaveHeight.js +1 -1
- package/lib/matchers/element/toHaveSize.js +1 -1
- package/lib/matchers/element/toHaveStyle.js +1 -1
- package/lib/matchers/element/toHaveText.js +25 -5
- package/lib/matchers/element/toHaveWidth.js +1 -1
- package/lib/util/formatMessage.js +1 -1
- package/lib/utils.js +3 -3
- package/package.json +2 -2
- package/types/expect-webdriverio.d.ts +29 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { waitUntil, enhanceError, compareText, executeCommand, wrapExpectedWithArray } from '../../utils.js';
|
|
2
1
|
import { DEFAULT_OPTIONS } from '../../constants.js';
|
|
2
|
+
import { compareText, enhanceError, executeCommand, waitUntil, wrapExpectedWithArray } from '../../utils.js';
|
|
3
3
|
async function conditionAttr(el, attribute) {
|
|
4
4
|
const attr = await el.getAttribute(attribute);
|
|
5
5
|
if (typeof attr !== 'string') {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { waitUntil, enhanceError, compareNumbers, numberError, executeCommand, wrapExpectedWithArray } from '../../utils.js';
|
|
2
1
|
import { DEFAULT_OPTIONS } from '../../constants.js';
|
|
2
|
+
import { compareNumbers, enhanceError, executeCommand, numberError, waitUntil, wrapExpectedWithArray } from '../../utils.js';
|
|
3
3
|
async function condition(el, options) {
|
|
4
4
|
const children = await el.$$('./*');
|
|
5
5
|
if (typeof options.lte !== 'number' &&
|
|
@@ -2,7 +2,7 @@ import { DEFAULT_OPTIONS } from '../../constants.js';
|
|
|
2
2
|
import { compareText, compareTextWithArray, enhanceError, executeCommand, isAsymmeyricMatcher, waitUntil, wrapExpectedWithArray } from '../../utils.js';
|
|
3
3
|
import { toHaveAttributeAndValue } from './toHaveAttribute.js';
|
|
4
4
|
async function condition(el, attribute, value, options) {
|
|
5
|
-
const actualClass = await
|
|
5
|
+
const actualClass = await el.getAttribute(attribute);
|
|
6
6
|
if (typeof actualClass !== 'string') {
|
|
7
7
|
return { result: false };
|
|
8
8
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { waitUntil, enhanceError, compareText, compareTextWithArray, executeCommand, wrapExpectedWithArray } from '../../utils.js';
|
|
2
1
|
import { DEFAULT_OPTIONS } from '../../constants.js';
|
|
2
|
+
import { compareText, compareTextWithArray, enhanceError, executeCommand, waitUntil, wrapExpectedWithArray } from '../../utils.js';
|
|
3
3
|
async function condition(el, label, options) {
|
|
4
4
|
const actualLabel = await el.getComputedLabel();
|
|
5
5
|
if (Array.isArray(label)) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { waitUntil, enhanceError, compareText, compareTextWithArray, executeCommand, wrapExpectedWithArray } from '../../utils.js';
|
|
2
1
|
import { DEFAULT_OPTIONS } from '../../constants.js';
|
|
2
|
+
import { compareText, compareTextWithArray, enhanceError, executeCommand, waitUntil, wrapExpectedWithArray } from '../../utils.js';
|
|
3
3
|
async function condition(el, role, options) {
|
|
4
4
|
const actualRole = await el.getComputedRole();
|
|
5
5
|
if (Array.isArray(role)) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { waitUntil, enhanceError, compareText, executeCommand, wrapExpectedWithArray } from '../../utils.js';
|
|
2
1
|
import { DEFAULT_OPTIONS } from '../../constants.js';
|
|
2
|
+
import { compareText, enhanceError, executeCommand, waitUntil, wrapExpectedWithArray } from '../../utils.js';
|
|
3
3
|
async function condition(el, property, value, options = DEFAULT_OPTIONS) {
|
|
4
4
|
const { asString = false } = options;
|
|
5
5
|
let prop = await el.getProperty(property);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { waitUntil, enhanceError, compareText, compareTextWithArray, executeCommand, wrapExpectedWithArray } from '../../utils.js';
|
|
2
1
|
import { DEFAULT_OPTIONS } from '../../constants.js';
|
|
2
|
+
import { compareText, compareTextWithArray, enhanceError, executeCommand, waitUntil, wrapExpectedWithArray } from '../../utils.js';
|
|
3
3
|
async function condition(el, html, options) {
|
|
4
4
|
const actualHTML = await el.getHTML(options.includeSelectorTag);
|
|
5
5
|
if (Array.isArray(html)) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { waitUntil, enhanceError, executeCommand, wrapExpectedWithArray } from '../../utils.js';
|
|
2
1
|
import { DEFAULT_OPTIONS } from '../../constants.js';
|
|
2
|
+
import { enhanceError, executeCommand, waitUntil, wrapExpectedWithArray } from '../../utils.js';
|
|
3
3
|
async function condition(el, height) {
|
|
4
4
|
const actualHeight = await el.getSize('height');
|
|
5
5
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { waitUntil, enhanceError, executeCommand, wrapExpectedWithArray, compareObject, } from '../../utils.js';
|
|
2
1
|
import { DEFAULT_OPTIONS } from '../../constants.js';
|
|
2
|
+
import { compareObject, enhanceError, executeCommand, waitUntil, wrapExpectedWithArray, } from '../../utils.js';
|
|
3
3
|
async function condition(el, size) {
|
|
4
4
|
const actualSize = await el.getSize();
|
|
5
5
|
return compareObject(actualSize, size);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { waitUntil, enhanceError, compareStyle, executeCommand, wrapExpectedWithArray } from '../../utils.js';
|
|
2
1
|
import { DEFAULT_OPTIONS } from '../../constants.js';
|
|
2
|
+
import { compareStyle, enhanceError, executeCommand, waitUntil, wrapExpectedWithArray } from '../../utils.js';
|
|
3
3
|
async function condition(el, style, options) {
|
|
4
4
|
return compareStyle(el, style, options);
|
|
5
5
|
}
|
|
@@ -1,11 +1,31 @@
|
|
|
1
|
-
import { waitUntil, enhanceError, compareText, compareTextWithArray, executeCommand, wrapExpectedWithArray } from '../../utils.js';
|
|
2
1
|
import { DEFAULT_OPTIONS } from '../../constants.js';
|
|
2
|
+
import { compareText, compareTextWithArray, enhanceError, executeCommand, waitUntil, wrapExpectedWithArray } from '../../utils.js';
|
|
3
3
|
async function condition(el, text, options) {
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const actualTextArray = [];
|
|
5
|
+
const resultArray = [];
|
|
6
|
+
let checkAllValuesMatchCondition;
|
|
7
|
+
if (Array.isArray(el)) {
|
|
8
|
+
for (const element of el) {
|
|
9
|
+
const actualText = await element.getText();
|
|
10
|
+
actualTextArray.push(actualText);
|
|
11
|
+
const result = Array.isArray(text)
|
|
12
|
+
? compareTextWithArray(actualText, text, options).result
|
|
13
|
+
: compareText(actualText, text, options).result;
|
|
14
|
+
resultArray.push(result);
|
|
15
|
+
}
|
|
16
|
+
checkAllValuesMatchCondition = resultArray.every(result => result);
|
|
7
17
|
}
|
|
8
|
-
|
|
18
|
+
else {
|
|
19
|
+
const actualText = await el.getText();
|
|
20
|
+
actualTextArray.push(actualText);
|
|
21
|
+
checkAllValuesMatchCondition = Array.isArray(text)
|
|
22
|
+
? compareTextWithArray(actualText, text, options).result
|
|
23
|
+
: compareText(actualText, text, options).result;
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
value: actualTextArray.length === 1 ? actualTextArray[0] : actualTextArray,
|
|
27
|
+
result: checkAllValuesMatchCondition
|
|
28
|
+
};
|
|
9
29
|
}
|
|
10
30
|
export async function toHaveText(received, expectedValue, options = DEFAULT_OPTIONS) {
|
|
11
31
|
const isNot = this.isNot;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { waitUntil, enhanceError, executeCommand, wrapExpectedWithArray } from '../../utils.js';
|
|
2
1
|
import { DEFAULT_OPTIONS } from '../../constants.js';
|
|
2
|
+
import { enhanceError, executeCommand, waitUntil, wrapExpectedWithArray } from '../../utils.js';
|
|
3
3
|
async function condition(el, width) {
|
|
4
4
|
const actualWidth = await el.getSize('width');
|
|
5
5
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { printExpected, printReceived
|
|
1
|
+
import { printDiffOrStringify, printExpected, printReceived } from 'jest-matcher-utils';
|
|
2
2
|
import { equals } from '../jasmineUtils.js';
|
|
3
3
|
const EXPECTED_LABEL = 'Expected';
|
|
4
4
|
const RECEIVED_LABEL = 'Received';
|
package/lib/utils.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import isEqual from 'lodash.isequal';
|
|
2
|
-
import {
|
|
2
|
+
import { DEFAULT_OPTIONS } from './constants.js';
|
|
3
3
|
import { wrapExpectedWithArray } from './util/elementsUtil.js';
|
|
4
|
+
import { executeCommand } from './util/executeCommand.js';
|
|
4
5
|
import { enhanceError, enhanceErrorBe, numberError } from './util/formatMessage.js';
|
|
5
|
-
import { DEFAULT_OPTIONS } from './constants.js';
|
|
6
6
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
7
7
|
const asymmetricMatcher = typeof Symbol === 'function' && Symbol.for
|
|
8
8
|
? Symbol.for('jest.asymmetricMatcher')
|
|
@@ -219,7 +219,7 @@ function aliasFn(fn, { verb, expectation, } = {}, ...args) {
|
|
|
219
219
|
this.expectation = expectation;
|
|
220
220
|
return fn.apply(this, args);
|
|
221
221
|
}
|
|
222
|
-
export {
|
|
222
|
+
export { aliasFn, compareNumbers, enhanceError, executeCommand, executeCommandBe, numberError, waitUntil, wrapExpectedWithArray };
|
|
223
223
|
function replaceActual(replace, actual) {
|
|
224
224
|
const hasMultipleReplacers = replace.every((r) => Array.isArray(r));
|
|
225
225
|
const replacers = hasMultipleReplacers
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expect-webdriverio",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.15.1",
|
|
4
4
|
"author": "Mykola Grybyk <mykola.grybyk@gmail.com>",
|
|
5
5
|
"description": "WebdriverIO Assertion Library",
|
|
6
6
|
"license": "MIT",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"shelljs": "^0.8.5",
|
|
77
77
|
"typescript": "^5.3.3",
|
|
78
78
|
"vitest": "1.6.0",
|
|
79
|
-
"webdriverio": "8.38.
|
|
79
|
+
"webdriverio": "8.38.2"
|
|
80
80
|
},
|
|
81
81
|
"optionalDependencies": {
|
|
82
82
|
"@wdio/globals": "^8.29.3",
|
|
@@ -214,8 +214,21 @@ declare namespace ExpectWebdriverIO {
|
|
|
214
214
|
|
|
215
215
|
/**
|
|
216
216
|
* `WebdriverIO.Element` -> `getAttribute` class
|
|
217
|
+
*
|
|
218
|
+
* Checks if an element has the specified class or matches any of the provided class patterns.
|
|
219
|
+
* @param className - The class name(s) or pattern(s) to match against.
|
|
220
|
+
* @param options - Optional settings that can be passed to the function.
|
|
221
|
+
*
|
|
222
|
+
* **Usage**
|
|
223
|
+
* ```js
|
|
224
|
+
* // Check if an element has the class 'btn'
|
|
225
|
+
* await expect(element).toHaveElementClass('btn');
|
|
226
|
+
*
|
|
227
|
+
* // Check if an element has any of the specified classes
|
|
228
|
+
* await expect(element).toHaveElementClass(['btn', 'btn-large']);
|
|
229
|
+
* ```
|
|
217
230
|
*/
|
|
218
|
-
toHaveElementClass(className: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
231
|
+
toHaveElementClass(className: string | RegExp | Array<string | RegExp> | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
219
232
|
|
|
220
233
|
/**
|
|
221
234
|
* `WebdriverIO.Element` -> `getAttribute` class
|
|
@@ -330,6 +343,21 @@ declare namespace ExpectWebdriverIO {
|
|
|
330
343
|
/**
|
|
331
344
|
* `WebdriverIO.Element` -> `getText`
|
|
332
345
|
* Element's text equals the text provided
|
|
346
|
+
*
|
|
347
|
+
* @param text - The expected text to match.
|
|
348
|
+
* @param options - Optional settings that can be passed to the function.
|
|
349
|
+
*
|
|
350
|
+
* **Usage**
|
|
351
|
+
*
|
|
352
|
+
* ```js
|
|
353
|
+
* // Check if an element has the text
|
|
354
|
+
* const elem = await $('.container')
|
|
355
|
+
* await expect(elem).toHaveText('Next-gen browser and mobile automation test framework for Node.js')
|
|
356
|
+
*
|
|
357
|
+
* // Check if an element array contains the specified text
|
|
358
|
+
* const elem = await $$('ul > li')
|
|
359
|
+
* await expect(elem).toHaveText(['Coffee', 'Tea', 'Milk'])
|
|
360
|
+
* ```
|
|
333
361
|
*/
|
|
334
362
|
toHaveText(
|
|
335
363
|
text: string | RegExp | ExpectWebdriverIO.PartialMatcher | Array<string | RegExp>,
|