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.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +65 -0
  3. package/jasmine.d.ts +6 -0
  4. package/jest.d.ts +5 -0
  5. package/lib/addMatchers.js +48 -0
  6. package/lib/index.js +6 -0
  7. package/lib/jasmineUtils.js +205 -0
  8. package/lib/matchers/browser/toHaveTitle.js +26 -0
  9. package/lib/matchers/browser/toHaveTitleContaining.js +15 -0
  10. package/lib/matchers/browser/toHaveUrl.js +26 -0
  11. package/lib/matchers/browser/toHaveUrlContaining.js +15 -0
  12. package/lib/matchers/element/toBeClickable.js +23 -0
  13. package/lib/matchers/element/toBeDisabled.js +16 -0
  14. package/lib/matchers/element/toBeDisplayed.js +23 -0
  15. package/lib/matchers/element/toBeDisplayedInViewport.js +23 -0
  16. package/lib/matchers/element/toBeEnabled.js +16 -0
  17. package/lib/matchers/element/toBeExisting.js +32 -0
  18. package/lib/matchers/element/toBeFocused.js +16 -0
  19. package/lib/matchers/element/toBeSelected.js +22 -0
  20. package/lib/matchers/element/toHaveAttribute.js +72 -0
  21. package/lib/matchers/element/toHaveAttributeContaining.js +16 -0
  22. package/lib/matchers/element/toHaveChildren.js +51 -0
  23. package/lib/matchers/element/toHaveElementClass.js +60 -0
  24. package/lib/matchers/element/toHaveElementClassContaining.js +20 -0
  25. package/lib/matchers/element/toHaveElementProperty.js +52 -0
  26. package/lib/matchers/element/toHaveHref.js +14 -0
  27. package/lib/matchers/element/toHaveHrefContaining.js +16 -0
  28. package/lib/matchers/element/toHaveId.js +13 -0
  29. package/lib/matchers/element/toHaveStyle.js +33 -0
  30. package/lib/matchers/element/toHaveText.js +37 -0
  31. package/lib/matchers/element/toHaveTextContaining.js +15 -0
  32. package/lib/matchers/element/toHaveValue.js +13 -0
  33. package/lib/matchers/element/toHaveValueContaining.js +15 -0
  34. package/lib/matchers/elements/toBeElementsArrayOfSize.js +39 -0
  35. package/lib/matchers/mock/toBeRequested.js +12 -0
  36. package/lib/matchers/mock/toBeRequestedTimes.js +35 -0
  37. package/lib/matchers/mock/toBeRequestedWith.js +218 -0
  38. package/lib/matchers/mock/toBeRequestedWithResponse.js +13 -0
  39. package/lib/matchers.js +41 -0
  40. package/lib/options.js +33 -0
  41. package/lib/util/elementsUtil.js +28 -0
  42. package/lib/util/executeCommand.js +31 -0
  43. package/lib/util/expectAdapter.js +41 -0
  44. package/lib/util/formatMessage.js +93 -0
  45. package/lib/util/refetchElements.js +15 -0
  46. package/lib/utils.js +161 -0
  47. package/package.json +68 -0
  48. package/types/expect-webdriverio.d.ts +327 -0
  49. package/types/jest-global.d.ts +9 -0
  50. package/types/standalone-global.d.ts +9 -0
  51. package/types/standalone.d.ts +24 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Mykola Grybyk
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # expect-webdriverio
2
+
3
+ [![Test](https://github.com/webdriverio/expect-webdriverio/actions/workflows/test.yml/badge.svg)](https://github.com/webdriverio/expect-webdriverio/actions/workflows/test.yml)
4
+
5
+ ###### [API](docs/API.md) | [TypeScript / JS Autocomplete](/docs/Types.md) | [Examples](docs/Examples.md) | [Extending Matchers](/docs/Extend.md)
6
+
7
+ > [WebdriverIO](https://webdriver.io/) Assertion library inspired by [expect](https://www.npmjs.com/package/expect)
8
+
9
+ ## Key Features
10
+
11
+ - [waits](#default-options) for expectation to succeed
12
+ - detailed [error messages](#error-messages)
13
+ - works in Mocha, Cucumber, Jest, Jasmine
14
+ - builtin [types](docs/Types.md) for TypeScript and JS autocompletion
15
+
16
+ ## Installation
17
+
18
+ 1. `npm install expect` (**Jasmine** and **Jest** users should skip this step)
19
+ 2. `npm install expect-webdriverio`
20
+
21
+ NOTE: [WebdriverIO](https://github.com/webdriverio/webdriverio) `v5.16.11` or higher is required!
22
+
23
+ ## Usage
24
+
25
+ In your `wdio.conf.js`
26
+ ```js
27
+ before () { // not needed in WebdriverIO v6
28
+ require('expect-webdriverio')
29
+ },
30
+ ```
31
+
32
+ In your test
33
+ ```js
34
+ const $button = $('button')
35
+ expect($button).toBeDisplayed()
36
+ ```
37
+
38
+ See more [Examples](docs/Examples.md)
39
+
40
+ ## API
41
+
42
+ Please see [API doc](docs/API.md)
43
+
44
+ ## Error messages
45
+
46
+ Error messages are informative out of the box and contain:
47
+
48
+ - full element selector, like `$('form').$('input')`
49
+ - actual and expected values
50
+ - highlight the difference (texts assertions)
51
+
52
+ ![toHaveText](/docs/img/errors/text.png?raw=true "toHaveText")
53
+ ![toHaveElementClass](/docs/img/errors/class.png?raw=true "toHaveElementClass")
54
+
55
+ ## What's next?
56
+
57
+ First of all, **feel free to raise an issue with your suggestions or help with PR!**
58
+
59
+ ### Planned
60
+
61
+ - css matcher
62
+ - size matcher
63
+ - cookie / localStorage matchers?
64
+ - text regex matchers
65
+ - multiremote support (if requested)
package/jasmine.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ /// <reference types="expect-webdriverio/types/expect-webdriverio"/>
2
+
3
+ declare module jasmine {
4
+ interface Matchers<T> extends ExpectWebdriverIO.Matchers<any, T> {}
5
+ interface AsyncMatchers<T, U> extends ExpectWebdriverIO.Matchers<Promise<void>, T> {}
6
+ }
package/jest.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /// <reference types="expect-webdriverio/types/expect-webdriverio"/>
2
+
3
+ declare namespace jest {
4
+ interface Matchers<R, T> extends ExpectWebdriverIO.Matchers<R, T> { }
5
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addMatchers = exports.loadExpect = exports.isJasmine = void 0;
4
+ let expectLib;
5
+ const isJasmine = () => {
6
+ return Boolean(global.jasmine && global.expect && global.expectAsync && global.jasmine.getEnv && global.jasmine.addMatchers && global.jasmine.addAsyncMatchers);
7
+ };
8
+ exports.isJasmine = isJasmine;
9
+ const loadExpect = () => {
10
+ try {
11
+ return expectLib = require('expect');
12
+ }
13
+ catch (err) {
14
+ return console.error('Failed to load expect package. Make sure it has been installed: npm i expect');
15
+ }
16
+ };
17
+ exports.loadExpect = loadExpect;
18
+ const addMatchers = () => {
19
+ if (global.expect === undefined) {
20
+ if (!exports.loadExpect()) {
21
+ return;
22
+ }
23
+ global.expect = expectLib;
24
+ }
25
+ else {
26
+ expectLib = global.expect;
27
+ }
28
+ if (!global.expect.extend && !exports.isJasmine()) {
29
+ if (!exports.loadExpect()) {
30
+ return;
31
+ }
32
+ global.expectWdio = expectLib;
33
+ console.warn('Warning! Unsupported expect lib is used.\n' +
34
+ "Only Jasmine >= 3.3.0 and Jest's expect are supported.\n" +
35
+ "expect-webdriverio is assigned to global.expectWdio");
36
+ }
37
+ require('./options').setDefaultOptions;
38
+ const matchers = require('./matchers').default;
39
+ if (expectLib.extend) {
40
+ return expectLib.extend({ ...matchers });
41
+ }
42
+ expectLib = global.jasmine;
43
+ return expectLib.getEnv().beforeAll(function addExpectWebdriverIOMatchers() {
44
+ expectLib.addAsyncMatchers({ ...matchers });
45
+ global.expect = global.expectAsync;
46
+ });
47
+ };
48
+ exports.addMatchers = addMatchers;
package/lib/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setOptions = void 0;
4
+ const addMatchers_1 = require("./addMatchers");
5
+ addMatchers_1.addMatchers();
6
+ exports.setOptions = require('./options').setDefaultOptions;
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isImmutableUnorderedSet = exports.isImmutableUnorderedKeyed = exports.hasProperty = exports.isUndefined = exports.fnNameFor = exports.isA = exports.equals = void 0;
4
+ function equals(a, b, customTesters, strictCheck) {
5
+ customTesters = customTesters || [];
6
+ return eq(a, b, [], [], customTesters, strictCheck ? hasKey : hasDefinedKey);
7
+ }
8
+ exports.equals = equals;
9
+ const functionToString = Function.prototype.toString;
10
+ function isAsymmetric(obj) {
11
+ return !!obj && isA('Function', obj.asymmetricMatch);
12
+ }
13
+ function asymmetricMatch(a, b) {
14
+ var asymmetricA = isAsymmetric(a), asymmetricB = isAsymmetric(b);
15
+ if (asymmetricA && asymmetricB) {
16
+ return undefined;
17
+ }
18
+ if (asymmetricA) {
19
+ return a.asymmetricMatch(b);
20
+ }
21
+ if (asymmetricB) {
22
+ return b.asymmetricMatch(a);
23
+ }
24
+ }
25
+ function eq(a, b, aStack, bStack, customTesters, hasKey) {
26
+ var result = true;
27
+ var asymmetricResult = asymmetricMatch(a, b);
28
+ if (asymmetricResult !== undefined) {
29
+ return asymmetricResult;
30
+ }
31
+ for (var i = 0; i < customTesters.length; i++) {
32
+ var customTesterResult = customTesters[i](a, b);
33
+ if (customTesterResult !== undefined) {
34
+ return customTesterResult;
35
+ }
36
+ }
37
+ if (a instanceof Error && b instanceof Error) {
38
+ return a.message == b.message;
39
+ }
40
+ if (Object.is(a, b)) {
41
+ return true;
42
+ }
43
+ if (a === null || b === null) {
44
+ return a === b;
45
+ }
46
+ var className = Object.prototype.toString.call(a);
47
+ if (className != Object.prototype.toString.call(b)) {
48
+ return false;
49
+ }
50
+ switch (className) {
51
+ case '[object Boolean]':
52
+ case '[object String]':
53
+ case '[object Number]':
54
+ if (typeof a !== typeof b) {
55
+ return false;
56
+ }
57
+ else if (typeof a !== 'object' && typeof b !== 'object') {
58
+ return Object.is(a, b);
59
+ }
60
+ else {
61
+ return Object.is(a.valueOf(), b.valueOf());
62
+ }
63
+ case '[object Date]':
64
+ return +a == +b;
65
+ case '[object RegExp]':
66
+ return a.source === b.source && a.flags === b.flags;
67
+ }
68
+ if (typeof a !== 'object' || typeof b !== 'object') {
69
+ return false;
70
+ }
71
+ if (isDomNode(a) && isDomNode(b)) {
72
+ return a.isEqualNode(b);
73
+ }
74
+ var length = aStack.length;
75
+ while (length--) {
76
+ if (aStack[length] === a) {
77
+ return bStack[length] === b;
78
+ }
79
+ else if (bStack[length] === b) {
80
+ return false;
81
+ }
82
+ }
83
+ aStack.push(a);
84
+ bStack.push(b);
85
+ var size = 0;
86
+ if (className == '[object Array]') {
87
+ size = a.length;
88
+ if (size !== b.length) {
89
+ return false;
90
+ }
91
+ while (size--) {
92
+ result = eq(a[size], b[size], aStack, bStack, customTesters, hasKey);
93
+ if (!result) {
94
+ return false;
95
+ }
96
+ }
97
+ }
98
+ var aKeys = keys(a, className == '[object Array]', hasKey), key;
99
+ size = aKeys.length;
100
+ if (keys(b, className == '[object Array]', hasKey).length !== size) {
101
+ return false;
102
+ }
103
+ while (size--) {
104
+ key = aKeys[size];
105
+ result =
106
+ hasKey(b, key) &&
107
+ eq(a[key], b[key], aStack, bStack, customTesters, hasKey);
108
+ if (!result) {
109
+ return false;
110
+ }
111
+ }
112
+ aStack.pop();
113
+ bStack.pop();
114
+ return result;
115
+ }
116
+ function keys(obj, isArray, hasKey) {
117
+ var allKeys = (function (o) {
118
+ var keys = [];
119
+ for (var key in o) {
120
+ if (hasKey(o, key)) {
121
+ keys.push(key);
122
+ }
123
+ }
124
+ return keys.concat(Object.getOwnPropertySymbols(o).filter(symbol => Object.getOwnPropertyDescriptor(o, symbol)
125
+ .enumerable));
126
+ })(obj);
127
+ if (!isArray) {
128
+ return allKeys;
129
+ }
130
+ var extraKeys = [];
131
+ if (allKeys.length === 0) {
132
+ return allKeys;
133
+ }
134
+ for (var x = 0; x < allKeys.length; x++) {
135
+ if (typeof allKeys[x] === 'symbol' || !allKeys[x].match(/^[0-9]+$/)) {
136
+ extraKeys.push(allKeys[x]);
137
+ }
138
+ }
139
+ return extraKeys;
140
+ }
141
+ function hasDefinedKey(obj, key) {
142
+ return hasKey(obj, key) && obj[key] !== undefined;
143
+ }
144
+ function hasKey(obj, key) {
145
+ return Object.prototype.hasOwnProperty.call(obj, key);
146
+ }
147
+ function isA(typeName, value) {
148
+ return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';
149
+ }
150
+ exports.isA = isA;
151
+ function isDomNode(obj) {
152
+ return (obj !== null &&
153
+ typeof obj === 'object' &&
154
+ typeof obj.nodeType === 'number' &&
155
+ typeof obj.nodeName === 'string' &&
156
+ typeof obj.isEqualNode === 'function');
157
+ }
158
+ function fnNameFor(func) {
159
+ if (func.name) {
160
+ return func.name;
161
+ }
162
+ const matches = functionToString
163
+ .call(func)
164
+ .match(/^(?:async)?\s*function\s*\*?\s*([\w$]+)\s*\(/);
165
+ return matches ? matches[1] : '<anonymous>';
166
+ }
167
+ exports.fnNameFor = fnNameFor;
168
+ function isUndefined(obj) {
169
+ return obj === void 0;
170
+ }
171
+ exports.isUndefined = isUndefined;
172
+ function getPrototype(obj) {
173
+ if (Object.getPrototypeOf) {
174
+ return Object.getPrototypeOf(obj);
175
+ }
176
+ if (obj.constructor.prototype == obj) {
177
+ return null;
178
+ }
179
+ return obj.constructor.prototype;
180
+ }
181
+ function hasProperty(obj, property) {
182
+ if (!obj) {
183
+ return false;
184
+ }
185
+ if (Object.prototype.hasOwnProperty.call(obj, property)) {
186
+ return true;
187
+ }
188
+ return hasProperty(getPrototype(obj), property);
189
+ }
190
+ exports.hasProperty = hasProperty;
191
+ const IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
192
+ const IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
193
+ const IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
194
+ function isImmutableUnorderedKeyed(maybeKeyed) {
195
+ return !!(maybeKeyed &&
196
+ maybeKeyed[IS_KEYED_SENTINEL] &&
197
+ !maybeKeyed[IS_ORDERED_SENTINEL]);
198
+ }
199
+ exports.isImmutableUnorderedKeyed = isImmutableUnorderedKeyed;
200
+ function isImmutableUnorderedSet(maybeSet) {
201
+ return !!(maybeSet &&
202
+ maybeSet[IS_SET_SENTINEL] &&
203
+ !maybeSet[IS_ORDERED_SENTINEL]);
204
+ }
205
+ exports.isImmutableUnorderedSet = isImmutableUnorderedSet;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toHaveTitle = exports.toHaveTitleFn = void 0;
4
+ const expectAdapter_1 = require("../../util/expectAdapter");
5
+ const utils_1 = require("../../utils");
6
+ function toHaveTitleFn(browser, title, options = {}) {
7
+ const isNot = this.isNot;
8
+ const { expectation = 'title', verb = 'have' } = this;
9
+ return browser.call(async () => {
10
+ let actual;
11
+ const pass = await utils_1.waitUntil(async () => {
12
+ actual = await browser.getTitle();
13
+ return utils_1.compareText(actual, title, options).result;
14
+ }, isNot, options);
15
+ const message = utils_1.enhanceError('window', title, actual, this, verb, expectation, '', options);
16
+ return {
17
+ pass,
18
+ message: () => message
19
+ };
20
+ });
21
+ }
22
+ exports.toHaveTitleFn = toHaveTitleFn;
23
+ function toHaveTitle(...args) {
24
+ return expectAdapter_1.runExpect.call(this, toHaveTitleFn, args);
25
+ }
26
+ exports.toHaveTitle = toHaveTitle;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toHaveTitleContaining = void 0;
4
+ const expectAdapter_1 = require("../../util/expectAdapter");
5
+ const toHaveTitle_1 = require("./toHaveTitle");
6
+ function toHaveTitleContainingFn(browser, title, options = {}) {
7
+ return toHaveTitle_1.toHaveTitleFn.call(this, browser, title, {
8
+ ...options,
9
+ containing: true
10
+ });
11
+ }
12
+ function toHaveTitleContaining(...args) {
13
+ return expectAdapter_1.runExpect.call(this, toHaveTitleContainingFn, args);
14
+ }
15
+ exports.toHaveTitleContaining = toHaveTitleContaining;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toHaveUrl = exports.toHaveUrlFn = void 0;
4
+ const expectAdapter_1 = require("../../util/expectAdapter");
5
+ const utils_1 = require("../../utils");
6
+ function toHaveUrlFn(browser, url, options = {}) {
7
+ const isNot = this.isNot;
8
+ const { expectation = 'url', verb = 'have' } = this;
9
+ return browser.call(async () => {
10
+ let actual;
11
+ const pass = await utils_1.waitUntil(async () => {
12
+ actual = await browser.getUrl();
13
+ return utils_1.compareText(actual, url, options).result;
14
+ }, isNot, options);
15
+ const message = utils_1.enhanceError('window', url, actual, this, verb, expectation, '', options);
16
+ return {
17
+ pass,
18
+ message: () => message
19
+ };
20
+ });
21
+ }
22
+ exports.toHaveUrlFn = toHaveUrlFn;
23
+ function toHaveUrl(...args) {
24
+ return expectAdapter_1.runExpect.call(this, toHaveUrlFn, args);
25
+ }
26
+ exports.toHaveUrl = toHaveUrl;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toHaveUrlContaining = void 0;
4
+ const expectAdapter_1 = require("../../util/expectAdapter");
5
+ const toHaveUrl_1 = require("./toHaveUrl");
6
+ function toHaveUrlContainingFn(browser, url, options = {}) {
7
+ return toHaveUrl_1.toHaveUrlFn.call(this, browser, url, {
8
+ ...options,
9
+ containing: true
10
+ });
11
+ }
12
+ function toHaveUrlContaining(...args) {
13
+ return expectAdapter_1.runExpect.call(this, toHaveUrlContainingFn, args);
14
+ }
15
+ exports.toHaveUrlContaining = toHaveUrlContaining;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toBeClickable = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const expectAdapter_1 = require("../../util/expectAdapter");
6
+ function toBeClickableFn(received, options = {}) {
7
+ this.expectation = this.expectation || 'clickable';
8
+ return browser.call(async () => {
9
+ const result = await utils_1.executeCommandBe.call(this, received, async (el) => {
10
+ try {
11
+ return el.isClickable();
12
+ }
13
+ catch (_a) {
14
+ return false;
15
+ }
16
+ }, options);
17
+ return result;
18
+ });
19
+ }
20
+ function toBeClickable(...args) {
21
+ return expectAdapter_1.runExpect.call(this, toBeClickableFn, args);
22
+ }
23
+ exports.toBeClickable = toBeClickable;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toBeDisabled = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const expectAdapter_1 = require("../../util/expectAdapter");
6
+ function toBeDisabledFn(received, options = {}) {
7
+ this.expectation = this.expectation || 'disabled';
8
+ return browser.call(async () => {
9
+ const result = await utils_1.executeCommandBe.call(this, received, async (el) => !await el.isEnabled(), options);
10
+ return result;
11
+ });
12
+ }
13
+ function toBeDisabled(...args) {
14
+ return expectAdapter_1.runExpect.call(this, toBeDisabledFn, args);
15
+ }
16
+ exports.toBeDisabled = toBeDisabled;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toBeDisplayed = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const expectAdapter_1 = require("../../util/expectAdapter");
6
+ function toBeDisplayedFn(received, options = {}) {
7
+ this.expectation = this.expectation || 'displayed';
8
+ return browser.call(async () => {
9
+ const result = await utils_1.executeCommandBe.call(this, received, async (el) => {
10
+ try {
11
+ return el.isDisplayed();
12
+ }
13
+ catch (_a) {
14
+ return false;
15
+ }
16
+ }, options);
17
+ return result;
18
+ });
19
+ }
20
+ function toBeDisplayed(...args) {
21
+ return expectAdapter_1.runExpect.call(this, toBeDisplayedFn, args);
22
+ }
23
+ exports.toBeDisplayed = toBeDisplayed;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toBeDisplayedInViewport = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const expectAdapter_1 = require("../../util/expectAdapter");
6
+ function toBeDisplayedInViewportFn(received, options = {}) {
7
+ this.expectation = this.expectation || 'displayed in viewport';
8
+ return browser.call(async () => {
9
+ const result = await utils_1.executeCommandBe.call(this, received, async (el) => {
10
+ try {
11
+ return el.isDisplayedInViewport();
12
+ }
13
+ catch (_a) {
14
+ return false;
15
+ }
16
+ }, options);
17
+ return result;
18
+ });
19
+ }
20
+ function toBeDisplayedInViewport(...args) {
21
+ return expectAdapter_1.runExpect.call(this, toBeDisplayedInViewportFn, args);
22
+ }
23
+ exports.toBeDisplayedInViewport = toBeDisplayedInViewport;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toBeEnabled = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const expectAdapter_1 = require("../../util/expectAdapter");
6
+ function toBeEnabledFn(received, options = {}) {
7
+ this.expectation = this.expectation || 'enabled';
8
+ return browser.call(async () => {
9
+ const result = await utils_1.executeCommandBe.call(this, received, el => el.isEnabled(), options);
10
+ return result;
11
+ });
12
+ }
13
+ function toBeEnabled(...args) {
14
+ return expectAdapter_1.runExpect.call(this, toBeEnabledFn, args);
15
+ }
16
+ exports.toBeEnabled = toBeEnabled;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toBePresent = exports.toBeExisting = exports.toExist = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const expectAdapter_1 = require("../../util/expectAdapter");
6
+ function toExistFn(received, options = {}) {
7
+ this.expectation = this.expectation || 'exist';
8
+ this.verb = this.verb || '';
9
+ return browser.call(async () => {
10
+ const result = await utils_1.executeCommandBe.call(this, received, async (el) => {
11
+ try {
12
+ return el.isExisting();
13
+ }
14
+ catch (_a) {
15
+ return false;
16
+ }
17
+ }, options);
18
+ return result;
19
+ });
20
+ }
21
+ function toExist(...args) {
22
+ return expectAdapter_1.runExpect.call(this, toExistFn, args);
23
+ }
24
+ exports.toExist = toExist;
25
+ function toBeExisting(el, options) {
26
+ return utils_1.aliasFn.call(this, toExist, { verb: 'be', expectation: 'existing' }, el, options);
27
+ }
28
+ exports.toBeExisting = toBeExisting;
29
+ function toBePresent(el, options) {
30
+ return utils_1.aliasFn.call(this, toExist, { verb: 'be', expectation: 'present' }, el, options);
31
+ }
32
+ exports.toBePresent = toBePresent;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toBeFocused = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const expectAdapter_1 = require("../../util/expectAdapter");
6
+ function toBeFocusedFn(received, options = {}) {
7
+ this.expectation = this.expectation || 'focused';
8
+ return browser.call(async () => {
9
+ const result = await utils_1.executeCommandBe.call(this, received, el => el.isFocused(), options);
10
+ return result;
11
+ });
12
+ }
13
+ function toBeFocused(...args) {
14
+ return expectAdapter_1.runExpect.call(this, toBeFocusedFn, args);
15
+ }
16
+ exports.toBeFocused = toBeFocused;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toBeChecked = exports.toBeSelected = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const expectAdapter_1 = require("../../util/expectAdapter");
6
+ function toBeSelectedFn(received, options = {}) {
7
+ this.expectation = this.expectation || 'selected';
8
+ return browser.call(async () => {
9
+ const result = await utils_1.executeCommandBe.call(this, received, el => el.isSelected(), options);
10
+ return result;
11
+ });
12
+ }
13
+ function toBeSelected(...args) {
14
+ return expectAdapter_1.runExpect.call(this, toBeSelectedFn, args);
15
+ }
16
+ exports.toBeSelected = toBeSelected;
17
+ function toBeChecked(el, options) {
18
+ const context = expectAdapter_1.getContext(this);
19
+ context.expectation = 'checked';
20
+ return toBeSelected.call(context, el, options);
21
+ }
22
+ exports.toBeChecked = toBeChecked;