expect-webdriverio 4.5.0 → 4.5.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { waitUntil, enhanceError, executeCommand, wrapExpectedWithArray, updateElementsArray } from '../../utils.js';
|
|
1
|
+
import { waitUntil, enhanceError, executeCommand, wrapExpectedWithArray, updateElementsArray, compareText } from '../../utils.js';
|
|
2
2
|
async function condition(el, attribute, value, options) {
|
|
3
3
|
const { ignoreCase = false, trim = false, containing = false } = options;
|
|
4
4
|
let attr = await el.getAttribute(attribute);
|
|
@@ -10,13 +10,17 @@ async function condition(el, attribute, value, options) {
|
|
|
10
10
|
}
|
|
11
11
|
if (ignoreCase) {
|
|
12
12
|
attr = attr.toLowerCase();
|
|
13
|
-
if (
|
|
13
|
+
if (typeof value === 'string') {
|
|
14
14
|
value = value.toLowerCase();
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
const classes = attr.split(' ');
|
|
18
18
|
const valueInClasses = classes.some((t) => {
|
|
19
|
-
return value instanceof RegExp
|
|
19
|
+
return value instanceof RegExp
|
|
20
|
+
? !!t.match(value)
|
|
21
|
+
: containing && typeof value === 'string'
|
|
22
|
+
? t.includes(value)
|
|
23
|
+
: compareText(t, value, options);
|
|
20
24
|
});
|
|
21
25
|
return {
|
|
22
26
|
value: attr,
|
package/lib/utils.js
CHANGED
|
@@ -78,14 +78,6 @@ export const compareText = (actual, expected, { ignoreCase = false, trim = true,
|
|
|
78
78
|
result: false,
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
|
-
if (typeof expected === 'object' && '$$typeof' in expected && expected.$$typeof === asymmetricMatcher) {
|
|
82
|
-
const result = expected.asymmetricMatch(actual);
|
|
83
|
-
return {
|
|
84
|
-
value: actual,
|
|
85
|
-
result
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
expected = expected;
|
|
89
81
|
if (trim) {
|
|
90
82
|
actual = actual.trim();
|
|
91
83
|
}
|
|
@@ -94,10 +86,18 @@ export const compareText = (actual, expected, { ignoreCase = false, trim = true,
|
|
|
94
86
|
}
|
|
95
87
|
if (ignoreCase) {
|
|
96
88
|
actual = actual.toLowerCase();
|
|
97
|
-
if (
|
|
89
|
+
if (typeof expected === 'string') {
|
|
98
90
|
expected = expected.toLowerCase();
|
|
99
91
|
}
|
|
100
92
|
}
|
|
93
|
+
if (typeof expected === 'object' && '$$typeof' in expected && expected.$$typeof === asymmetricMatcher && expected.asymmetricMatch) {
|
|
94
|
+
const result = expected.asymmetricMatch(actual);
|
|
95
|
+
return {
|
|
96
|
+
value: actual,
|
|
97
|
+
result
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
expected = expected;
|
|
101
101
|
if (expected instanceof RegExp) {
|
|
102
102
|
return {
|
|
103
103
|
value: actual,
|
package/package.json
CHANGED
|
@@ -130,13 +130,13 @@ declare namespace ExpectWebdriverIO {
|
|
|
130
130
|
*/
|
|
131
131
|
toHaveAttribute(
|
|
132
132
|
attribute: string,
|
|
133
|
-
value?: string | RegExp,
|
|
133
|
+
value?: string | RegExp | ExpectWebdriverIO.PartialMatcher,
|
|
134
134
|
options?: ExpectWebdriverIO.StringOptions
|
|
135
135
|
): R
|
|
136
136
|
/**
|
|
137
137
|
* `WebdriverIO.Element` -> `getAttribute`
|
|
138
138
|
*/
|
|
139
|
-
toHaveAttr(attribute: string, value?: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
139
|
+
toHaveAttr(attribute: string, value?: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
140
140
|
|
|
141
141
|
/**
|
|
142
142
|
* `WebdriverIO.Element` -> `getAttribute`
|
|
@@ -144,7 +144,7 @@ declare namespace ExpectWebdriverIO {
|
|
|
144
144
|
*/
|
|
145
145
|
toHaveAttributeContaining(
|
|
146
146
|
attribute: string,
|
|
147
|
-
contains: string | RegExp,
|
|
147
|
+
contains: string | RegExp | ExpectWebdriverIO.PartialMatcher,
|
|
148
148
|
options?: ExpectWebdriverIO.StringOptions
|
|
149
149
|
): R
|
|
150
150
|
/**
|
|
@@ -153,7 +153,7 @@ declare namespace ExpectWebdriverIO {
|
|
|
153
153
|
*/
|
|
154
154
|
toHaveAttrContaining(
|
|
155
155
|
attribute: string,
|
|
156
|
-
contains: string | RegExp,
|
|
156
|
+
contains: string | RegExp | ExpectWebdriverIO.PartialMatcher,
|
|
157
157
|
options?: ExpectWebdriverIO.StringOptions
|
|
158
158
|
): R
|
|
159
159
|
|
|
@@ -161,31 +161,31 @@ declare namespace ExpectWebdriverIO {
|
|
|
161
161
|
* `WebdriverIO.Element` -> `getAttribute` class
|
|
162
162
|
* @deprecated since v1.3.1 - use `toHaveElementClass` instead.
|
|
163
163
|
*/
|
|
164
|
-
toHaveClass(className: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
164
|
+
toHaveClass(className: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
165
165
|
|
|
166
166
|
/**
|
|
167
167
|
* `WebdriverIO.Element` -> `getAttribute` class
|
|
168
168
|
*/
|
|
169
|
-
toHaveElementClass(className: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
169
|
+
toHaveElementClass(className: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
170
170
|
|
|
171
171
|
/**
|
|
172
172
|
* `WebdriverIO.Element` -> `getAttribute` class
|
|
173
173
|
* @deprecated since v1.3.1 - use `toHaveElementClassContaining` instead.
|
|
174
174
|
* Element's class includes the className.
|
|
175
175
|
*/
|
|
176
|
-
toHaveClassContaining(className: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
176
|
+
toHaveClassContaining(className: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
177
177
|
|
|
178
178
|
/**
|
|
179
179
|
* `WebdriverIO.Element` -> `getAttribute` class
|
|
180
180
|
* Element's class includes the className.
|
|
181
181
|
*/
|
|
182
|
-
toHaveElementClassContaining(className: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
182
|
+
toHaveElementClassContaining(className: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
183
183
|
|
|
184
184
|
/**
|
|
185
185
|
* `WebdriverIO.Element` -> `getProperty`
|
|
186
186
|
*/
|
|
187
187
|
toHaveElementProperty(
|
|
188
|
-
property: string | RegExp,
|
|
188
|
+
property: string | RegExp | ExpectWebdriverIO.PartialMatcher,
|
|
189
189
|
value?: any,
|
|
190
190
|
options?: ExpectWebdriverIO.StringOptions
|
|
191
191
|
): R
|
|
@@ -193,12 +193,12 @@ declare namespace ExpectWebdriverIO {
|
|
|
193
193
|
/**
|
|
194
194
|
* `WebdriverIO.Element` -> `getProperty` value
|
|
195
195
|
*/
|
|
196
|
-
toHaveValue(value: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
196
|
+
toHaveValue(value: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
197
197
|
/**
|
|
198
198
|
* `WebdriverIO.Element` -> `getProperty` value
|
|
199
199
|
* Element's value includes the value.
|
|
200
200
|
*/
|
|
201
|
-
toHaveValueContaining(value: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
201
|
+
toHaveValueContaining(value: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
202
202
|
|
|
203
203
|
/**
|
|
204
204
|
* `WebdriverIO.Element` -> `isClickable`
|
|
@@ -247,34 +247,34 @@ declare namespace ExpectWebdriverIO {
|
|
|
247
247
|
/**
|
|
248
248
|
* `WebdriverIO.Element` -> `getAttribute` href
|
|
249
249
|
*/
|
|
250
|
-
toHaveHref(href: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
250
|
+
toHaveHref(href: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
251
251
|
/**
|
|
252
252
|
* `WebdriverIO.Element` -> `getAttribute` href
|
|
253
253
|
*/
|
|
254
|
-
toHaveLink(href: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
254
|
+
toHaveLink(href: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
255
255
|
|
|
256
256
|
/**
|
|
257
257
|
* `WebdriverIO.Element` -> `getAttribute` href
|
|
258
258
|
* Element's href includes the value provided
|
|
259
259
|
*/
|
|
260
|
-
toHaveHrefContaining(href: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
260
|
+
toHaveHrefContaining(href: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
261
261
|
/**
|
|
262
262
|
* `WebdriverIO.Element` -> `getAttribute` href
|
|
263
263
|
* Element's href includes the value provided
|
|
264
264
|
*/
|
|
265
|
-
toHaveLinkContaining(href: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
265
|
+
toHaveLinkContaining(href: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
266
266
|
|
|
267
267
|
/**
|
|
268
268
|
* `WebdriverIO.Element` -> `getProperty` value
|
|
269
269
|
*/
|
|
270
|
-
toHaveId(id: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
270
|
+
toHaveId(id: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
271
271
|
|
|
272
272
|
/**
|
|
273
273
|
* `WebdriverIO.Element` -> `getText`
|
|
274
274
|
* Element's text equals the text provided
|
|
275
275
|
*/
|
|
276
276
|
toHaveText(
|
|
277
|
-
text: string | RegExp | Array<string | RegExp>,
|
|
277
|
+
text: string | RegExp | ExpectWebdriverIO.PartialMatcher | Array<string | RegExp>,
|
|
278
278
|
options?: ExpectWebdriverIO.StringOptions
|
|
279
279
|
): R
|
|
280
280
|
/**
|
|
@@ -282,7 +282,7 @@ declare namespace ExpectWebdriverIO {
|
|
|
282
282
|
* Element's text includes the text provided
|
|
283
283
|
*/
|
|
284
284
|
toHaveTextContaining(
|
|
285
|
-
text: string | RegExp | Array<string | RegExp>,
|
|
285
|
+
text: string | RegExp | ExpectWebdriverIO.PartialMatcher | Array<string | RegExp>,
|
|
286
286
|
options?: ExpectWebdriverIO.StringOptions
|
|
287
287
|
): R
|
|
288
288
|
|
|
@@ -290,13 +290,13 @@ declare namespace ExpectWebdriverIO {
|
|
|
290
290
|
* `WebdriverIO.Element` -> `getHTML`
|
|
291
291
|
* Element's html equals the html provided
|
|
292
292
|
*/
|
|
293
|
-
toHaveHTML(html: string | RegExp | Array<string | RegExp>, options?: ExpectWebdriverIO.HTMLOptions): R
|
|
293
|
+
toHaveHTML(html: string | RegExp | ExpectWebdriverIO.PartialMatcher | Array<string | RegExp>, options?: ExpectWebdriverIO.HTMLOptions): R
|
|
294
294
|
/**
|
|
295
295
|
* `WebdriverIO.Element` -> `getHTML`
|
|
296
296
|
* Element's html includes the html provided
|
|
297
297
|
*/
|
|
298
298
|
toHaveHTMLContaining(
|
|
299
|
-
html: string | RegExp | Array<string | RegExp>,
|
|
299
|
+
html: string | RegExp | ExpectWebdriverIO.PartialMatcher | Array<string | RegExp>,
|
|
300
300
|
options?: ExpectWebdriverIO.HTMLOptions
|
|
301
301
|
): R
|
|
302
302
|
|
|
@@ -305,7 +305,7 @@ declare namespace ExpectWebdriverIO {
|
|
|
305
305
|
* Element's computed label equals the computed label provided
|
|
306
306
|
*/
|
|
307
307
|
toHaveComputedLabel(
|
|
308
|
-
computedLabel: string | RegExp | Array<string | RegExp>,
|
|
308
|
+
computedLabel: string | RegExp | ExpectWebdriverIO.PartialMatcher | Array<string | RegExp>,
|
|
309
309
|
options?: ExpectWebdriverIO.StringOptions
|
|
310
310
|
): R
|
|
311
311
|
/**
|
|
@@ -313,7 +313,7 @@ declare namespace ExpectWebdriverIO {
|
|
|
313
313
|
* Element's computed label includes the computed label provided
|
|
314
314
|
*/
|
|
315
315
|
toHaveComputedLabelContaining(
|
|
316
|
-
computedLabel: string | RegExp | Array<string | RegExp>,
|
|
316
|
+
computedLabel: string | RegExp | ExpectWebdriverIO.PartialMatcher | Array<string | RegExp>,
|
|
317
317
|
options?: ExpectWebdriverIO.StringOptions
|
|
318
318
|
): R
|
|
319
319
|
|
|
@@ -322,7 +322,7 @@ declare namespace ExpectWebdriverIO {
|
|
|
322
322
|
* Element's computed role equals the computed role provided
|
|
323
323
|
*/
|
|
324
324
|
toHaveComputedRole(
|
|
325
|
-
computedRole: string | RegExp | Array<string | RegExp>,
|
|
325
|
+
computedRole: string | RegExp | ExpectWebdriverIO.PartialMatcher | Array<string | RegExp>,
|
|
326
326
|
options?: ExpectWebdriverIO.StringOptions
|
|
327
327
|
): R
|
|
328
328
|
/**
|
|
@@ -330,7 +330,7 @@ declare namespace ExpectWebdriverIO {
|
|
|
330
330
|
* Element's computed role includes the computed role provided
|
|
331
331
|
*/
|
|
332
332
|
toHaveComputedRoleContaining(
|
|
333
|
-
computedRole: string | RegExp | Array<string | RegExp>,
|
|
333
|
+
computedRole: string | RegExp | ExpectWebdriverIO.PartialMatcher | Array<string | RegExp>,
|
|
334
334
|
options?: ExpectWebdriverIO.StringOptions
|
|
335
335
|
): R
|
|
336
336
|
|
|
@@ -361,26 +361,26 @@ declare namespace ExpectWebdriverIO {
|
|
|
361
361
|
/**
|
|
362
362
|
* `WebdriverIO.Browser` -> `getUrl`
|
|
363
363
|
*/
|
|
364
|
-
toHaveUrl(url: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
364
|
+
toHaveUrl(url: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
365
365
|
|
|
366
366
|
// ===== browser only =====
|
|
367
367
|
/**
|
|
368
368
|
* `WebdriverIO.Browser` -> `getUrl`
|
|
369
369
|
* Browser's url includes the provided text
|
|
370
370
|
*/
|
|
371
|
-
toHaveUrlContaining(url: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
371
|
+
toHaveUrlContaining(url: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
372
372
|
|
|
373
373
|
/**
|
|
374
374
|
* `WebdriverIO.Browser` -> `getTitle`
|
|
375
375
|
*/
|
|
376
|
-
toHaveTitle(title: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
376
|
+
toHaveTitle(title: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
377
377
|
|
|
378
378
|
// ===== browser only =====
|
|
379
379
|
/**
|
|
380
380
|
* `WebdriverIO.Browser` -> `getTitle`
|
|
381
381
|
* Browser's title includes the provided text
|
|
382
382
|
*/
|
|
383
|
-
toHaveTitleContaining(title: string | RegExp, options?: ExpectWebdriverIO.StringOptions): R
|
|
383
|
+
toHaveTitleContaining(title: string | RegExp | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
384
384
|
|
|
385
385
|
// ===== $$ only =====
|
|
386
386
|
/**
|
|
@@ -444,7 +444,8 @@ declare namespace ExpectWebdriverIO {
|
|
|
444
444
|
|
|
445
445
|
interface PartialMatcher {
|
|
446
446
|
sample?: any
|
|
447
|
-
|
|
447
|
+
$$typeof: symbol
|
|
448
|
+
asymmetricMatch(...args: any[]): boolean
|
|
448
449
|
}
|
|
449
450
|
}
|
|
450
451
|
|
package/types/standalone.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ declare namespace ExpectWebdriverIO {
|
|
|
21
21
|
arrayContaining(sample: Array<unknown>): PartialMatcher
|
|
22
22
|
objectContaining(sample: Record<string, unknown>): PartialMatcher
|
|
23
23
|
stringContaining(expected: string): PartialMatcher
|
|
24
|
-
stringMatching(expected: string | RegExp): PartialMatcher
|
|
24
|
+
stringMatching(expected: string | RegExp | ExpectWebdriverIO.PartialMatcher): PartialMatcher
|
|
25
25
|
not: AsymmetricMatchers
|
|
26
26
|
}
|
|
27
27
|
}
|