expect-webdriverio 4.0.0 → 4.0.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/README.md +29 -9
- package/jasmine.d.ts +0 -1
- package/jest.d.ts +1 -1
- package/lib/constants.js +4 -0
- package/lib/index.js +14 -6
- package/lib/jasmineUtils.js +7 -17
- package/lib/matchers/browser/toHaveTitle.js +12 -23
- package/lib/matchers/browser/toHaveTitleContaining.js +3 -11
- package/lib/matchers/browser/toHaveUrl.js +12 -23
- package/lib/matchers/browser/toHaveUrlContaining.js +3 -11
- package/lib/matchers/element/toBeClickable.js +10 -21
- package/lib/matchers/element/toBeDisabled.js +3 -14
- package/lib/matchers/element/toBeDisplayed.js +10 -21
- package/lib/matchers/element/toBeDisplayedInViewport.js +10 -21
- package/lib/matchers/element/toBeEnabled.js +3 -14
- package/lib/matchers/element/toBeExisting.js +14 -27
- package/lib/matchers/element/toBeFocused.js +3 -14
- package/lib/matchers/element/toBeSelected.js +6 -19
- package/lib/matchers/element/toHaveAttribute.js +35 -46
- package/lib/matchers/element/toHaveAttributeContaining.js +4 -12
- package/lib/matchers/element/toHaveChildren.js +27 -39
- package/lib/matchers/element/toHaveClass.js +47 -0
- package/lib/matchers/element/toHaveClassContaining.js +10 -0
- package/lib/matchers/element/toHaveElementProperty.js +25 -36
- 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 +17 -28
- package/lib/matchers/element/toHaveText.js +18 -29
- 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 +16 -26
- package/lib/matchers/mock/toBeRequested.js +3 -11
- package/lib/matchers/mock/toBeRequestedTimes.js +17 -32
- package/lib/matchers/mock/toBeRequestedWith.js +30 -39
- 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 +41 -49
- package/package.json +49 -44
- package/types/expect-webdriverio.d.ts +23 -22
- package/types/jest-global.d.ts +1 -1
- package/types/standalone.d.ts +2 -2
- package/lib/addMatchers.js +0 -48
- package/lib/matchers/element/toHaveElementClass.js +0 -60
- 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 -9
package/package.json
CHANGED
|
@@ -1,68 +1,73 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expect-webdriverio",
|
|
3
|
-
"version": "4.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "4.0.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
|
+
"type": "module",
|
|
22
|
+
"exports": "./lib/index.js",
|
|
23
|
+
"types": "types/jest-global.d.ts",
|
|
24
|
+
"typeScriptVersion": "3.8.3",
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=16 || >=18 || >=20"
|
|
27
|
+
},
|
|
6
28
|
"scripts": {
|
|
7
29
|
"build": "run-s clean compile",
|
|
8
30
|
"clean": "run-p clean:*",
|
|
9
31
|
"clean:build": "rimraf ./lib",
|
|
10
32
|
"clean:tests": "rimraf test-types/**/node_modules && rimraf test-types/**/dist",
|
|
11
33
|
"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
34
|
"test": "run-s test:*",
|
|
18
35
|
"test:lint": "eslint . --ext .js,.jsx,.ts,.tsx",
|
|
19
|
-
"test:unit": "
|
|
20
|
-
"watch": "npm run compile -- --watch",
|
|
36
|
+
"test:unit": "vitest",
|
|
21
37
|
"test:types": "node test-types/copy && npm run ts && npm run clean:tests",
|
|
22
38
|
"ts": "run-p ts:*",
|
|
23
39
|
"ts:default": "cd test-types/default && tsc --incremental",
|
|
24
40
|
"ts:jest": "cd test-types/jest && tsc --incremental",
|
|
25
41
|
"ts:jasmine": "cd test-types/jasmine && tsc --incremental",
|
|
42
|
+
"watch": "npm run compile -- --watch",
|
|
26
43
|
"prepare": "husky install"
|
|
27
44
|
},
|
|
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
45
|
"devDependencies": {
|
|
45
|
-
"@types/
|
|
46
|
-
"@types/
|
|
47
|
-
"@
|
|
48
|
-
"@typescript-eslint/
|
|
49
|
-
"@
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
46
|
+
"@types/jest": "^29.2.3",
|
|
47
|
+
"@types/node": "^18.11.9",
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^5.44.0",
|
|
49
|
+
"@typescript-eslint/parser": "^5.44.0",
|
|
50
|
+
"@vitest/coverage-c8": "^0.25.2",
|
|
51
|
+
"@wdio/globals": "^8.0.0-alpha.505",
|
|
52
|
+
"c8": "^7.12.0",
|
|
53
|
+
"eslint": "^8.28.0",
|
|
54
|
+
"eslint-plugin-import": "^2.26.0",
|
|
55
|
+
"eslint-plugin-unicorn": "^45.0.0",
|
|
56
|
+
"husky": "^8.0.2",
|
|
53
57
|
"npm-run-all": "^4.1.5",
|
|
54
|
-
"release-it": "^
|
|
58
|
+
"release-it": "^15.5.0",
|
|
55
59
|
"rimraf": "^3.0.2",
|
|
56
|
-
"shelljs": "^0.8.
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
|
|
60
|
+
"shelljs": "^0.8.5",
|
|
61
|
+
"typescript": "^4.9.3",
|
|
62
|
+
"vitest": "0.25.3",
|
|
63
|
+
"webdriverio": "^8.0.0-alpha.505"
|
|
64
|
+
},
|
|
65
|
+
"optionalDependencies": {
|
|
66
|
+
"@wdio/globals": "^8.0.0-alpha.505",
|
|
67
|
+
"webdriverio": "^8.0.0-alpha.505"
|
|
61
68
|
},
|
|
62
|
-
"types": "types/jest-global.d.ts",
|
|
63
|
-
"typeScriptVersion": "3.8.3",
|
|
64
69
|
"dependencies": {
|
|
65
|
-
"expect": "^
|
|
66
|
-
"jest-matcher-utils": "^
|
|
70
|
+
"expect": "^29.3.1",
|
|
71
|
+
"jest-matcher-utils": "^29.3.1"
|
|
67
72
|
}
|
|
68
73
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
declare namespace ExpectWebdriverIO {
|
|
2
|
+
function expect<T = unknown>(actual: T): Matchers<T, T>
|
|
2
3
|
function setOptions(options: DefaultOptions): void
|
|
3
4
|
|
|
4
5
|
interface DefaultOptions {
|
|
@@ -83,11 +84,11 @@ declare namespace ExpectWebdriverIO {
|
|
|
83
84
|
/**
|
|
84
85
|
* `WebdriverIO.Element` -> `getAttribute`
|
|
85
86
|
*/
|
|
86
|
-
toHaveAttribute(attribute: string, value?: string, options?: ExpectWebdriverIO.StringOptions): R
|
|
87
|
+
toHaveAttribute(attribute: string, value?: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
87
88
|
/**
|
|
88
89
|
* `WebdriverIO.Element` -> `getAttribute`
|
|
89
90
|
*/
|
|
90
|
-
toHaveAttr(attribute: string, value?: string, options?: ExpectWebdriverIO.StringOptions): R
|
|
91
|
+
toHaveAttr(attribute: string, value?: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
91
92
|
|
|
92
93
|
/**
|
|
93
94
|
* `WebdriverIO.Element` -> `getAttribute`
|
|
@@ -95,7 +96,7 @@ declare namespace ExpectWebdriverIO {
|
|
|
95
96
|
*/
|
|
96
97
|
toHaveAttributeContaining(
|
|
97
98
|
attribute: string,
|
|
98
|
-
contains: string,
|
|
99
|
+
contains: string | RegExp,
|
|
99
100
|
options?: ExpectWebdriverIO.StringOptions
|
|
100
101
|
): R
|
|
101
102
|
/**
|
|
@@ -104,7 +105,7 @@ declare namespace ExpectWebdriverIO {
|
|
|
104
105
|
*/
|
|
105
106
|
toHaveAttrContaining(
|
|
106
107
|
attribute: string,
|
|
107
|
-
contains: string,
|
|
108
|
+
contains: string | RegExp,
|
|
108
109
|
options?: ExpectWebdriverIO.StringOptions
|
|
109
110
|
): R
|
|
110
111
|
|
|
@@ -112,40 +113,40 @@ declare namespace ExpectWebdriverIO {
|
|
|
112
113
|
* `WebdriverIO.Element` -> `getAttribute` class
|
|
113
114
|
* @deprecated since v1.3.1 - use `toHaveElementClass` instead.
|
|
114
115
|
*/
|
|
115
|
-
toHaveClass(className: string, options?: ExpectWebdriverIO.StringOptions): R
|
|
116
|
+
toHaveClass(className: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
116
117
|
|
|
117
118
|
/**
|
|
118
119
|
* `WebdriverIO.Element` -> `getAttribute` class
|
|
119
120
|
*/
|
|
120
|
-
toHaveElementClass(className: string, options?: ExpectWebdriverIO.StringOptions): R
|
|
121
|
+
toHaveElementClass(className: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
121
122
|
|
|
122
123
|
/**
|
|
123
124
|
* `WebdriverIO.Element` -> `getAttribute` class
|
|
124
125
|
* @deprecated since v1.3.1 - use `toHaveElementClassContaining` instead.
|
|
125
126
|
* Element's class includes the className.
|
|
126
127
|
*/
|
|
127
|
-
toHaveClassContaining(className: string, options?: ExpectWebdriverIO.StringOptions): R
|
|
128
|
+
toHaveClassContaining(className: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
128
129
|
|
|
129
130
|
/**
|
|
130
131
|
* `WebdriverIO.Element` -> `getAttribute` class
|
|
131
132
|
* Element's class includes the className.
|
|
132
133
|
*/
|
|
133
|
-
toHaveElementClassContaining(className: string, options?: ExpectWebdriverIO.StringOptions): R
|
|
134
|
+
toHaveElementClassContaining(className: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
134
135
|
|
|
135
136
|
/**
|
|
136
137
|
* `WebdriverIO.Element` -> `getProperty`
|
|
137
138
|
*/
|
|
138
|
-
toHaveElementProperty(property: string, value?: any, options?: ExpectWebdriverIO.StringOptions): R
|
|
139
|
+
toHaveElementProperty(property: string | RegExp, value?: any, options?: ExpectWebdriverIO.StringOptions): R
|
|
139
140
|
|
|
140
141
|
/**
|
|
141
142
|
* `WebdriverIO.Element` -> `getProperty` value
|
|
142
143
|
*/
|
|
143
|
-
toHaveValue(value: string, options?: ExpectWebdriverIO.StringOptions): R
|
|
144
|
+
toHaveValue(value: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
144
145
|
/**
|
|
145
146
|
* `WebdriverIO.Element` -> `getProperty` value
|
|
146
147
|
* Element's value includes the value.
|
|
147
148
|
*/
|
|
148
|
-
toHaveValueContaining(value: string, options?: ExpectWebdriverIO.StringOptions): R
|
|
149
|
+
toHaveValueContaining(value: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
149
150
|
|
|
150
151
|
/**
|
|
151
152
|
* `WebdriverIO.Element` -> `isClickable`
|
|
@@ -194,37 +195,37 @@ declare namespace ExpectWebdriverIO {
|
|
|
194
195
|
/**
|
|
195
196
|
* `WebdriverIO.Element` -> `getAttribute` href
|
|
196
197
|
*/
|
|
197
|
-
toHaveHref(href: string, options?: ExpectWebdriverIO.StringOptions): R
|
|
198
|
+
toHaveHref(href: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
198
199
|
/**
|
|
199
200
|
* `WebdriverIO.Element` -> `getAttribute` href
|
|
200
201
|
*/
|
|
201
|
-
toHaveLink(href: string, options?: ExpectWebdriverIO.StringOptions): R
|
|
202
|
+
toHaveLink(href: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
202
203
|
|
|
203
204
|
/**
|
|
204
205
|
* `WebdriverIO.Element` -> `getAttribute` href
|
|
205
206
|
* Element's href includes the value provided
|
|
206
207
|
*/
|
|
207
|
-
toHaveHrefContaining(href: string, options?: ExpectWebdriverIO.StringOptions): R
|
|
208
|
+
toHaveHrefContaining(href: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
208
209
|
/**
|
|
209
210
|
* `WebdriverIO.Element` -> `getAttribute` href
|
|
210
211
|
* Element's href includes the value provided
|
|
211
212
|
*/
|
|
212
|
-
toHaveLinkContaining(href: string, options?: ExpectWebdriverIO.StringOptions): R
|
|
213
|
+
toHaveLinkContaining(href: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
213
214
|
|
|
214
215
|
/**
|
|
215
216
|
* `WebdriverIO.Element` -> `getProperty` value
|
|
216
217
|
*/
|
|
217
|
-
toHaveId(id: string, options?: ExpectWebdriverIO.StringOptions): R
|
|
218
|
+
toHaveId(id: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
218
219
|
|
|
219
220
|
/**
|
|
220
221
|
* `WebdriverIO.Element` -> `getText`
|
|
221
222
|
*/
|
|
222
|
-
toHaveText(text: string | string
|
|
223
|
+
toHaveText(text: string | RegExp | Array<string | RegExp>, options?: ExpectWebdriverIO.StringOptions): R
|
|
223
224
|
/**
|
|
224
225
|
* `WebdriverIO.Element` -> `getText`
|
|
225
226
|
* Element's text includes the text provided
|
|
226
227
|
*/
|
|
227
|
-
toHaveTextContaining(text: string | string
|
|
228
|
+
toHaveTextContaining(text: string | RegExp | Array<string | RegExp>, options?: ExpectWebdriverIO.StringOptions): R
|
|
228
229
|
|
|
229
230
|
/**
|
|
230
231
|
* `WebdriverIO.Element` -> `getAttribute("style")`
|
|
@@ -235,26 +236,26 @@ declare namespace ExpectWebdriverIO {
|
|
|
235
236
|
/**
|
|
236
237
|
* `WebdriverIO.Browser` -> `getUrl`
|
|
237
238
|
*/
|
|
238
|
-
toHaveUrl(url: string, options?: ExpectWebdriverIO.StringOptions): R
|
|
239
|
+
toHaveUrl(url: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
239
240
|
|
|
240
241
|
// ===== browser only =====
|
|
241
242
|
/**
|
|
242
243
|
* `WebdriverIO.Browser` -> `getUrl`
|
|
243
244
|
* Browser's url includes the provided text
|
|
244
245
|
*/
|
|
245
|
-
toHaveUrlContaining(url: string, options?: ExpectWebdriverIO.StringOptions): R
|
|
246
|
+
toHaveUrlContaining(url: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
246
247
|
|
|
247
248
|
/**
|
|
248
249
|
* `WebdriverIO.Browser` -> `getTitle`
|
|
249
250
|
*/
|
|
250
|
-
toHaveTitle(title: string, options?: ExpectWebdriverIO.StringOptions): R
|
|
251
|
+
toHaveTitle(title: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
251
252
|
|
|
252
253
|
// ===== browser only =====
|
|
253
254
|
/**
|
|
254
255
|
* `WebdriverIO.Browser` -> `getTitle`
|
|
255
256
|
* Browser's title includes the provided text
|
|
256
257
|
*/
|
|
257
|
-
toHaveTitleContaining(title: string, options?: ExpectWebdriverIO.StringOptions): R
|
|
258
|
+
toHaveTitleContaining(title: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
258
259
|
|
|
259
260
|
// ===== $$ only =====
|
|
260
261
|
/**
|
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/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 (!exports.loadExpect()) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
global.expect = expectLib;
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
expectLib = global.expect;
|
|
27
|
-
}
|
|
28
|
-
if (!global.expect.extend && !exports.isJasmine()) {
|
|
29
|
-
if (!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.addAsyncMatchers({ ...matchers });
|
|
45
|
-
global.expect = global.expectAsync;
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
exports.addMatchers = addMatchers;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toHaveClass = exports.toHaveElementClass = void 0;
|
|
4
|
-
const utils_1 = require("../../utils");
|
|
5
|
-
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
6
|
-
async function condition(el, attribute, value, options) {
|
|
7
|
-
const { ignoreCase = false, trim = false, containing = false } = options;
|
|
8
|
-
let attr = await el.getAttribute(attribute);
|
|
9
|
-
if (typeof attr !== 'string') {
|
|
10
|
-
return { result: false };
|
|
11
|
-
}
|
|
12
|
-
if (trim) {
|
|
13
|
-
attr = attr.trim();
|
|
14
|
-
}
|
|
15
|
-
if (ignoreCase) {
|
|
16
|
-
attr = attr.toLowerCase();
|
|
17
|
-
value = value.toLowerCase();
|
|
18
|
-
}
|
|
19
|
-
if (containing) {
|
|
20
|
-
return {
|
|
21
|
-
result: attr.includes(value),
|
|
22
|
-
value: attr
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
const classes = attr.split(' ');
|
|
26
|
-
return {
|
|
27
|
-
result: classes.includes(value),
|
|
28
|
-
value: attr
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
function toHaveElementClassFn(received, className, options = {}) {
|
|
32
|
-
const isNot = this.isNot;
|
|
33
|
-
const { expectation = 'class', verb = 'have' } = this;
|
|
34
|
-
const attribute = 'class';
|
|
35
|
-
return browser.call(async () => {
|
|
36
|
-
let el = await received;
|
|
37
|
-
let attr;
|
|
38
|
-
const pass = await utils_1.waitUntil(async () => {
|
|
39
|
-
const result = await utils_1.executeCommand.call(this, el, condition, options, [attribute, className, options]);
|
|
40
|
-
el = result.el;
|
|
41
|
-
attr = result.values;
|
|
42
|
-
return result.success;
|
|
43
|
-
}, isNot, options);
|
|
44
|
-
utils_1.updateElementsArray(pass, received, el);
|
|
45
|
-
const message = utils_1.enhanceError(el, utils_1.wrapExpectedWithArray(el, attr, className), attr, this, verb, expectation, '', options);
|
|
46
|
-
return {
|
|
47
|
-
pass,
|
|
48
|
-
message: () => message
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
function toHaveElementClass(...args) {
|
|
53
|
-
return expectAdapter_1.runExpect.call(this, toHaveElementClassFn, args);
|
|
54
|
-
}
|
|
55
|
-
exports.toHaveElementClass = toHaveElementClass;
|
|
56
|
-
function toHaveClass(...args) {
|
|
57
|
-
console.warn('expect(...).toHaveClass is deprecated and will be removed in next release. Use toHaveElementClass instead.');
|
|
58
|
-
return expectAdapter_1.runExpect.call(this, toHaveElementClassFn, args);
|
|
59
|
-
}
|
|
60
|
-
exports.toHaveClass = toHaveClass;
|
|
@@ -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 = 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 => exports.buildJasmineFromJestResult(jestStyleResult, isNot));
|
|
23
|
-
}
|
|
24
|
-
return exports.buildJasmineFromJestResult(result, isNot);
|
|
25
|
-
};
|
|
26
|
-
exports.jestResultToJasmine = jestResultToJasmine;
|
|
27
|
-
function runJasmineExpect(fn) {
|
|
28
|
-
const context = exports.getContext(this);
|
|
29
|
-
return {
|
|
30
|
-
compare(...args) {
|
|
31
|
-
const result = fn.apply({ ...context, isNot: false }, args);
|
|
32
|
-
return exports.jestResultToJasmine(result, false);
|
|
33
|
-
},
|
|
34
|
-
negativeCompare(...args) {
|
|
35
|
-
const result = fn.apply({ ...context, isNot: true }, args);
|
|
36
|
-
return exports.jestResultToJasmine(result, true);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
exports.runJasmineExpect = runJasmineExpect;
|
|
41
|
-
exports.runExpect = MODE === 'jasmine' ? runJasmineExpect : runJestExpect;
|