expect-webdriverio 4.12.0 → 4.12.2

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.
@@ -1,5 +1,5 @@
1
1
  import { toHaveAttributeAndValue } from './toHaveAttribute.js';
2
- import { waitUntil, enhanceError, executeCommand, wrapExpectedWithArray, compareText } from '../../utils.js';
2
+ import { waitUntil, enhanceError, executeCommand, wrapExpectedWithArray, compareText, isAsymmeyricMatcher } from '../../utils.js';
3
3
  import { DEFAULT_OPTIONS } from '../../constants.js';
4
4
  async function condition(el, attribute, value, options) {
5
5
  const { ignoreCase = false, trim = false, containing = false } = options;
@@ -16,6 +16,9 @@ async function condition(el, attribute, value, options) {
16
16
  value = value.toLowerCase();
17
17
  }
18
18
  }
19
+ if (isAsymmeyricMatcher(value)) {
20
+ return compareText(attr, value, options);
21
+ }
19
22
  const classes = attr.split(' ');
20
23
  const valueInClasses = classes.some((t) => {
21
24
  return value instanceof RegExp
@@ -21,8 +21,12 @@ export async function toBeElementsArrayOfSize(received, expectedValue, options =
21
21
  }
22
22
  let elements = await received;
23
23
  const pass = await waitUntil(async () => {
24
+ const isPassing = compareNumbers(elements.length, numberOptions);
25
+ if (isPassing) {
26
+ return isPassing;
27
+ }
24
28
  elements = await refetchElements(elements, numberOptions.wait, true);
25
- return compareNumbers(elements.length, numberOptions);
29
+ return false;
26
30
  }, isNot, { ...numberOptions, ...options });
27
31
  const error = numberError(numberOptions);
28
32
  const message = enhanceError(elements, error, elements.length, this, verb, expectation, '', numberOptions);
package/lib/utils.js CHANGED
@@ -7,6 +7,9 @@ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
7
7
  const asymmetricMatcher = typeof Symbol === 'function' && Symbol.for
8
8
  ? Symbol.for('jest.asymmetricMatcher')
9
9
  : 1267621;
10
+ export function isAsymmeyricMatcher(expected) {
11
+ return typeof expected === 'object' && '$$typeof' in expected && expected.$$typeof === asymmetricMatcher && expected.asymmetricMatch;
12
+ }
10
13
  const waitUntil = async (condition, isNot = false, { wait = DEFAULT_OPTIONS.wait, interval = DEFAULT_OPTIONS.interval } = {}) => {
11
14
  if (wait === 0) {
12
15
  return await condition();
@@ -93,7 +96,7 @@ export const compareText = (actual, expected, { ignoreCase = false, trim = true,
93
96
  expected = expected.toLowerCase();
94
97
  }
95
98
  }
96
- if (typeof expected === 'object' && '$$typeof' in expected && expected.$$typeof === asymmetricMatcher && expected.asymmetricMatch) {
99
+ if (isAsymmeyricMatcher(expected)) {
97
100
  const result = expected.asymmetricMatch(actual);
98
101
  return {
99
102
  value: actual,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expect-webdriverio",
3
- "version": "4.12.0",
3
+ "version": "4.12.2",
4
4
  "author": "Mykola Grybyk <mykola.grybyk@gmail.com>",
5
5
  "description": "WebdriverIO Assertion Library",
6
6
  "license": "MIT",
@@ -75,8 +75,8 @@
75
75
  "rimraf": "^5.0.5",
76
76
  "shelljs": "^0.8.5",
77
77
  "typescript": "^5.3.3",
78
- "vitest": "1.3.1",
79
- "webdriverio": "8.33.1"
78
+ "vitest": "1.4.0",
79
+ "webdriverio": "8.34.1"
80
80
  },
81
81
  "optionalDependencies": {
82
82
  "@wdio/globals": "^8.29.3",