expect-webdriverio 5.6.6 → 5.6.7
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/lib/util/formatMessage.js +22 -22
- package/lib/utils.js +2 -2
- package/package.json +2 -2
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { printDiffOrStringify, printExpected, printReceived } from 'jest-matcher-utils';
|
|
2
2
|
import { equals } from '../jasmineUtils.js';
|
|
3
3
|
import { isElementArray } from './elementsUtil.js';
|
|
4
|
-
const EXPECTED_LABEL = 'Expected';
|
|
5
|
-
const RECEIVED_LABEL = 'Received';
|
|
6
|
-
const NOT_SUFFIX = ' [not]';
|
|
7
|
-
const NOT_EXPECTED_LABEL = EXPECTED_LABEL + NOT_SUFFIX;
|
|
8
4
|
export const getSelector = (el) => {
|
|
9
5
|
let result = typeof el.selector === 'string' ? el.selector : '<fn>';
|
|
10
6
|
if (Array.isArray(el) && el.props.length > 0) {
|
|
@@ -30,11 +26,9 @@ export const getSelectors = (el) => {
|
|
|
30
26
|
}
|
|
31
27
|
return selectors.reverse().join('.');
|
|
32
28
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
36
|
-
export const enhanceError = (subject, expected, actual, context, verb, expectation, arg2 = '', { message = '', containing = false }) => {
|
|
37
|
-
const { isNot = false } = context;
|
|
29
|
+
const not = (isNot) => `${isNot ? 'not ' : ''}`;
|
|
30
|
+
export const enhanceError = (subject, expected, actual, context, verb, expectation, expectedValueArgument2 = '', { message = '', containing = false } = {}) => {
|
|
31
|
+
const { isNot = false, useNotInLabel = true } = context;
|
|
38
32
|
subject = typeof subject === 'string' ? subject : getSelectors(subject);
|
|
39
33
|
let contain = '';
|
|
40
34
|
if (containing) {
|
|
@@ -43,25 +37,31 @@ export const enhanceError = (subject, expected, actual, context, verb, expectati
|
|
|
43
37
|
if (verb) {
|
|
44
38
|
verb += ' ';
|
|
45
39
|
}
|
|
46
|
-
|
|
47
|
-
?
|
|
48
|
-
:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
40
|
+
const label = {
|
|
41
|
+
expected: isNot && useNotInLabel ? 'Expected [not]' : 'Expected',
|
|
42
|
+
received: isNot && useNotInLabel ? 'Received ' : 'Received'
|
|
43
|
+
};
|
|
44
|
+
const diffString = equals(actual, expected) ? `\
|
|
45
|
+
${label.expected}: ${printExpected(expected)}
|
|
46
|
+
${label.received}: ${printReceived(actual)}`
|
|
47
|
+
: printDiffOrStringify(expected, actual, label.expected, label.received, true);
|
|
54
48
|
if (message) {
|
|
55
49
|
message += '\n';
|
|
56
50
|
}
|
|
57
|
-
if (
|
|
58
|
-
|
|
51
|
+
if (expectedValueArgument2) {
|
|
52
|
+
expectedValueArgument2 = ` ${expectedValueArgument2}`;
|
|
59
53
|
}
|
|
60
|
-
const msg =
|
|
54
|
+
const msg = `\
|
|
55
|
+
${message}Expect ${subject} ${not(isNot)}to ${verb}${expectation}${expectedValueArgument2}${contain}
|
|
56
|
+
|
|
57
|
+
${diffString}`;
|
|
61
58
|
return msg;
|
|
62
59
|
};
|
|
63
|
-
export const enhanceErrorBe = (subject,
|
|
64
|
-
|
|
60
|
+
export const enhanceErrorBe = (subject, context, options) => {
|
|
61
|
+
const { isNot, verb, expectation } = context;
|
|
62
|
+
const expected = `${not(isNot)}${expectation}`;
|
|
63
|
+
const actual = `${not(!isNot)}${expectation}`;
|
|
64
|
+
return enhanceError(subject, expected, actual, { ...context, useNotInLabel: false }, verb, expectation, '', options);
|
|
65
65
|
};
|
|
66
66
|
export const numberError = (options = {}) => {
|
|
67
67
|
if (typeof options.eq === 'number') {
|
package/lib/utils.js
CHANGED
|
@@ -56,14 +56,14 @@ const waitUntil = async (condition, isNot = false, { wait = DEFAULT_OPTIONS.wait
|
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
async function executeCommandBe(received, command, options) {
|
|
59
|
-
const { isNot,
|
|
59
|
+
const { isNot, verb = 'be' } = this;
|
|
60
60
|
let el = await received?.getElement();
|
|
61
61
|
const pass = await waitUntil(async () => {
|
|
62
62
|
const result = await executeCommand.call(this, el, async (element) => ({ result: await command(element) }), options);
|
|
63
63
|
el = result.el;
|
|
64
64
|
return result.success;
|
|
65
65
|
}, isNot, options);
|
|
66
|
-
const message = enhanceErrorBe(el,
|
|
66
|
+
const message = enhanceErrorBe(el, { ...this, verb }, options);
|
|
67
67
|
return {
|
|
68
68
|
pass,
|
|
69
69
|
message: () => message,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expect-webdriverio",
|
|
3
|
-
"version": "5.6.
|
|
3
|
+
"version": "5.6.7",
|
|
4
4
|
"author": "Mykola Grybyk <mykola.grybyk@gmail.com>",
|
|
5
5
|
"description": "WebdriverIO Assertion Library",
|
|
6
6
|
"license": "MIT",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"eslint": "^9.39.2",
|
|
97
97
|
"husky": "^9.1.7",
|
|
98
98
|
"npm-run-all2": "^8.0.4",
|
|
99
|
-
"release-it": "^
|
|
99
|
+
"release-it": "^20.0.1",
|
|
100
100
|
"rimraf": "^6.1.2",
|
|
101
101
|
"shelljs": "^0.10.0",
|
|
102
102
|
"typescript": "^5.9.3",
|