expect-webdriverio 4.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/LICENSE +21 -0
- package/README.md +65 -0
- package/jasmine.d.ts +6 -0
- package/jest.d.ts +5 -0
- package/lib/addMatchers.js +48 -0
- package/lib/index.js +6 -0
- package/lib/jasmineUtils.js +205 -0
- package/lib/matchers/browser/toHaveTitle.js +26 -0
- package/lib/matchers/browser/toHaveTitleContaining.js +15 -0
- package/lib/matchers/browser/toHaveUrl.js +26 -0
- package/lib/matchers/browser/toHaveUrlContaining.js +15 -0
- package/lib/matchers/element/toBeClickable.js +23 -0
- package/lib/matchers/element/toBeDisabled.js +16 -0
- package/lib/matchers/element/toBeDisplayed.js +23 -0
- package/lib/matchers/element/toBeDisplayedInViewport.js +23 -0
- package/lib/matchers/element/toBeEnabled.js +16 -0
- package/lib/matchers/element/toBeExisting.js +32 -0
- package/lib/matchers/element/toBeFocused.js +16 -0
- package/lib/matchers/element/toBeSelected.js +22 -0
- package/lib/matchers/element/toHaveAttribute.js +72 -0
- package/lib/matchers/element/toHaveAttributeContaining.js +16 -0
- package/lib/matchers/element/toHaveChildren.js +51 -0
- package/lib/matchers/element/toHaveElementClass.js +60 -0
- package/lib/matchers/element/toHaveElementClassContaining.js +20 -0
- package/lib/matchers/element/toHaveElementProperty.js +52 -0
- package/lib/matchers/element/toHaveHref.js +14 -0
- package/lib/matchers/element/toHaveHrefContaining.js +16 -0
- package/lib/matchers/element/toHaveId.js +13 -0
- package/lib/matchers/element/toHaveStyle.js +33 -0
- package/lib/matchers/element/toHaveText.js +37 -0
- package/lib/matchers/element/toHaveTextContaining.js +15 -0
- package/lib/matchers/element/toHaveValue.js +13 -0
- package/lib/matchers/element/toHaveValueContaining.js +15 -0
- package/lib/matchers/elements/toBeElementsArrayOfSize.js +39 -0
- package/lib/matchers/mock/toBeRequested.js +12 -0
- package/lib/matchers/mock/toBeRequestedTimes.js +35 -0
- package/lib/matchers/mock/toBeRequestedWith.js +218 -0
- package/lib/matchers/mock/toBeRequestedWithResponse.js +13 -0
- package/lib/matchers.js +41 -0
- package/lib/options.js +33 -0
- package/lib/util/elementsUtil.js +28 -0
- package/lib/util/executeCommand.js +31 -0
- package/lib/util/expectAdapter.js +41 -0
- package/lib/util/formatMessage.js +93 -0
- package/lib/util/refetchElements.js +15 -0
- package/lib/utils.js +161 -0
- package/package.json +68 -0
- package/types/expect-webdriverio.d.ts +327 -0
- package/types/jest-global.d.ts +9 -0
- package/types/standalone-global.d.ts +9 -0
- package/types/standalone.d.ts +24 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toHaveAttr = exports.toHaveAttribute = exports.toHaveAttributeFn = exports.toHaveAttributeAndValueFn = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
6
|
+
async function conditionAttr(el, attribute) {
|
|
7
|
+
const attr = await el.getAttribute(attribute);
|
|
8
|
+
if (typeof attr !== 'string') {
|
|
9
|
+
return { result: false, value: attr };
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
return { result: true, value: attr };
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
async function conditionAttrAndValue(el, attribute, value, options) {
|
|
16
|
+
const attr = await el.getAttribute(attribute);
|
|
17
|
+
if (typeof attr !== 'string') {
|
|
18
|
+
return { result: false, value: attr };
|
|
19
|
+
}
|
|
20
|
+
return utils_1.compareText(attr, value, options);
|
|
21
|
+
}
|
|
22
|
+
function toHaveAttributeAndValueFn(received, attribute, value, options = {}) {
|
|
23
|
+
const isNot = this.isNot;
|
|
24
|
+
const { expectation = 'attribute', verb = 'have' } = this;
|
|
25
|
+
return browser.call(async () => {
|
|
26
|
+
let el = await received;
|
|
27
|
+
let attr;
|
|
28
|
+
const pass = await utils_1.waitUntil(async () => {
|
|
29
|
+
const result = await utils_1.executeCommand.call(this, el, conditionAttrAndValue, options, [attribute, value, options]);
|
|
30
|
+
el = result.el;
|
|
31
|
+
attr = result.values;
|
|
32
|
+
return result.success;
|
|
33
|
+
}, isNot, options);
|
|
34
|
+
utils_1.updateElementsArray(pass, received, el);
|
|
35
|
+
const expected = utils_1.wrapExpectedWithArray(el, attr, value);
|
|
36
|
+
const message = utils_1.enhanceError(el, expected, attr, this, verb, expectation, attribute, options);
|
|
37
|
+
return {
|
|
38
|
+
pass,
|
|
39
|
+
message: () => message
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
exports.toHaveAttributeAndValueFn = toHaveAttributeAndValueFn;
|
|
44
|
+
function toHaveAttributeFn(received, attribute) {
|
|
45
|
+
const isNot = this.isNot;
|
|
46
|
+
const { expectation = 'attribute', verb = 'have' } = this;
|
|
47
|
+
return browser.call(async () => {
|
|
48
|
+
let el = await received;
|
|
49
|
+
const pass = await utils_1.waitUntil(async () => {
|
|
50
|
+
const result = await utils_1.executeCommand.call(this, el, conditionAttr, {}, [attribute]);
|
|
51
|
+
el = result.el;
|
|
52
|
+
return result.success;
|
|
53
|
+
}, isNot, {});
|
|
54
|
+
utils_1.updateElementsArray(pass, received, el);
|
|
55
|
+
const message = utils_1.enhanceError(el, !isNot, pass, this, verb, expectation, attribute, {});
|
|
56
|
+
return {
|
|
57
|
+
pass,
|
|
58
|
+
message: () => message
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
exports.toHaveAttributeFn = toHaveAttributeFn;
|
|
63
|
+
function toHaveAttribute(...args) {
|
|
64
|
+
if (args.length === 3 || args.length === 4) {
|
|
65
|
+
return expectAdapter_1.runExpect.call(this, toHaveAttributeAndValueFn, args);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
return expectAdapter_1.runExpect.call(this, toHaveAttributeFn, args);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.toHaveAttribute = toHaveAttribute;
|
|
72
|
+
exports.toHaveAttr = toHaveAttribute;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toHaveAttrContaining = exports.toHaveAttributeContaining = void 0;
|
|
4
|
+
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
5
|
+
const toHaveAttribute_1 = require("./toHaveAttribute");
|
|
6
|
+
function toHaveAttributeContainingFn(el, attribute, value, options = {}) {
|
|
7
|
+
return toHaveAttribute_1.toHaveAttributeAndValueFn.call(this, el, attribute, value, {
|
|
8
|
+
...options,
|
|
9
|
+
containing: true
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function toHaveAttributeContaining(...args) {
|
|
13
|
+
return expectAdapter_1.runExpect.call(this, toHaveAttributeContainingFn, args);
|
|
14
|
+
}
|
|
15
|
+
exports.toHaveAttributeContaining = toHaveAttributeContaining;
|
|
16
|
+
exports.toHaveAttrContaining = toHaveAttributeContaining;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toHaveChildren = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
6
|
+
async function condition(el, options) {
|
|
7
|
+
const children = await el.$$('./*');
|
|
8
|
+
if (!options.lte && !options.gte && !options.eq) {
|
|
9
|
+
return {
|
|
10
|
+
result: children.length > 0,
|
|
11
|
+
value: children === null || children === void 0 ? void 0 : children.length
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
result: utils_1.compareNumbers(children === null || children === void 0 ? void 0 : children.length, options),
|
|
16
|
+
value: children === null || children === void 0 ? void 0 : children.length
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function toHaveChildrenFn(received, expected, options = {}) {
|
|
20
|
+
const isNot = this.isNot;
|
|
21
|
+
const { expectation = 'children', verb = 'have' } = this;
|
|
22
|
+
let numberOptions;
|
|
23
|
+
if (typeof expected === 'number') {
|
|
24
|
+
numberOptions = { eq: expected };
|
|
25
|
+
}
|
|
26
|
+
else if (typeof expected === 'object') {
|
|
27
|
+
numberOptions = expected;
|
|
28
|
+
}
|
|
29
|
+
return browser.call(async () => {
|
|
30
|
+
let el = await received;
|
|
31
|
+
let children;
|
|
32
|
+
const pass = await utils_1.waitUntil(async () => {
|
|
33
|
+
const result = await utils_1.executeCommand.call(this, el, condition, numberOptions, [numberOptions]);
|
|
34
|
+
el = result.el;
|
|
35
|
+
children = result.values;
|
|
36
|
+
return result.success;
|
|
37
|
+
}, isNot, { ...numberOptions, ...options });
|
|
38
|
+
utils_1.updateElementsArray(pass, received, el);
|
|
39
|
+
const error = utils_1.numberError(numberOptions);
|
|
40
|
+
const expected = utils_1.wrapExpectedWithArray(el, children, error);
|
|
41
|
+
const message = utils_1.enhanceError(el, expected, children, this, verb, expectation, '', numberOptions);
|
|
42
|
+
return {
|
|
43
|
+
pass,
|
|
44
|
+
message: () => message
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function toHaveChildren(...args) {
|
|
49
|
+
return expectAdapter_1.runExpect.call(this, toHaveChildrenFn, args);
|
|
50
|
+
}
|
|
51
|
+
exports.toHaveChildren = toHaveChildren;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toHaveClass = exports.toHaveElementClass = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
6
|
+
async function condition(el, attribute, value, options) {
|
|
7
|
+
const { ignoreCase = false, trim = false, containing = false } = options;
|
|
8
|
+
let attr = await el.getAttribute(attribute);
|
|
9
|
+
if (typeof attr !== 'string') {
|
|
10
|
+
return { result: false };
|
|
11
|
+
}
|
|
12
|
+
if (trim) {
|
|
13
|
+
attr = attr.trim();
|
|
14
|
+
}
|
|
15
|
+
if (ignoreCase) {
|
|
16
|
+
attr = attr.toLowerCase();
|
|
17
|
+
value = value.toLowerCase();
|
|
18
|
+
}
|
|
19
|
+
if (containing) {
|
|
20
|
+
return {
|
|
21
|
+
result: attr.includes(value),
|
|
22
|
+
value: attr
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const classes = attr.split(' ');
|
|
26
|
+
return {
|
|
27
|
+
result: classes.includes(value),
|
|
28
|
+
value: attr
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function toHaveElementClassFn(received, className, options = {}) {
|
|
32
|
+
const isNot = this.isNot;
|
|
33
|
+
const { expectation = 'class', verb = 'have' } = this;
|
|
34
|
+
const attribute = 'class';
|
|
35
|
+
return browser.call(async () => {
|
|
36
|
+
let el = await received;
|
|
37
|
+
let attr;
|
|
38
|
+
const pass = await utils_1.waitUntil(async () => {
|
|
39
|
+
const result = await utils_1.executeCommand.call(this, el, condition, options, [attribute, className, options]);
|
|
40
|
+
el = result.el;
|
|
41
|
+
attr = result.values;
|
|
42
|
+
return result.success;
|
|
43
|
+
}, isNot, options);
|
|
44
|
+
utils_1.updateElementsArray(pass, received, el);
|
|
45
|
+
const message = utils_1.enhanceError(el, utils_1.wrapExpectedWithArray(el, attr, className), attr, this, verb, expectation, '', options);
|
|
46
|
+
return {
|
|
47
|
+
pass,
|
|
48
|
+
message: () => message
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function toHaveElementClass(...args) {
|
|
53
|
+
return expectAdapter_1.runExpect.call(this, toHaveElementClassFn, args);
|
|
54
|
+
}
|
|
55
|
+
exports.toHaveElementClass = toHaveElementClass;
|
|
56
|
+
function toHaveClass(...args) {
|
|
57
|
+
console.warn('expect(...).toHaveClass is deprecated and will be removed in next release. Use toHaveElementClass instead.');
|
|
58
|
+
return expectAdapter_1.runExpect.call(this, toHaveElementClassFn, args);
|
|
59
|
+
}
|
|
60
|
+
exports.toHaveClass = toHaveClass;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toHaveClassContaining = exports.toHaveElementClassContaining = void 0;
|
|
4
|
+
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
5
|
+
const toHaveAttribute_1 = require("./toHaveAttribute");
|
|
6
|
+
function toHaveElementClassContainingFn(el, className, options = {}) {
|
|
7
|
+
return toHaveAttribute_1.toHaveAttributeAndValueFn.call(this, el, 'class', className, {
|
|
8
|
+
...options,
|
|
9
|
+
containing: true
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function toHaveElementClassContaining(...args) {
|
|
13
|
+
return expectAdapter_1.runExpect.call(this, toHaveElementClassContainingFn, args);
|
|
14
|
+
}
|
|
15
|
+
exports.toHaveElementClassContaining = toHaveElementClassContaining;
|
|
16
|
+
function toHaveClassContaining(...args) {
|
|
17
|
+
console.warn('expect(...).toHaveClassContaining is deprecated and will be removed in next release. Use toHaveElementClassContaining instead.');
|
|
18
|
+
return expectAdapter_1.runExpect.call(this, toHaveElementClassContainingFn, args);
|
|
19
|
+
}
|
|
20
|
+
exports.toHaveClassContaining = toHaveClassContaining;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toHaveElementProperty = exports.toHaveElementPropertyFn = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
6
|
+
async function condition(el, property, value, options = {}) {
|
|
7
|
+
const { asString = false } = options;
|
|
8
|
+
let prop = await el.getProperty(property);
|
|
9
|
+
if (prop === null || prop === undefined) {
|
|
10
|
+
return { result: false, value: prop };
|
|
11
|
+
}
|
|
12
|
+
if (value === null) {
|
|
13
|
+
return { result: true, value: prop };
|
|
14
|
+
}
|
|
15
|
+
if (typeof value !== 'string' || (typeof prop !== 'string' && !asString)) {
|
|
16
|
+
return { result: prop === value, value: prop };
|
|
17
|
+
}
|
|
18
|
+
prop = prop.toString();
|
|
19
|
+
return utils_1.compareText(prop, value, options);
|
|
20
|
+
}
|
|
21
|
+
function toHaveElementPropertyFn(received, property, value, options = {}) {
|
|
22
|
+
const isNot = this.isNot;
|
|
23
|
+
const { expectation = 'property', verb = 'have' } = this;
|
|
24
|
+
return browser.call(async () => {
|
|
25
|
+
let el = await received;
|
|
26
|
+
let prop;
|
|
27
|
+
const pass = await utils_1.waitUntil(async () => {
|
|
28
|
+
const result = await utils_1.executeCommand.call(this, el, condition, options, [property, value]);
|
|
29
|
+
el = result.el;
|
|
30
|
+
prop = result.values;
|
|
31
|
+
return result.success;
|
|
32
|
+
}, isNot, options);
|
|
33
|
+
utils_1.updateElementsArray(pass, received, el);
|
|
34
|
+
let message;
|
|
35
|
+
if (value === undefined) {
|
|
36
|
+
message = utils_1.enhanceError(el, !isNot, pass, this, verb, expectation, property, options);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
const expected = utils_1.wrapExpectedWithArray(el, prop, value);
|
|
40
|
+
message = utils_1.enhanceError(el, expected, prop, this, verb, expectation, property, options);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
pass,
|
|
44
|
+
message: () => message,
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
exports.toHaveElementPropertyFn = toHaveElementPropertyFn;
|
|
49
|
+
function toHaveElementProperty(...args) {
|
|
50
|
+
return expectAdapter_1.runExpect.call(this, toHaveElementPropertyFn, args);
|
|
51
|
+
}
|
|
52
|
+
exports.toHaveElementProperty = toHaveElementProperty;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toHaveLink = exports.toHaveHref = exports.toHaveHrefFn = void 0;
|
|
4
|
+
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
5
|
+
const toHaveAttribute_1 = require("./toHaveAttribute");
|
|
6
|
+
function toHaveHrefFn(el, href, options = {}) {
|
|
7
|
+
return toHaveAttribute_1.toHaveAttributeAndValueFn.call(this, el, 'href', href, options);
|
|
8
|
+
}
|
|
9
|
+
exports.toHaveHrefFn = toHaveHrefFn;
|
|
10
|
+
function toHaveHref(...args) {
|
|
11
|
+
return expectAdapter_1.runExpect.call(this, toHaveHrefFn, args);
|
|
12
|
+
}
|
|
13
|
+
exports.toHaveHref = toHaveHref;
|
|
14
|
+
exports.toHaveLink = toHaveHref;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toHaveLinkContaining = exports.toHaveHrefContaining = void 0;
|
|
4
|
+
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
5
|
+
const toHaveHref_1 = require("./toHaveHref");
|
|
6
|
+
function toHaveHrefContainingFn(el, href, options = {}) {
|
|
7
|
+
return toHaveHref_1.toHaveHrefFn.call(this, el, href, {
|
|
8
|
+
...options,
|
|
9
|
+
containing: true
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function toHaveHrefContaining(...args) {
|
|
13
|
+
return expectAdapter_1.runExpect.call(this, toHaveHrefContainingFn, args);
|
|
14
|
+
}
|
|
15
|
+
exports.toHaveHrefContaining = toHaveHrefContaining;
|
|
16
|
+
exports.toHaveLinkContaining = toHaveHrefContaining;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toHaveId = exports.toHaveIdFn = void 0;
|
|
4
|
+
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
5
|
+
const toHaveAttribute_1 = require("./toHaveAttribute");
|
|
6
|
+
function toHaveIdFn(el, id, options = {}) {
|
|
7
|
+
return toHaveAttribute_1.toHaveAttributeAndValueFn.call(this, el, 'id', id, options);
|
|
8
|
+
}
|
|
9
|
+
exports.toHaveIdFn = toHaveIdFn;
|
|
10
|
+
function toHaveId(...args) {
|
|
11
|
+
return expectAdapter_1.runExpect.call(this, toHaveIdFn, args);
|
|
12
|
+
}
|
|
13
|
+
exports.toHaveId = toHaveId;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toHaveStyle = exports.toHaveStyleFn = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
6
|
+
async function condition(el, style, options) {
|
|
7
|
+
return utils_1.compareStyle(el, style, options);
|
|
8
|
+
}
|
|
9
|
+
function toHaveStyleFn(received, style, options = {}) {
|
|
10
|
+
const isNot = this.isNot;
|
|
11
|
+
const { expectation = 'style', verb = 'have' } = this;
|
|
12
|
+
return browser.call(async () => {
|
|
13
|
+
let el = await received;
|
|
14
|
+
let actualStyle;
|
|
15
|
+
const pass = await utils_1.waitUntil(async () => {
|
|
16
|
+
const result = await utils_1.executeCommand.call(this, el, condition, options, [style, options]);
|
|
17
|
+
el = result.el;
|
|
18
|
+
actualStyle = result.values;
|
|
19
|
+
return result.success;
|
|
20
|
+
}, isNot, options);
|
|
21
|
+
utils_1.updateElementsArray(pass, received, el);
|
|
22
|
+
const message = utils_1.enhanceError(el, utils_1.wrapExpectedWithArray(el, actualStyle, style), actualStyle, this, verb, expectation, '', options);
|
|
23
|
+
return {
|
|
24
|
+
pass,
|
|
25
|
+
message: () => message
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
exports.toHaveStyleFn = toHaveStyleFn;
|
|
30
|
+
function toHaveStyle(...args) {
|
|
31
|
+
return expectAdapter_1.runExpect.call(this, toHaveStyleFn, args);
|
|
32
|
+
}
|
|
33
|
+
exports.toHaveStyle = toHaveStyle;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toHaveText = exports.toHaveTextFn = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
6
|
+
async function condition(el, text, options) {
|
|
7
|
+
const actualText = await el.getText();
|
|
8
|
+
if (Array.isArray(text)) {
|
|
9
|
+
return utils_1.compareTextWithArray(actualText, text, options);
|
|
10
|
+
}
|
|
11
|
+
return utils_1.compareText(actualText, text, options);
|
|
12
|
+
}
|
|
13
|
+
function toHaveTextFn(received, text, options = {}) {
|
|
14
|
+
const isNot = this.isNot;
|
|
15
|
+
const { expectation = 'text', verb = 'have' } = this;
|
|
16
|
+
return browser.call(async () => {
|
|
17
|
+
let el = await received;
|
|
18
|
+
let actualText;
|
|
19
|
+
const pass = await utils_1.waitUntil(async () => {
|
|
20
|
+
const result = await utils_1.executeCommand.call(this, el, condition, options, [text, options]);
|
|
21
|
+
el = result.el;
|
|
22
|
+
actualText = result.values;
|
|
23
|
+
return result.success;
|
|
24
|
+
}, isNot, options);
|
|
25
|
+
utils_1.updateElementsArray(pass, received, el);
|
|
26
|
+
const message = utils_1.enhanceError(el, utils_1.wrapExpectedWithArray(el, actualText, text), actualText, this, verb, expectation, '', options);
|
|
27
|
+
return {
|
|
28
|
+
pass,
|
|
29
|
+
message: () => message
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
exports.toHaveTextFn = toHaveTextFn;
|
|
34
|
+
function toHaveText(...args) {
|
|
35
|
+
return expectAdapter_1.runExpect.call(this, toHaveTextFn, args);
|
|
36
|
+
}
|
|
37
|
+
exports.toHaveText = toHaveText;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toHaveTextContaining = void 0;
|
|
4
|
+
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
5
|
+
const toHaveText_1 = require("./toHaveText");
|
|
6
|
+
function toHaveTextContainingFn(el, text, options = {}) {
|
|
7
|
+
return toHaveText_1.toHaveTextFn.call(this, el, text, {
|
|
8
|
+
...options,
|
|
9
|
+
containing: true
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function toHaveTextContaining(...args) {
|
|
13
|
+
return expectAdapter_1.runExpect.call(this, toHaveTextContainingFn, args);
|
|
14
|
+
}
|
|
15
|
+
exports.toHaveTextContaining = toHaveTextContaining;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toHaveValue = exports.toHaveValueFn = void 0;
|
|
4
|
+
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
5
|
+
const toHaveElementProperty_1 = require("./toHaveElementProperty");
|
|
6
|
+
function toHaveValueFn(el, value, options = {}) {
|
|
7
|
+
return toHaveElementProperty_1.toHaveElementPropertyFn.call(this, el, 'value', value, options);
|
|
8
|
+
}
|
|
9
|
+
exports.toHaveValueFn = toHaveValueFn;
|
|
10
|
+
function toHaveValue(...args) {
|
|
11
|
+
return expectAdapter_1.runExpect.call(this, toHaveValueFn, args);
|
|
12
|
+
}
|
|
13
|
+
exports.toHaveValue = toHaveValue;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toHaveValueContaining = void 0;
|
|
4
|
+
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
5
|
+
const toHaveValue_1 = require("./toHaveValue");
|
|
6
|
+
function toHaveValueContainingFn(el, value, options = {}) {
|
|
7
|
+
return toHaveValue_1.toHaveValueFn.call(this, el, value, {
|
|
8
|
+
...options,
|
|
9
|
+
containing: true
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function toHaveValueContaining(...args) {
|
|
13
|
+
return expectAdapter_1.runExpect.call(this, toHaveValueContainingFn, args);
|
|
14
|
+
}
|
|
15
|
+
exports.toHaveValueContaining = toHaveValueContaining;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toBeElementsArrayOfSize = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const refetchElements_1 = require("../../util/refetchElements");
|
|
6
|
+
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
7
|
+
function toBeElementsArrayOfSizeFn(received, expected, options = {}) {
|
|
8
|
+
const isNot = this.isNot;
|
|
9
|
+
const { expectation = 'elements array of size', verb = 'be' } = this;
|
|
10
|
+
let numberOptions;
|
|
11
|
+
if (typeof expected === 'number') {
|
|
12
|
+
numberOptions = { eq: expected };
|
|
13
|
+
}
|
|
14
|
+
else if (!expected || (typeof expected.eq !== 'number' && typeof expected.gte !== 'number' && typeof expected.lte !== 'number')) {
|
|
15
|
+
throw new Error('Invalid params passed to toBeElementsArrayOfSize.');
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
numberOptions = expected;
|
|
19
|
+
}
|
|
20
|
+
return browser.call(async () => {
|
|
21
|
+
let elements = await received;
|
|
22
|
+
const arrLength = elements.length;
|
|
23
|
+
const pass = await utils_1.waitUntil(async () => {
|
|
24
|
+
elements = await refetchElements_1.refetchElements(elements, numberOptions.wait, true);
|
|
25
|
+
return utils_1.compareNumbers(elements.length, numberOptions);
|
|
26
|
+
}, isNot, { ...numberOptions, ...options });
|
|
27
|
+
utils_1.updateElementsArray(pass, received, elements, true);
|
|
28
|
+
const error = utils_1.numberError(numberOptions);
|
|
29
|
+
const message = utils_1.enhanceError(elements, error, arrLength, this, verb, expectation, '', numberOptions);
|
|
30
|
+
return {
|
|
31
|
+
pass,
|
|
32
|
+
message: () => message
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function toBeElementsArrayOfSize(...args) {
|
|
37
|
+
return expectAdapter_1.runExpect.call(this, toBeElementsArrayOfSizeFn, args);
|
|
38
|
+
}
|
|
39
|
+
exports.toBeElementsArrayOfSize = toBeElementsArrayOfSize;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toBeRequested = void 0;
|
|
4
|
+
const toBeRequestedTimes_1 = require("./toBeRequestedTimes");
|
|
5
|
+
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
6
|
+
function toBeRequestedFn(received, options = {}) {
|
|
7
|
+
return toBeRequestedTimes_1.toBeRequestedTimes.call({ ...(this || {}), expectation: 'called' }, received, { ...options, gte: 1 });
|
|
8
|
+
}
|
|
9
|
+
function toBeRequested(...args) {
|
|
10
|
+
return expectAdapter_1.runExpect.call(this, toBeRequestedFn, args);
|
|
11
|
+
}
|
|
12
|
+
exports.toBeRequested = toBeRequested;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toBeRequestedTimes = exports.toBeRequestedTimesFn = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
6
|
+
const formatMessage_1 = require("../../util/formatMessage");
|
|
7
|
+
function toBeRequestedTimesFn(received, expected = {}, options = {}) {
|
|
8
|
+
const isNot = this.isNot || false;
|
|
9
|
+
const { expectation = `called${typeof expected === 'number' ? ' ' + expected : ''} time${expected !== 1 ? 's' : ''}`, verb = 'be' } = this;
|
|
10
|
+
let numberOptions;
|
|
11
|
+
if (typeof expected === 'number') {
|
|
12
|
+
numberOptions = { eq: expected };
|
|
13
|
+
}
|
|
14
|
+
else if (typeof expected === 'object') {
|
|
15
|
+
numberOptions = expected;
|
|
16
|
+
}
|
|
17
|
+
return browser.call(async () => {
|
|
18
|
+
let actual;
|
|
19
|
+
const pass = await utils_1.waitUntil(async () => {
|
|
20
|
+
actual = received.calls.length;
|
|
21
|
+
return utils_1.compareNumbers(actual, numberOptions);
|
|
22
|
+
}, isNot, { ...numberOptions, ...options });
|
|
23
|
+
const error = formatMessage_1.numberError(numberOptions);
|
|
24
|
+
const message = utils_1.enhanceError('mock', error, actual, this, verb, expectation, '', numberOptions);
|
|
25
|
+
return {
|
|
26
|
+
pass,
|
|
27
|
+
message: () => message
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
exports.toBeRequestedTimesFn = toBeRequestedTimesFn;
|
|
32
|
+
function toBeRequestedTimes(...args) {
|
|
33
|
+
return expectAdapter_1.runExpect.call(this, toBeRequestedTimesFn, args);
|
|
34
|
+
}
|
|
35
|
+
exports.toBeRequestedTimes = toBeRequestedTimes;
|