expect-webdriverio 3.5.0 → 3.5.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.
@@ -5,8 +5,7 @@ const utils_1 = require("../../utils");
5
5
  const expectAdapter_1 = require("../../util/expectAdapter");
6
6
  async function toBeClickableFn(received, options = {}) {
7
7
  this.expectation = this.expectation || 'clickable';
8
- const el = await (0, utils_1.getFirstElement)(received);
9
- const browser = (0, utils_1.getBrowserObject)(el);
8
+ const browser = (0, utils_1.getBrowserObject)(received);
10
9
  return browser.call(async () => {
11
10
  const result = await utils_1.executeCommandBe.call(this, received, async (el) => {
12
11
  try {
@@ -5,8 +5,8 @@ const utils_1 = require("../../utils");
5
5
  const expectAdapter_1 = require("../../util/expectAdapter");
6
6
  async function toBeDisabledFn(received, options = {}) {
7
7
  this.expectation = this.expectation || 'disabled';
8
- const el = await (0, utils_1.getFirstElement)(received);
9
- const browser = (0, utils_1.getBrowserObject)(el);
8
+ received = await received;
9
+ const browser = (0, utils_1.getBrowserObject)(received);
10
10
  return browser.call(async () => {
11
11
  const result = await utils_1.executeCommandBe.call(this, received, async (el) => !await el.isEnabled(), options);
12
12
  return result;
@@ -5,8 +5,8 @@ const utils_1 = require("../../utils");
5
5
  const expectAdapter_1 = require("../../util/expectAdapter");
6
6
  async function toBeDisplayedFn(received, options = {}) {
7
7
  this.expectation = this.expectation || 'displayed';
8
- const el = await (0, utils_1.getFirstElement)(received);
9
- const browser = (0, utils_1.getBrowserObject)(el);
8
+ received = await received;
9
+ const browser = (0, utils_1.getBrowserObject)(received);
10
10
  return browser.call(async () => {
11
11
  const result = await utils_1.executeCommandBe.call(this, received, async (el) => {
12
12
  try {
@@ -5,8 +5,7 @@ const utils_1 = require("../../utils");
5
5
  const expectAdapter_1 = require("../../util/expectAdapter");
6
6
  async function toBeDisplayedInViewportFn(received, options = {}) {
7
7
  this.expectation = this.expectation || 'displayed in viewport';
8
- const el = await (0, utils_1.getFirstElement)(received);
9
- const browser = (0, utils_1.getBrowserObject)(el);
8
+ const browser = (0, utils_1.getBrowserObject)(received);
10
9
  return browser.call(async () => {
11
10
  const result = await utils_1.executeCommandBe.call(this, received, async (el) => {
12
11
  try {
@@ -5,8 +5,7 @@ const utils_1 = require("../../utils");
5
5
  const expectAdapter_1 = require("../../util/expectAdapter");
6
6
  async function toBeEnabledFn(received, options = {}) {
7
7
  this.expectation = this.expectation || 'enabled';
8
- const el = await (0, utils_1.getFirstElement)(received);
9
- const browser = (0, utils_1.getBrowserObject)(el);
8
+ const browser = (0, utils_1.getBrowserObject)(received);
10
9
  return browser.call(async () => {
11
10
  const result = await utils_1.executeCommandBe.call(this, received, el => el.isEnabled(), options);
12
11
  return result;
@@ -6,8 +6,8 @@ const expectAdapter_1 = require("../../util/expectAdapter");
6
6
  async function toExistFn(received, options = {}) {
7
7
  this.expectation = this.expectation || 'exist';
8
8
  this.verb = this.verb || '';
9
- const el = await (0, utils_1.getFirstElement)(received);
10
- const browser = (0, utils_1.getBrowserObject)(el);
9
+ received = await received;
10
+ const browser = (0, utils_1.getBrowserObject)(received);
11
11
  return browser.call(async () => {
12
12
  const result = await utils_1.executeCommandBe.call(this, received, async (el) => {
13
13
  try {
@@ -5,8 +5,7 @@ const utils_1 = require("../../utils");
5
5
  const expectAdapter_1 = require("../../util/expectAdapter");
6
6
  async function toBeFocusedFn(received, options = {}) {
7
7
  this.expectation = this.expectation || 'focused';
8
- const el = await (0, utils_1.getFirstElement)(received);
9
- const browser = (0, utils_1.getBrowserObject)(el);
8
+ const browser = (0, utils_1.getBrowserObject)(received);
10
9
  return browser.call(async () => {
11
10
  const result = await utils_1.executeCommandBe.call(this, received, el => el.isFocused(), options);
12
11
  return result;
@@ -5,8 +5,7 @@ const utils_1 = require("../../utils");
5
5
  const expectAdapter_1 = require("../../util/expectAdapter");
6
6
  async function toBeSelectedFn(received, options = {}) {
7
7
  this.expectation = this.expectation || 'selected';
8
- const el = await (0, utils_1.getFirstElement)(received);
9
- const browser = (0, utils_1.getBrowserObject)(el);
8
+ const browser = (0, utils_1.getBrowserObject)(received);
10
9
  return browser.call(async () => {
11
10
  const result = await utils_1.executeCommandBe.call(this, received, el => el.isSelected(), options);
12
11
  return result;
@@ -22,8 +22,7 @@ async function conditionAttrAndValue(el, attribute, value, options) {
22
22
  async function toHaveAttributeAndValueFn(received, attribute, value, options = {}) {
23
23
  const isNot = this.isNot;
24
24
  const { expectation = 'attribute', verb = 'have' } = this;
25
- const el = await (0, utils_1.getFirstElement)(received);
26
- const browser = (0, utils_1.getBrowserObject)(el);
25
+ const browser = (0, utils_1.getBrowserObject)(received);
27
26
  return browser.call(async () => {
28
27
  let el = await received;
29
28
  let attr;
@@ -46,8 +45,7 @@ exports.toHaveAttributeAndValueFn = toHaveAttributeAndValueFn;
46
45
  async function toHaveAttributeFn(received, attribute) {
47
46
  const isNot = this.isNot;
48
47
  const { expectation = 'attribute', verb = 'have' } = this;
49
- const el = await (0, utils_1.getFirstElement)(received);
50
- const browser = (0, utils_1.getBrowserObject)(el);
48
+ const browser = (0, utils_1.getBrowserObject)(received);
51
49
  return browser.call(async () => {
52
50
  let el = await received;
53
51
  const pass = await (0, utils_1.waitUntil)(async () => {
@@ -28,8 +28,7 @@ async function toHaveChildrenFn(received, expected, options = {}) {
28
28
  else if (typeof expected === 'object') {
29
29
  numberOptions = expected;
30
30
  }
31
- const el = await (0, utils_1.getFirstElement)(received);
32
- const browser = (0, utils_1.getBrowserObject)(el);
31
+ const browser = (0, utils_1.getBrowserObject)(received);
33
32
  return browser.call(async () => {
34
33
  let el = await received;
35
34
  let children;
@@ -31,8 +31,7 @@ async function toHaveElementClassFn(received, className, options = {}) {
31
31
  const isNot = this.isNot;
32
32
  const { expectation = 'class', verb = 'have' } = this;
33
33
  const attribute = 'class';
34
- const el = await (0, utils_1.getFirstElement)(received);
35
- const browser = (0, utils_1.getBrowserObject)(el);
34
+ const browser = (0, utils_1.getBrowserObject)(received);
36
35
  return browser.call(async () => {
37
36
  let el = await received;
38
37
  let attr;
@@ -21,8 +21,7 @@ async function condition(el, property, value, options = {}) {
21
21
  async function toHaveElementPropertyFn(received, property, value, options = {}) {
22
22
  const isNot = this.isNot;
23
23
  const { expectation = 'property', verb = 'have' } = this;
24
- const el = await (0, utils_1.getFirstElement)(received);
25
- const browser = (0, utils_1.getBrowserObject)(el);
24
+ const browser = (0, utils_1.getBrowserObject)(received);
26
25
  return browser.call(async () => {
27
26
  let el = await received;
28
27
  let prop;
@@ -9,8 +9,7 @@ async function condition(el, style, options) {
9
9
  async function toHaveStyleFn(received, style, options = {}) {
10
10
  const isNot = this.isNot;
11
11
  const { expectation = 'style', verb = 'have' } = this;
12
- const el = await (0, utils_1.getFirstElement)(received);
13
- const browser = (0, utils_1.getBrowserObject)(el);
12
+ const browser = (0, utils_1.getBrowserObject)(received);
14
13
  return browser.call(async () => {
15
14
  let el = await received;
16
15
  let actualStyle;
@@ -13,8 +13,7 @@ async function condition(el, text, options) {
13
13
  async function toHaveTextFn(received, text, options = {}) {
14
14
  const isNot = this.isNot;
15
15
  const { expectation = 'text', verb = 'have' } = this;
16
- const el = await (0, utils_1.getFirstElement)(received);
17
- const browser = (0, utils_1.getBrowserObject)(el);
16
+ const browser = (0, utils_1.getBrowserObject)(received);
18
17
  return browser.call(async () => {
19
18
  let el = await received;
20
19
  let actualText;
@@ -17,8 +17,7 @@ async function toBeElementsArrayOfSizeFn(received, expected, options = {}) {
17
17
  else {
18
18
  numberOptions = expected;
19
19
  }
20
- const el = await (0, utils_1.getFirstElement)(received);
21
- const browser = (0, utils_1.getBrowserObject)(el);
20
+ const browser = (0, utils_1.getBrowserObject)(received);
22
21
  return browser.call(async () => {
23
22
  let elements = await received;
24
23
  const arrLength = elements.length;
package/lib/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFirstElement = exports.getBrowserObject = exports.aliasFn = exports.compareNumbers = exports.waitUntil = exports.executeCommandBe = exports.executeCommand = exports.numberError = exports.enhanceError = exports.wrapExpectedWithArray = exports.updateElementsArray = exports.compareStyle = exports.compareTextWithArray = exports.compareText = void 0;
3
+ exports.getBrowserObject = exports.aliasFn = exports.compareNumbers = exports.waitUntil = exports.executeCommandBe = exports.executeCommand = exports.numberError = exports.enhanceError = exports.wrapExpectedWithArray = exports.updateElementsArray = exports.compareStyle = exports.compareTextWithArray = exports.compareText = void 0;
4
4
  const options_1 = require("./options");
5
5
  const executeCommand_1 = require("./util/executeCommand");
6
6
  Object.defineProperty(exports, "executeCommand", { enumerable: true, get: function () { return executeCommand_1.executeCommand; } });
@@ -174,8 +174,3 @@ function getBrowserObject(elem) {
174
174
  return elemObject.parent ? getBrowserObject(elemObject.parent) : elem;
175
175
  }
176
176
  exports.getBrowserObject = getBrowserObject;
177
- async function getFirstElement(received) {
178
- received = await received;
179
- return Array.isArray(received) ? received[0] : received;
180
- }
181
- exports.getFirstElement = getFirstElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expect-webdriverio",
3
- "version": "3.5.0",
3
+ "version": "3.5.1",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {