expect-webdriverio 5.6.9 → 6.0.0
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/README.md +16 -14
- package/jasmine-wdio-expect-async.d.ts +58 -18
- package/jasmine.d.ts +9 -16
- package/lib/constants.js +4 -0
- package/lib/index.js +30 -18
- package/lib/jasmineUtils.js +3 -2
- package/lib/matchers/asymmetrics/asymmetricsUtils.js +24 -0
- package/lib/matchers/asymmetrics/oneOf.js +51 -0
- package/lib/matchers/browser/toHaveClipboardText.js +8 -9
- package/lib/matchers/browser/toHaveLocalStorageItem.js +22 -14
- package/lib/matchers/browser/toHaveTitle.js +9 -10
- package/lib/matchers/browser/toHaveUrl.js +8 -9
- package/lib/matchers/element/toBeExisting.js +8 -3
- package/lib/matchers/element/toBeSelected.js +6 -13
- package/lib/matchers/element/toHaveAttribute.js +46 -45
- package/lib/matchers/element/toHaveChildren.js +30 -32
- package/lib/matchers/element/toHaveComputedLabel.js +21 -20
- package/lib/matchers/element/toHaveComputedRole.js +21 -20
- package/lib/matchers/element/toHaveElementClass.js +57 -0
- package/lib/matchers/element/toHaveElementProperty.js +40 -32
- package/lib/matchers/element/toHaveHTML.js +22 -23
- package/lib/matchers/element/toHaveHeight.js +23 -28
- package/lib/matchers/element/toHaveSize.js +16 -14
- package/lib/matchers/element/toHaveStyle.js +20 -14
- package/lib/matchers/element/toHaveText.js +26 -44
- package/lib/matchers/element/toHaveWidth.js +23 -28
- package/lib/matchers/elements/toBeElementsArrayOfSize.js +25 -30
- package/lib/matchers/mock/toBeRequestedTimes.js +12 -17
- package/lib/matchers/mock/toBeRequestedWith.js +13 -23
- package/lib/matchers/modifiers/some.js +15 -0
- package/lib/matchers.js +1 -1
- package/lib/tsconfig.build.tsbuildinfo +1 -1
- package/lib/util/commandOptionsUtils.js +6 -0
- package/lib/util/elementsUtil.js +74 -4
- package/lib/util/executeCommand.js +94 -6
- package/lib/util/formatMessage.js +87 -32
- package/lib/util/numberOptionsUtil.js +92 -0
- package/lib/util/refetchElements.js +30 -5
- package/lib/util/stringUtil.js +12 -0
- package/lib/util/waitUntil.js +44 -0
- package/lib/utils.js +128 -105
- package/package.json +13 -11
- package/types/expect-global.d.ts +2 -1
- package/types/expect-webdriverio.d.ts +628 -136
- package/lib/matchers/element/toHaveClass.js +0 -61
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_OPTIONS } from '../../constants.js';
|
|
2
|
-
import { compareText, compareTextWithArray, enhanceError, executeCommand, isAsymmetricMatcher, waitUntil, wrapExpectedWithArray } from '../../utils.js';
|
|
3
|
-
import { toHaveAttributeAndValue } from './toHaveAttribute.js';
|
|
4
|
-
async function condition(el, attribute, value, options) {
|
|
5
|
-
const actualClass = await el.getAttribute(attribute);
|
|
6
|
-
if (typeof actualClass !== 'string') {
|
|
7
|
-
return { result: false };
|
|
8
|
-
}
|
|
9
|
-
if (isAsymmetricMatcher(value)) {
|
|
10
|
-
return compareText(actualClass, value, options);
|
|
11
|
-
}
|
|
12
|
-
const classes = actualClass.split(' ');
|
|
13
|
-
const isValueInClasses = classes.some((t) => {
|
|
14
|
-
return Array.isArray(value)
|
|
15
|
-
? compareTextWithArray(t, value, options).result
|
|
16
|
-
: compareText(t, value, options).result;
|
|
17
|
-
});
|
|
18
|
-
return {
|
|
19
|
-
value: actualClass,
|
|
20
|
-
result: isValueInClasses
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
export function toHaveClass(...args) {
|
|
24
|
-
return toHaveElementClass.call(this || {}, ...args);
|
|
25
|
-
}
|
|
26
|
-
export async function toHaveElementClass(received, expectedValue, options = DEFAULT_OPTIONS) {
|
|
27
|
-
const isNot = this.isNot;
|
|
28
|
-
const { expectation = 'class', verb = 'have' } = this;
|
|
29
|
-
await options.beforeAssertion?.({
|
|
30
|
-
matcherName: 'toHaveElementClass',
|
|
31
|
-
expectedValue,
|
|
32
|
-
options,
|
|
33
|
-
});
|
|
34
|
-
const attribute = 'class';
|
|
35
|
-
let el = await received?.getElement();
|
|
36
|
-
let attr;
|
|
37
|
-
const pass = await waitUntil(async () => {
|
|
38
|
-
const result = await executeCommand.call(this, el, condition, options, [attribute, expectedValue, options]);
|
|
39
|
-
el = result.el;
|
|
40
|
-
attr = result.values;
|
|
41
|
-
return result.success;
|
|
42
|
-
}, isNot, options);
|
|
43
|
-
const message = enhanceError(el, wrapExpectedWithArray(el, attr, expectedValue), attr, this, verb, expectation, '', options);
|
|
44
|
-
const result = {
|
|
45
|
-
pass,
|
|
46
|
-
message: () => message
|
|
47
|
-
};
|
|
48
|
-
await options.afterAssertion?.({
|
|
49
|
-
matcherName: 'toHaveElementClass',
|
|
50
|
-
expectedValue,
|
|
51
|
-
options,
|
|
52
|
-
result
|
|
53
|
-
});
|
|
54
|
-
return result;
|
|
55
|
-
}
|
|
56
|
-
export function toHaveClassContaining(el, className, options = DEFAULT_OPTIONS) {
|
|
57
|
-
return toHaveAttributeAndValue.call(this, el, 'class', className, {
|
|
58
|
-
...options,
|
|
59
|
-
containing: true
|
|
60
|
-
});
|
|
61
|
-
}
|