expect-webdriverio 3.5.2 → 3.6.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.
@@ -5,7 +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 browser = (0, utils_1.getBrowserObject)(await received);
8
+ const browser = await (0, utils_1.getBrowserObject)(await received);
9
9
  return browser.call(async () => {
10
10
  const result = await utils_1.executeCommandBe.call(this, received, async (el) => {
11
11
  try {
@@ -6,7 +6,7 @@ const expectAdapter_1 = require("../../util/expectAdapter");
6
6
  async function toBeDisabledFn(received, options = {}) {
7
7
  this.expectation = this.expectation || 'disabled';
8
8
  received = await received;
9
- const browser = (0, utils_1.getBrowserObject)(await received);
9
+ const browser = await (0, utils_1.getBrowserObject)(await 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;
@@ -6,7 +6,7 @@ const expectAdapter_1 = require("../../util/expectAdapter");
6
6
  async function toBeDisplayedFn(received, options = {}) {
7
7
  this.expectation = this.expectation || 'displayed';
8
8
  received = await received;
9
- const browser = (0, utils_1.getBrowserObject)(await received);
9
+ const browser = await (0, utils_1.getBrowserObject)(await received);
10
10
  return browser.call(async () => {
11
11
  const result = await utils_1.executeCommandBe.call(this, received, async (el) => {
12
12
  try {
@@ -5,7 +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 browser = (0, utils_1.getBrowserObject)(await received);
8
+ const browser = await (0, utils_1.getBrowserObject)(await received);
9
9
  return browser.call(async () => {
10
10
  const result = await utils_1.executeCommandBe.call(this, received, async (el) => {
11
11
  try {
@@ -5,7 +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 browser = (0, utils_1.getBrowserObject)(await received);
8
+ const browser = await (0, utils_1.getBrowserObject)(await received);
9
9
  return browser.call(async () => {
10
10
  const result = await utils_1.executeCommandBe.call(this, received, el => el.isEnabled(), options);
11
11
  return result;
@@ -7,7 +7,7 @@ async function toExistFn(received, options = {}) {
7
7
  this.expectation = this.expectation || 'exist';
8
8
  this.verb = this.verb || '';
9
9
  received = await received;
10
- const browser = (0, utils_1.getBrowserObject)(await received);
10
+ const browser = await (0, utils_1.getBrowserObject)(await received);
11
11
  return browser.call(async () => {
12
12
  const result = await utils_1.executeCommandBe.call(this, received, async (el) => {
13
13
  try {
@@ -5,7 +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 browser = (0, utils_1.getBrowserObject)(await received);
8
+ const browser = await (0, utils_1.getBrowserObject)(await received);
9
9
  return browser.call(async () => {
10
10
  const result = await utils_1.executeCommandBe.call(this, received, el => el.isFocused(), options);
11
11
  return result;
@@ -5,7 +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 browser = (0, utils_1.getBrowserObject)(await received);
8
+ const browser = await (0, utils_1.getBrowserObject)(await received);
9
9
  return browser.call(async () => {
10
10
  const result = await utils_1.executeCommandBe.call(this, received, el => el.isSelected(), options);
11
11
  return result;
@@ -22,7 +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 browser = (0, utils_1.getBrowserObject)(await received);
25
+ const browser = await (0, utils_1.getBrowserObject)(await received);
26
26
  return browser.call(async () => {
27
27
  let el = await received;
28
28
  let attr;
@@ -45,7 +45,7 @@ exports.toHaveAttributeAndValueFn = toHaveAttributeAndValueFn;
45
45
  async function toHaveAttributeFn(received, attribute) {
46
46
  const isNot = this.isNot;
47
47
  const { expectation = 'attribute', verb = 'have' } = this;
48
- const browser = (0, utils_1.getBrowserObject)(await received);
48
+ const browser = await (0, utils_1.getBrowserObject)(await received);
49
49
  return browser.call(async () => {
50
50
  let el = await received;
51
51
  const pass = await (0, utils_1.waitUntil)(async () => {
@@ -28,7 +28,7 @@ async function toHaveChildrenFn(received, expected, options = {}) {
28
28
  else if (typeof expected === 'object') {
29
29
  numberOptions = expected;
30
30
  }
31
- const browser = (0, utils_1.getBrowserObject)(await received);
31
+ const browser = await (0, utils_1.getBrowserObject)(await received);
32
32
  return browser.call(async () => {
33
33
  let el = await received;
34
34
  let children;
@@ -31,7 +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 browser = (0, utils_1.getBrowserObject)(await received);
34
+ const browser = await (0, utils_1.getBrowserObject)(await received);
35
35
  return browser.call(async () => {
36
36
  let el = await received;
37
37
  let attr;
@@ -21,7 +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 browser = (0, utils_1.getBrowserObject)(await received);
24
+ const browser = await (0, utils_1.getBrowserObject)(await received);
25
25
  return browser.call(async () => {
26
26
  let el = await received;
27
27
  let prop;
@@ -9,7 +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 browser = (0, utils_1.getBrowserObject)(await received);
12
+ const browser = await (0, utils_1.getBrowserObject)(await received);
13
13
  return browser.call(async () => {
14
14
  let el = await received;
15
15
  let actualStyle;
@@ -13,7 +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 browser = (0, utils_1.getBrowserObject)(await received);
16
+ const browser = await (0, utils_1.getBrowserObject)(await received);
17
17
  return browser.call(async () => {
18
18
  let el = await received;
19
19
  let actualText;
@@ -17,7 +17,7 @@ async function toBeElementsArrayOfSizeFn(received, expected, options = {}) {
17
17
  else {
18
18
  numberOptions = expected;
19
19
  }
20
- const browser = (0, utils_1.getBrowserObject)(await received);
20
+ const browser = await (0, utils_1.getBrowserObject)(await received);
21
21
  return browser.call(async () => {
22
22
  let elements = await received;
23
23
  const arrLength = elements.length;
package/lib/utils.js CHANGED
@@ -169,8 +169,8 @@ function aliasFn(fn, { verb, expectation } = {}, ...args) {
169
169
  return fn.apply(context, args);
170
170
  }
171
171
  exports.aliasFn = aliasFn;
172
- function getBrowserObject(elem) {
172
+ async function getBrowserObject(elem) {
173
173
  const elemObject = elem;
174
- return elemObject.parent ? getBrowserObject(elemObject.parent) : elem;
174
+ return elemObject.parent ? getBrowserObject(await elemObject.parent) : elem;
175
175
  }
176
176
  exports.getBrowserObject = getBrowserObject;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expect-webdriverio",
3
- "version": "3.5.2",
3
+ "version": "3.6.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -1,14 +1,14 @@
1
1
  /// <reference types="expect-webdriverio/types/expect-webdriverio"/>
2
2
 
3
3
  declare namespace ExpectWebdriverIO {
4
- interface Matchers<R, T> extends Readonly<import('expect').Matchers<R>> {
4
+ interface Matchers<R extends void|Promise<void>, T> extends Readonly<import('expect').Matchers<R>> {
5
5
  not: Matchers<R, T>
6
- resolves: Matchers<Promise<R>, T>
7
- rejects: Matchers<Promise<R>, T>
6
+ resolves: Matchers<R, T>
7
+ rejects: Matchers<R, T>
8
8
  }
9
9
 
10
10
  type Expect = {
11
- <T = unknown>(actual: T): Matchers<T, T>
11
+ <T = unknown>(actual: T): Matchers<void, T>
12
12
  extend(map: Record<string, Function>): void
13
13
  } & AsymmetricMatchers
14
14