expect-webdriverio 3.3.2 → 4.0.0-alpha.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.
- package/jest.d.ts +1 -1
- package/lib/constants.js +4 -0
- package/lib/index.js +15 -6
- package/lib/jasmineUtils.js +7 -17
- package/lib/matchers/browser/toHaveTitle.js +5 -14
- package/lib/matchers/browser/toHaveTitleContaining.js +3 -11
- package/lib/matchers/browser/toHaveUrl.js +5 -14
- package/lib/matchers/browser/toHaveUrlContaining.js +3 -11
- package/lib/matchers/element/toBeClickable.js +5 -12
- package/lib/matchers/element/toBeDisabled.js +4 -11
- package/lib/matchers/element/toBeDisplayed.js +5 -12
- package/lib/matchers/element/toBeDisplayedInViewport.js +5 -12
- package/lib/matchers/element/toBeEnabled.js +4 -11
- package/lib/matchers/element/toBeExisting.js +9 -18
- package/lib/matchers/element/toBeFocused.js +4 -11
- package/lib/matchers/element/toBeSelected.js +7 -16
- package/lib/matchers/element/toHaveAttribute.js +18 -24
- package/lib/matchers/element/toHaveAttributeContaining.js +4 -12
- package/lib/matchers/element/toHaveChildren.js +12 -19
- package/lib/matchers/element/{toHaveElementClass.js → toHaveClass.js} +10 -19
- package/lib/matchers/element/toHaveClassContaining.js +10 -0
- package/lib/matchers/element/toHaveElementProperty.js +10 -18
- package/lib/matchers/element/toHaveHref.js +4 -13
- package/lib/matchers/element/toHaveHrefContaining.js +4 -12
- package/lib/matchers/element/toHaveId.js +3 -12
- package/lib/matchers/element/toHaveStyle.js +8 -16
- package/lib/matchers/element/toHaveText.js +9 -17
- package/lib/matchers/element/toHaveTextContaining.js +3 -11
- package/lib/matchers/element/toHaveValue.js +3 -12
- package/lib/matchers/element/toHaveValueContaining.js +3 -11
- package/lib/matchers/elements/toBeElementsArrayOfSize.js +10 -17
- package/lib/matchers/mock/toBeRequested.js +3 -11
- package/lib/matchers/mock/toBeRequestedTimes.js +8 -16
- package/lib/matchers/mock/toBeRequestedWith.js +13 -19
- package/lib/matchers.js +62 -35
- package/lib/types.js +1 -0
- package/lib/util/elementsUtil.js +2 -7
- package/lib/util/executeCommand.js +3 -7
- package/lib/util/formatMessage.js +17 -26
- package/lib/util/refetchElements.js +2 -8
- package/lib/utils.js +15 -32
- package/package.json +52 -43
- package/types/jest-global.d.ts +1 -1
- package/types/standalone.d.ts +2 -2
- package/jasmine.d.ts +0 -6
- package/lib/addMatchers.js +0 -48
- package/lib/matchers/element/toHaveElementClassContaining.js +0 -20
- package/lib/matchers/mock/toBeRequestedWithResponse.js +0 -13
- package/lib/options.js +0 -33
- package/lib/util/expectAdapter.js +0 -41
- package/types/standalone-global.d.ts +0 -12
package/lib/util/elementsUtil.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateElementsArray = exports.wrapExpectedWithArray = void 0;
|
|
4
|
-
const wrapExpectedWithArray = (el, actual, expected) => {
|
|
1
|
+
export const wrapExpectedWithArray = (el, actual, expected) => {
|
|
5
2
|
if (Array.isArray(el) && el.length > 1 && Array.isArray(actual)) {
|
|
6
3
|
expected = [expected];
|
|
7
4
|
}
|
|
8
5
|
return expected;
|
|
9
6
|
};
|
|
10
|
-
|
|
11
|
-
const updateElementsArray = (success, received, refetched, full = false) => {
|
|
7
|
+
export const updateElementsArray = (success, received, refetched, full = false) => {
|
|
12
8
|
if (!success) {
|
|
13
9
|
return;
|
|
14
10
|
}
|
|
@@ -25,4 +21,3 @@ const updateElementsArray = (success, received, refetched, full = false) => {
|
|
|
25
21
|
}
|
|
26
22
|
}
|
|
27
23
|
};
|
|
28
|
-
exports.updateElementsArray = updateElementsArray;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.executeCommand = void 0;
|
|
4
|
-
const refetchElements_1 = require("./refetchElements");
|
|
5
|
-
async function executeCommand(el, condition, options = {}, params = [], fullRefetch = false) {
|
|
1
|
+
import { refetchElements } from './refetchElements.js';
|
|
2
|
+
export async function executeCommand(el, condition, options = {}, params = [], fullRefetch = false) {
|
|
6
3
|
const { isNot = false } = this;
|
|
7
4
|
let elements;
|
|
8
5
|
if (Array.isArray(el)) {
|
|
9
|
-
elements = await
|
|
6
|
+
elements = await refetchElements(el, options.wait, fullRefetch);
|
|
10
7
|
}
|
|
11
8
|
else {
|
|
12
9
|
elements = [el];
|
|
@@ -28,4 +25,3 @@ async function executeCommand(el, condition, options = {}, params = [], fullRefe
|
|
|
28
25
|
values: values.length > 1 ? values : values[0]
|
|
29
26
|
};
|
|
30
27
|
}
|
|
31
|
-
exports.executeCommand = executeCommand;
|
|
@@ -1,46 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.numberError = exports.enhanceErrorBe = exports.enhanceError = exports.not = exports.getSelectors = exports.getSelector = void 0;
|
|
4
|
-
const jest_matcher_utils_1 = require("jest-matcher-utils");
|
|
5
|
-
const jasmineUtils_1 = require("../jasmineUtils");
|
|
1
|
+
import { printExpected, printReceived, printDiffOrStringify } from 'jest-matcher-utils';
|
|
2
|
+
import { equals } from '../jasmineUtils.js';
|
|
6
3
|
const EXPECTED_LABEL = 'Expected';
|
|
7
4
|
const RECEIVED_LABEL = 'Received';
|
|
8
5
|
const NOT_SUFFIX = ' [not]';
|
|
9
6
|
const NOT_EXPECTED_LABEL = EXPECTED_LABEL + NOT_SUFFIX;
|
|
10
|
-
const getSelector = (el) => {
|
|
7
|
+
export const getSelector = (el) => {
|
|
11
8
|
let result = typeof el.selector === 'string' ? el.selector : '<fn>';
|
|
12
9
|
if (Array.isArray(el) && el.props.length > 0) {
|
|
13
10
|
result += ', <props>';
|
|
14
11
|
}
|
|
15
12
|
return result;
|
|
16
13
|
};
|
|
17
|
-
|
|
18
|
-
const getSelectors = (el) => {
|
|
14
|
+
export const getSelectors = (el) => {
|
|
19
15
|
const selectors = [];
|
|
20
16
|
let parent;
|
|
21
17
|
if (Array.isArray(el)) {
|
|
22
|
-
selectors.push(`${el.foundWith}(\`${
|
|
18
|
+
selectors.push(`${el.foundWith}(\`${getSelector(el)}\`)`);
|
|
23
19
|
parent = el.parent;
|
|
24
20
|
}
|
|
25
21
|
else {
|
|
26
22
|
parent = el;
|
|
27
23
|
}
|
|
28
24
|
while (parent && 'selector' in parent) {
|
|
29
|
-
const selector =
|
|
25
|
+
const selector = getSelector(parent);
|
|
30
26
|
const index = parent.index ? `[${parent.index}]` : '';
|
|
31
27
|
selectors.push(`${parent.index ? '$' : ''}$(\`${selector}\`)${index}`);
|
|
32
28
|
parent = parent.parent;
|
|
33
29
|
}
|
|
34
30
|
return selectors.reverse().join('.');
|
|
35
31
|
};
|
|
36
|
-
|
|
37
|
-
const not = (isNot) => {
|
|
32
|
+
export const not = (isNot) => {
|
|
38
33
|
return `${isNot ? 'not ' : ''}`;
|
|
39
34
|
};
|
|
40
|
-
|
|
41
|
-
const enhanceError = (subject, expected, actual, context, verb, expectation, arg2 = '', { message = '', containing = false }) => {
|
|
35
|
+
export const enhanceError = (subject, expected, actual, context, verb, expectation, arg2 = '', { message = '', containing = false }) => {
|
|
42
36
|
const { isNot = false } = context;
|
|
43
|
-
subject = typeof subject === 'string' ? subject :
|
|
37
|
+
subject = typeof subject === 'string' ? subject : getSelectors(subject);
|
|
44
38
|
let contain = '';
|
|
45
39
|
if (containing) {
|
|
46
40
|
contain = ' containing';
|
|
@@ -49,12 +43,12 @@ const enhanceError = (subject, expected, actual, context, verb, expectation, arg
|
|
|
49
43
|
verb += ' ';
|
|
50
44
|
}
|
|
51
45
|
let diffString;
|
|
52
|
-
if (isNot &&
|
|
53
|
-
diffString = `${EXPECTED_LABEL}: ${
|
|
54
|
-
`${RECEIVED_LABEL}: ${
|
|
46
|
+
if (isNot && equals(actual, expected)) {
|
|
47
|
+
diffString = `${EXPECTED_LABEL}: ${printExpected(expected)}\n` +
|
|
48
|
+
`${RECEIVED_LABEL}: ${printReceived(actual)}`;
|
|
55
49
|
}
|
|
56
50
|
else {
|
|
57
|
-
diffString =
|
|
51
|
+
diffString = printDiffOrStringify(expected, actual, EXPECTED_LABEL, RECEIVED_LABEL, true);
|
|
58
52
|
}
|
|
59
53
|
if (isNot) {
|
|
60
54
|
diffString = diffString
|
|
@@ -67,15 +61,13 @@ const enhanceError = (subject, expected, actual, context, verb, expectation, arg
|
|
|
67
61
|
if (arg2) {
|
|
68
62
|
arg2 = ` ${arg2}`;
|
|
69
63
|
}
|
|
70
|
-
const msg = `${message}Expect ${subject} ${
|
|
64
|
+
const msg = `${message}Expect ${subject} ${not(isNot)}to ${verb}${expectation}${arg2}${contain}\n\n${diffString}`;
|
|
71
65
|
return msg;
|
|
72
66
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return (0, exports.enhanceError)(subject, (0, exports.not)(context.isNot) + expectation, (0, exports.not)(!pass) + expectation, context, verb, expectation, '', options);
|
|
67
|
+
export const enhanceErrorBe = (subject, pass, context, verb, expectation, options) => {
|
|
68
|
+
return enhanceError(subject, not(context.isNot) + expectation, not(!pass) + expectation, context, verb, expectation, '', options);
|
|
76
69
|
};
|
|
77
|
-
|
|
78
|
-
const numberError = (options = {}) => {
|
|
70
|
+
export const numberError = (options = {}) => {
|
|
79
71
|
if (options.eq) {
|
|
80
72
|
return options.eq;
|
|
81
73
|
}
|
|
@@ -90,4 +82,3 @@ const numberError = (options = {}) => {
|
|
|
90
82
|
}
|
|
91
83
|
return "no params";
|
|
92
84
|
};
|
|
93
|
-
exports.numberError = numberError;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.refetchElements = void 0;
|
|
4
|
-
const options_1 = require("../options");
|
|
5
|
-
const config = (0, options_1.getConfig)();
|
|
6
|
-
const { options: DEFAULT_OPTIONS } = config;
|
|
7
|
-
const refetchElements = async (elements, wait = DEFAULT_OPTIONS.wait, full = false) => {
|
|
1
|
+
import { DEFAULT_OPTIONS } from '../constants.js';
|
|
2
|
+
export const refetchElements = async (elements, wait = DEFAULT_OPTIONS.wait, full = false) => {
|
|
8
3
|
if (elements) {
|
|
9
4
|
if (wait > 0 && (elements.length === 0 || full)) {
|
|
10
5
|
elements = await elements.parent[elements.foundWith](elements.selector, ...elements.props);
|
|
@@ -12,4 +7,3 @@ const refetchElements = async (elements, wait = DEFAULT_OPTIONS.wait, full = fal
|
|
|
12
7
|
}
|
|
13
8
|
return elements;
|
|
14
9
|
};
|
|
15
|
-
exports.refetchElements = refetchElements;
|
package/lib/utils.js
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Object.defineProperty(exports, "executeCommand", { enumerable: true, get: function () { return executeCommand_1.executeCommand; } });
|
|
7
|
-
const elementsUtil_1 = require("./util/elementsUtil");
|
|
8
|
-
Object.defineProperty(exports, "wrapExpectedWithArray", { enumerable: true, get: function () { return elementsUtil_1.wrapExpectedWithArray; } });
|
|
9
|
-
Object.defineProperty(exports, "updateElementsArray", { enumerable: true, get: function () { return elementsUtil_1.updateElementsArray; } });
|
|
10
|
-
const formatMessage_1 = require("./util/formatMessage");
|
|
11
|
-
Object.defineProperty(exports, "enhanceError", { enumerable: true, get: function () { return formatMessage_1.enhanceError; } });
|
|
12
|
-
Object.defineProperty(exports, "numberError", { enumerable: true, get: function () { return formatMessage_1.numberError; } });
|
|
13
|
-
const expectAdapter_1 = require("./util/expectAdapter");
|
|
14
|
-
const config = (0, options_1.getConfig)();
|
|
15
|
-
const { options: DEFAULT_OPTIONS } = config;
|
|
1
|
+
import { browser } from '@wdio/globals';
|
|
2
|
+
import { executeCommand } from './util/executeCommand.js';
|
|
3
|
+
import { wrapExpectedWithArray, updateElementsArray } from './util/elementsUtil.js';
|
|
4
|
+
import { enhanceError, enhanceErrorBe, numberError } from './util/formatMessage.js';
|
|
5
|
+
import { DEFAULT_OPTIONS } from './constants.js';
|
|
16
6
|
const waitUntil = async (condition, isNot = false, { wait = DEFAULT_OPTIONS.wait, interval = DEFAULT_OPTIONS.interval } = {}) => {
|
|
17
7
|
if (wait === 0) {
|
|
18
8
|
return await condition();
|
|
@@ -41,24 +31,22 @@ const waitUntil = async (condition, isNot = false, { wait = DEFAULT_OPTIONS.wait
|
|
|
41
31
|
return isNot;
|
|
42
32
|
}
|
|
43
33
|
};
|
|
44
|
-
exports.waitUntil = waitUntil;
|
|
45
34
|
async function executeCommandBe(received, command, options) {
|
|
46
35
|
const { isNot, expectation, verb = 'be' } = this;
|
|
47
36
|
received = await received;
|
|
48
37
|
let el = received;
|
|
49
38
|
const pass = await waitUntil(async () => {
|
|
50
|
-
const result = await
|
|
39
|
+
const result = await executeCommand.call(this, el, async (element) => ({ result: await command(element) }), options);
|
|
51
40
|
el = result.el;
|
|
52
41
|
return result.success;
|
|
53
42
|
}, isNot, options);
|
|
54
|
-
|
|
55
|
-
const message =
|
|
43
|
+
updateElementsArray(pass, received, el);
|
|
44
|
+
const message = enhanceErrorBe(el, pass, this, verb, expectation, options);
|
|
56
45
|
return {
|
|
57
46
|
pass,
|
|
58
47
|
message: () => message
|
|
59
48
|
};
|
|
60
49
|
}
|
|
61
|
-
exports.executeCommandBe = executeCommandBe;
|
|
62
50
|
const compareNumbers = (actual, options = {}) => {
|
|
63
51
|
if (typeof options.eq === 'number') {
|
|
64
52
|
return actual === options.eq;
|
|
@@ -74,8 +62,7 @@ const compareNumbers = (actual, options = {}) => {
|
|
|
74
62
|
}
|
|
75
63
|
return false;
|
|
76
64
|
};
|
|
77
|
-
|
|
78
|
-
const compareText = (actual, expected, { ignoreCase = false, trim = true, containing = false }) => {
|
|
65
|
+
export const compareText = (actual, expected, { ignoreCase = false, trim = true, containing = false }) => {
|
|
79
66
|
if (typeof actual !== 'string') {
|
|
80
67
|
return {
|
|
81
68
|
value: actual,
|
|
@@ -108,8 +95,7 @@ const compareText = (actual, expected, { ignoreCase = false, trim = true, contai
|
|
|
108
95
|
result: actual === expected
|
|
109
96
|
};
|
|
110
97
|
};
|
|
111
|
-
|
|
112
|
-
const compareTextWithArray = (actual, expectedArray, { ignoreCase = false, trim = false, containing = false }) => {
|
|
98
|
+
export const compareTextWithArray = (actual, expectedArray, { ignoreCase = false, trim = false, containing = false }) => {
|
|
113
99
|
if (typeof actual !== 'string') {
|
|
114
100
|
return {
|
|
115
101
|
value: actual,
|
|
@@ -131,8 +117,7 @@ const compareTextWithArray = (actual, expectedArray, { ignoreCase = false, trim
|
|
|
131
117
|
result: textInArray
|
|
132
118
|
};
|
|
133
119
|
};
|
|
134
|
-
|
|
135
|
-
const compareStyle = async (actualEl, style, { ignoreCase = true, trim = false }) => {
|
|
120
|
+
export const compareStyle = async (actualEl, style, { ignoreCase = true, trim = false }) => {
|
|
136
121
|
let result = true;
|
|
137
122
|
const actual = {};
|
|
138
123
|
for (const key in style) {
|
|
@@ -155,11 +140,9 @@ const compareStyle = async (actualEl, style, { ignoreCase = true, trim = false }
|
|
|
155
140
|
result
|
|
156
141
|
};
|
|
157
142
|
};
|
|
158
|
-
exports.compareStyle = compareStyle;
|
|
159
143
|
function aliasFn(fn, { verb, expectation } = {}, ...args) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return fn.apply(context, args);
|
|
144
|
+
this.verb = verb;
|
|
145
|
+
this.expectation = expectation;
|
|
146
|
+
return fn.apply(this, args);
|
|
164
147
|
}
|
|
165
|
-
|
|
148
|
+
export { updateElementsArray, wrapExpectedWithArray, enhanceError, numberError, executeCommand, executeCommandBe, waitUntil, compareNumbers, aliasFn, };
|
package/package.json
CHANGED
|
@@ -1,68 +1,77 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expect-webdriverio",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "4.0.0-alpha.1",
|
|
4
|
+
"author": "Mykola Grybyk <mykola.grybyk@gmail.com>",
|
|
5
|
+
"description": "WebdriverIO Assertion Library",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://webdriver.io",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/webdriverio/expect-webdriverio.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/webdriverio/expect-webdriverio/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"expect-webdriverio",
|
|
17
|
+
"expect",
|
|
18
|
+
"webdriverio",
|
|
19
|
+
"wdio"
|
|
20
|
+
],
|
|
21
|
+
"main": "./lib/index.cjs.js",
|
|
22
|
+
"type": "module",
|
|
23
|
+
"module": "./lib/index.js",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": [
|
|
26
|
+
{
|
|
27
|
+
"import": "./lib/index.js",
|
|
28
|
+
"require": "./lib/index.cjs.js"
|
|
29
|
+
},
|
|
30
|
+
"./lib/index.cjs.js"
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"types": "types/jest-global.d.ts",
|
|
34
|
+
"typeScriptVersion": "3.8.3",
|
|
6
35
|
"scripts": {
|
|
7
36
|
"build": "run-s clean compile",
|
|
8
37
|
"clean": "run-p clean:*",
|
|
9
38
|
"clean:build": "rimraf ./lib",
|
|
10
39
|
"clean:tests": "rimraf test-types/**/node_modules && rimraf test-types/**/dist",
|
|
11
40
|
"compile": "tsc --build tsconfig.build.json",
|
|
12
|
-
"release": "release-it --github.release",
|
|
13
|
-
"release:ci": "npm run release -- --ci --npm.skipChecks --no-git.requireCleanWorkingDir",
|
|
14
|
-
"release:patch": "npm run release -- patch",
|
|
15
|
-
"release:minor": "npm run release -- minor",
|
|
16
|
-
"release:major": "npm run release -- major",
|
|
17
41
|
"test": "run-s test:*",
|
|
18
42
|
"test:lint": "eslint . --ext .js,.jsx,.ts,.tsx",
|
|
19
|
-
"test:unit": "
|
|
20
|
-
"watch": "npm run compile -- --watch",
|
|
43
|
+
"test:unit": "vitest",
|
|
21
44
|
"test:types": "node test-types/copy && npm run ts && npm run clean:tests",
|
|
22
45
|
"ts": "run-p ts:*",
|
|
23
46
|
"ts:default": "cd test-types/default && tsc --incremental",
|
|
24
47
|
"ts:jest": "cd test-types/jest && tsc --incremental",
|
|
25
48
|
"ts:jasmine": "cd test-types/jasmine && tsc --incremental",
|
|
49
|
+
"watch": "npm run compile -- --watch",
|
|
26
50
|
"prepare": "husky install"
|
|
27
51
|
},
|
|
28
|
-
"repository": {
|
|
29
|
-
"type": "git",
|
|
30
|
-
"url": "git+https://github.com/webdriverio/expect-webdriverio.git"
|
|
31
|
-
},
|
|
32
|
-
"keywords": [
|
|
33
|
-
"expect-webdriverio",
|
|
34
|
-
"expect",
|
|
35
|
-
"webdriverio",
|
|
36
|
-
"wdio"
|
|
37
|
-
],
|
|
38
|
-
"author": "Mykola Grybyk <mykola.grybyk@gmail.com>",
|
|
39
|
-
"license": "MIT",
|
|
40
|
-
"bugs": {
|
|
41
|
-
"url": "https://github.com/webdriverio/expect-webdriverio/issues"
|
|
42
|
-
},
|
|
43
|
-
"homepage": "https://github.com/webdriverio/expect-webdriverio#readme",
|
|
44
52
|
"devDependencies": {
|
|
45
|
-
"@types/
|
|
46
|
-
"@types/
|
|
47
|
-
"@
|
|
48
|
-
"@typescript-eslint/
|
|
49
|
-
"
|
|
50
|
-
"eslint": "^8.
|
|
53
|
+
"@types/jest": "^28.1.6",
|
|
54
|
+
"@types/node": "^18.7.1",
|
|
55
|
+
"@typescript-eslint/eslint-plugin": "^5.33.0",
|
|
56
|
+
"@typescript-eslint/parser": "^5.33.0",
|
|
57
|
+
"c8": "^7.12.0",
|
|
58
|
+
"eslint": "^8.21.0",
|
|
59
|
+
"eslint-plugin-import": "^2.26.0",
|
|
60
|
+
"eslint-plugin-unicorn": "^43.0.2",
|
|
51
61
|
"husky": "^8.0.1",
|
|
52
|
-
"jest": "^27.3.1",
|
|
53
62
|
"npm-run-all": "^4.1.5",
|
|
54
|
-
"release-it": "^15.
|
|
63
|
+
"release-it": "^15.3.0",
|
|
55
64
|
"rimraf": "^3.0.2",
|
|
56
|
-
"shelljs": "^0.8.
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
65
|
+
"shelljs": "^0.8.5",
|
|
66
|
+
"typescript": "^4.7.4",
|
|
67
|
+
"vitest": "0.21.1"
|
|
68
|
+
},
|
|
69
|
+
"peerDependencies": {
|
|
70
|
+
"@wdio/globals": "next",
|
|
71
|
+
"webdriverio": "next"
|
|
61
72
|
},
|
|
62
|
-
"types": "types/jest-global.d.ts",
|
|
63
|
-
"typeScriptVersion": "3.8.3",
|
|
64
73
|
"dependencies": {
|
|
65
|
-
"expect": "^
|
|
66
|
-
"jest-matcher-utils": "^28.
|
|
74
|
+
"expect": "^28.1.3",
|
|
75
|
+
"jest-matcher-utils": "^28.1.3"
|
|
67
76
|
}
|
|
68
77
|
}
|
package/types/jest-global.d.ts
CHANGED
package/types/standalone.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/// <reference types="expect-webdriverio
|
|
1
|
+
/// <reference types="./expect-webdriverio"/>
|
|
2
2
|
|
|
3
3
|
declare namespace ExpectWebdriverIO {
|
|
4
|
-
interface Matchers<R, T> extends Readonly<import('expect
|
|
4
|
+
interface Matchers<R, T> extends Readonly<import('expect').Matchers<R>> {
|
|
5
5
|
not: Matchers<R, T>
|
|
6
6
|
resolves: Matchers<Promise<R>, T>
|
|
7
7
|
rejects: Matchers<Promise<R>, T>
|
package/jasmine.d.ts
DELETED
package/lib/addMatchers.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
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 (!(0, exports.loadExpect)()) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
global.expect = expectLib;
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
expectLib = global.expect;
|
|
27
|
-
}
|
|
28
|
-
if (!global.expect.extend && !(0, exports.isJasmine)()) {
|
|
29
|
-
if (!(0, 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.addMatchers({ ...matchers });
|
|
45
|
-
expectLib.addAsyncMatchers({ ...matchers });
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
exports.addMatchers = addMatchers;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toHaveClassContaining = exports.toHaveElementClassContaining = void 0;
|
|
4
|
-
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
5
|
-
const toHaveAttribute_1 = require("./toHaveAttribute");
|
|
6
|
-
function toHaveElementClassContainingFn(el, className, options = {}) {
|
|
7
|
-
return toHaveAttribute_1.toHaveAttributeAndValueFn.call(this, el, 'class', className, {
|
|
8
|
-
...options,
|
|
9
|
-
containing: true
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
function toHaveElementClassContaining(...args) {
|
|
13
|
-
return expectAdapter_1.runExpect.call(this || {}, toHaveElementClassContainingFn, args);
|
|
14
|
-
}
|
|
15
|
-
exports.toHaveElementClassContaining = toHaveElementClassContaining;
|
|
16
|
-
function toHaveClassContaining(...args) {
|
|
17
|
-
console.warn('expect(...).toHaveClassContaining is deprecated and will be removed in next release. Use toHaveElementClassContaining instead.');
|
|
18
|
-
return expectAdapter_1.runExpect.call(this || {}, toHaveElementClassContainingFn, args);
|
|
19
|
-
}
|
|
20
|
-
exports.toHaveClassContaining = toHaveClassContaining;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toBeRequestedWithResponse = void 0;
|
|
4
|
-
const toBeRequestedWith_1 = require("./toBeRequestedWith");
|
|
5
|
-
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
6
|
-
function toBeRequestedWithResponseFn(received, response, options = {}) {
|
|
7
|
-
return toBeRequestedWith_1.toBeRequestedWithFn.call(this, received, { response }, options);
|
|
8
|
-
}
|
|
9
|
-
function toBeRequestedWithResponse(...args) {
|
|
10
|
-
console.warn('expect(...).toBeRequestedWithResponse is deprecated and will be removed in next release. Use toBeRequestedWith instead.');
|
|
11
|
-
return expectAdapter_1.runExpect.call(this || {}, toBeRequestedWithResponseFn, args);
|
|
12
|
-
}
|
|
13
|
-
exports.toBeRequestedWithResponse = toBeRequestedWithResponse;
|
package/lib/options.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.setDefaultOptions = exports.getConfig = void 0;
|
|
5
|
-
const DEFAULT_OPTIONS = {
|
|
6
|
-
wait: 2000,
|
|
7
|
-
interval: 100,
|
|
8
|
-
};
|
|
9
|
-
let mode = 'jest';
|
|
10
|
-
let expectLib;
|
|
11
|
-
if (global.expectWdio) {
|
|
12
|
-
expectLib = global.expectWdio;
|
|
13
|
-
}
|
|
14
|
-
else if (global.jasmine && !((_a = global.expect) === null || _a === void 0 ? void 0 : _a.extend)) {
|
|
15
|
-
expectLib = global.jasmine;
|
|
16
|
-
mode = 'jasmine';
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
expectLib = global.expect;
|
|
20
|
-
}
|
|
21
|
-
if (!expectLib._expectWebdriverio) {
|
|
22
|
-
expectLib._expectWebdriverio = { options: { ...DEFAULT_OPTIONS }, mode };
|
|
23
|
-
}
|
|
24
|
-
const getConfig = () => expectLib._expectWebdriverio;
|
|
25
|
-
exports.getConfig = getConfig;
|
|
26
|
-
const setDefaultOptions = (options = {}) => {
|
|
27
|
-
Object.entries(options).forEach(([key, value]) => {
|
|
28
|
-
if (key in DEFAULT_OPTIONS) {
|
|
29
|
-
expectLib._expectWebdriverio.options[key] = value;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
exports.setDefaultOptions = setDefaultOptions;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runExpect = exports.runJasmineExpect = exports.jestResultToJasmine = exports.buildJasmineFromJestResult = exports.runJestExpect = exports.getContext = void 0;
|
|
4
|
-
const options_1 = require("../options");
|
|
5
|
-
const config = (0, options_1.getConfig)();
|
|
6
|
-
const { mode: MODE } = config;
|
|
7
|
-
const getContext = (context) => global === context ? {} : context || {};
|
|
8
|
-
exports.getContext = getContext;
|
|
9
|
-
function runJestExpect(fn, args) {
|
|
10
|
-
return fn.apply(this, args);
|
|
11
|
-
}
|
|
12
|
-
exports.runJestExpect = runJestExpect;
|
|
13
|
-
const buildJasmineFromJestResult = (result, isNot) => {
|
|
14
|
-
return {
|
|
15
|
-
pass: result.pass !== isNot,
|
|
16
|
-
message: result.message()
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
exports.buildJasmineFromJestResult = buildJasmineFromJestResult;
|
|
20
|
-
const jestResultToJasmine = (result, isNot) => {
|
|
21
|
-
if (result instanceof Promise) {
|
|
22
|
-
return result.then(jestStyleResult => (0, exports.buildJasmineFromJestResult)(jestStyleResult, isNot));
|
|
23
|
-
}
|
|
24
|
-
return (0, exports.buildJasmineFromJestResult)(result, isNot);
|
|
25
|
-
};
|
|
26
|
-
exports.jestResultToJasmine = jestResultToJasmine;
|
|
27
|
-
function runJasmineExpect(fn) {
|
|
28
|
-
const context = (0, exports.getContext)(this);
|
|
29
|
-
return {
|
|
30
|
-
compare(...args) {
|
|
31
|
-
const result = fn.apply({ ...context, isNot: false }, args);
|
|
32
|
-
return (0, exports.jestResultToJasmine)(result, false);
|
|
33
|
-
},
|
|
34
|
-
negativeCompare(...args) {
|
|
35
|
-
const result = fn.apply({ ...context, isNot: true }, args);
|
|
36
|
-
return (0, exports.jestResultToJasmine)(result, true);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
exports.runJasmineExpect = runJasmineExpect;
|
|
41
|
-
exports.runExpect = MODE === 'jasmine' ? runJasmineExpect : runJestExpect;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/// <reference types="expect-webdriverio/types/standalone"/>
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* to use as an additional expectation lib (not recommended)
|
|
5
|
-
*/
|
|
6
|
-
declare const expectWdio: ExpectWebdriverIO.Expect
|
|
7
|
-
|
|
8
|
-
declare namespace NodeJS {
|
|
9
|
-
interface Global {
|
|
10
|
-
expectWdio: ExpectWebdriverIO.Expect;
|
|
11
|
-
}
|
|
12
|
-
}
|