expect-webdriverio 1.2.0 → 1.4.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.
@@ -5,243 +5,332 @@ declare namespace ExpectWebdriverIO {
5
5
  /**
6
6
  * time in ms to wait for expectation to succeed. Default: 3000
7
7
  */
8
- wait?: number;
8
+ wait?: number
9
9
 
10
10
  /**
11
11
  * interval between attempts. Default: 100
12
12
  */
13
- interval?: number;
13
+ interval?: number
14
14
  }
15
15
 
16
16
  interface CommandOptions extends DefaultOptions {
17
17
  /**
18
18
  * user message to prepend before assertion error
19
19
  */
20
- message?: string;
20
+ message?: string
21
21
  }
22
22
 
23
23
  interface StringOptions extends CommandOptions {
24
24
  /**
25
25
  * apply `toLowerCase` to both actual and expected values
26
26
  */
27
- ignoreCase?: boolean;
27
+ ignoreCase?: boolean
28
28
 
29
29
  /**
30
30
  * apply `trim` to actual value
31
31
  */
32
- trim?: boolean;
32
+ trim?: boolean
33
33
 
34
34
  /**
35
35
  * expect actual value to contain expected value.
36
36
  * Otherwise strict equal
37
37
  */
38
- containing?: boolean;
38
+ containing?: boolean
39
39
 
40
40
  /**
41
41
  * might be helpful to force converting property value to string
42
42
  */
43
- asString?: boolean;
43
+ asString?: boolean
44
44
  }
45
45
 
46
46
  interface NumberOptions extends CommandOptions {
47
47
  /**
48
48
  * equals
49
49
  */
50
- eq?: number;
50
+ eq?: number
51
51
  /**
52
52
  * less than or equals
53
53
  */
54
- lte?: number;
54
+ lte?: number
55
55
 
56
56
  /**
57
57
  * greater than or equals
58
58
  */
59
- gte?: number;
59
+ gte?: number
60
60
  }
61
61
 
62
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
62
63
  interface Matchers<R, T> {
63
64
  // ===== $ or $$ =====
64
65
  /**
65
66
  * `WebdriverIO.Element` -> `isDisplayed`
66
67
  */
67
- toBeDisplayed(options?: ExpectWebdriverIO.CommandOptions): R;
68
+ toBeDisplayed(options?: ExpectWebdriverIO.CommandOptions): R
68
69
  /**
69
70
  * `WebdriverIO.Element` -> `isDisplayed`
70
71
  */
71
- toBeVisible(options?: ExpectWebdriverIO.CommandOptions): R;
72
+ toBeVisible(options?: ExpectWebdriverIO.CommandOptions): R
72
73
 
73
74
  /**
74
75
  * `WebdriverIO.Element` -> `isExisting`
75
76
  */
76
- toExist(options?: ExpectWebdriverIO.CommandOptions): R;
77
+ toExist(options?: ExpectWebdriverIO.CommandOptions): R
77
78
  /**
78
79
  * `WebdriverIO.Element` -> `isExisting`
79
80
  */
80
- toBePresent(options?: ExpectWebdriverIO.CommandOptions): R;
81
+ toBePresent(options?: ExpectWebdriverIO.CommandOptions): R
81
82
  /**
82
83
  * `WebdriverIO.Element` -> `isExisting`
83
84
  */
84
- toBeExisting(options?: ExpectWebdriverIO.CommandOptions): R;
85
+ toBeExisting(options?: ExpectWebdriverIO.CommandOptions): R
85
86
 
86
87
  /**
87
88
  * `WebdriverIO.Element` -> `getAttribute`
88
89
  */
89
- toHaveAttribute(attribute: string, value?: string, options?: ExpectWebdriverIO.StringOptions): R;
90
+ toHaveAttribute(attribute: string, value?: string, options?: ExpectWebdriverIO.StringOptions): R
90
91
  /**
91
92
  * `WebdriverIO.Element` -> `getAttribute`
92
93
  */
93
- toHaveAttr(attribute: string, value?: string, options?: ExpectWebdriverIO.StringOptions): R;
94
+ toHaveAttr(attribute: string, value?: string, options?: ExpectWebdriverIO.StringOptions): R
94
95
 
95
96
  /**
96
97
  * `WebdriverIO.Element` -> `getAttribute`
97
98
  * Element's attribute includes the value.
98
99
  */
99
- toHaveAttributeContaining(attribute: string, contains: string, options?: ExpectWebdriverIO.StringOptions): R;
100
+ toHaveAttributeContaining(
101
+ attribute: string,
102
+ contains: string,
103
+ options?: ExpectWebdriverIO.StringOptions
104
+ ): R
100
105
  /**
101
106
  * `WebdriverIO.Element` -> `getAttribute`
102
107
  * Element's attribute includes the value.
103
108
  */
104
- toHaveAttrContaining(attribute: string, contains: string, options?: ExpectWebdriverIO.StringOptions): R;
109
+ toHaveAttrContaining(
110
+ attribute: string,
111
+ contains: string,
112
+ options?: ExpectWebdriverIO.StringOptions
113
+ ): R
105
114
 
106
115
  /**
107
116
  * `WebdriverIO.Element` -> `getAttribute` class
117
+ * @deprecated since v1.3.1 - use `toHaveElementClass` instead.
108
118
  */
109
- toHaveClass(className: string, options?: ExpectWebdriverIO.StringOptions): R;
119
+ toHaveClass(className: string, options?: ExpectWebdriverIO.StringOptions): R
120
+
110
121
  /**
111
122
  * `WebdriverIO.Element` -> `getAttribute` class
123
+ */
124
+ toHaveElementClass(className: string, options?: ExpectWebdriverIO.StringOptions): R
125
+
126
+ /**
127
+ * `WebdriverIO.Element` -> `getAttribute` class
128
+ * @deprecated since v1.3.1 - use `toHaveElementClassContaining` instead.
112
129
  * Element's class includes the className.
113
130
  */
114
- toHaveClassContaining(className: string, options?: ExpectWebdriverIO.StringOptions): R;
131
+ toHaveClassContaining(className: string, options?: ExpectWebdriverIO.StringOptions): R
132
+
133
+ /**
134
+ * `WebdriverIO.Element` -> `getAttribute` class
135
+ * Element's class includes the className.
136
+ */
137
+ toHaveElementClassContaining(className: string, options?: ExpectWebdriverIO.StringOptions): R
115
138
 
116
139
  /**
117
140
  * `WebdriverIO.Element` -> `getProperty`
141
+ * @deprecated since v1.3.1 - use `toHaveElementProperty` instead.
118
142
  */
119
- toHaveProperty(property: string, value?: any, options?: ExpectWebdriverIO.StringOptions): R;
143
+ toHaveProperty(property: string, value?: any, options?: ExpectWebdriverIO.StringOptions): R
120
144
 
121
145
  /**
122
- * `WebdriverIO.Element` -> `getProperty` value
123
- */
124
- toHaveValue(value: string, options?: ExpectWebdriverIO.StringOptions): R;
146
+ * `WebdriverIO.Element` -> `getProperty`
147
+ */
148
+ toHaveElementProperty(property: string, value?: any, options?: ExpectWebdriverIO.StringOptions): R
149
+
150
+ /**
151
+ * `WebdriverIO.Element` -> `getProperty` value
152
+ */
153
+ toHaveValue(value: string, options?: ExpectWebdriverIO.StringOptions): R
125
154
  /**
126
155
  * `WebdriverIO.Element` -> `getProperty` value
127
156
  * Element's value includes the value.
128
157
  */
129
- toHaveValueContaining(value: string, options?: ExpectWebdriverIO.StringOptions): R;
158
+ toHaveValueContaining(value: string, options?: ExpectWebdriverIO.StringOptions): R
130
159
 
131
160
  /**
132
- * `WebdriverIO.Element` -> `isClickable`
133
- */
134
- toBeClickable(options?: ExpectWebdriverIO.StringOptions): R;
161
+ * `WebdriverIO.Element` -> `isClickable`
162
+ */
163
+ toBeClickable(options?: ExpectWebdriverIO.StringOptions): R
135
164
 
136
165
  /**
137
- * `WebdriverIO.Element` -> `!isEnabled`
138
- */
139
- toBeDisabled(options?: ExpectWebdriverIO.StringOptions): R;
166
+ * `WebdriverIO.Element` -> `!isEnabled`
167
+ */
168
+ toBeDisabled(options?: ExpectWebdriverIO.StringOptions): R
140
169
 
141
170
  /**
142
- * `WebdriverIO.Element` -> `isDisplayedInViewport`
143
- */
144
- toBeDisplayedInViewport(options?: ExpectWebdriverIO.StringOptions): R;
171
+ * `WebdriverIO.Element` -> `isDisplayedInViewport`
172
+ */
173
+ toBeDisplayedInViewport(options?: ExpectWebdriverIO.StringOptions): R
145
174
  /**
146
- * `WebdriverIO.Element` -> `isDisplayedInViewport`
147
- */
148
- toBeVisibleInViewport(options?: ExpectWebdriverIO.StringOptions): R;
175
+ * `WebdriverIO.Element` -> `isDisplayedInViewport`
176
+ */
177
+ toBeVisibleInViewport(options?: ExpectWebdriverIO.StringOptions): R
149
178
 
150
179
  /**
151
- * `WebdriverIO.Element` -> `isEnabled`
152
- */
153
- toBeEnabled(options?: ExpectWebdriverIO.StringOptions): R;
180
+ * `WebdriverIO.Element` -> `isEnabled`
181
+ */
182
+ toBeEnabled(options?: ExpectWebdriverIO.StringOptions): R
154
183
 
155
184
  /**
156
- * `WebdriverIO.Element` -> `isFocused`
157
- */
158
- toBeFocused(options?: ExpectWebdriverIO.StringOptions): R;
185
+ * `WebdriverIO.Element` -> `isFocused`
186
+ */
187
+ toBeFocused(options?: ExpectWebdriverIO.StringOptions): R
159
188
 
160
189
  /**
161
- * `WebdriverIO.Element` -> `isSelected`
162
- */
163
- toBeSelected(options?: ExpectWebdriverIO.StringOptions): R;
190
+ * `WebdriverIO.Element` -> `isSelected`
191
+ */
192
+ toBeSelected(options?: ExpectWebdriverIO.StringOptions): R
164
193
 
165
194
  /**
166
- * `WebdriverIO.Element` -> `isSelected`
167
- */
168
- toBeChecked(options?: ExpectWebdriverIO.StringOptions): R;
195
+ * `WebdriverIO.Element` -> `isSelected`
196
+ */
197
+ toBeChecked(options?: ExpectWebdriverIO.StringOptions): R
169
198
 
170
199
  /**
171
- * `WebdriverIO.Element` -> `$$('./*').length`
172
- * supports less / greater then or equals to be passed in options
173
- */
174
- toHaveChildren(options?: ExpectWebdriverIO.NumberOptions): R;
200
+ * `WebdriverIO.Element` -> `$$('./*').length`
201
+ * supports less / greater then or equals to be passed in options
202
+ */
203
+ toHaveChildren(
204
+ size?: number | ExpectWebdriverIO.NumberOptions,
205
+ options?: ExpectWebdriverIO.NumberOptions
206
+ ): R
175
207
 
176
208
  /**
177
- * `WebdriverIO.Element` -> `getAttribute` href
178
- */
179
- toHaveHref(href: string, options?: ExpectWebdriverIO.StringOptions): R;
209
+ * `WebdriverIO.Element` -> `getAttribute` href
210
+ */
211
+ toHaveHref(href: string, options?: ExpectWebdriverIO.StringOptions): R
180
212
  /**
181
- * `WebdriverIO.Element` -> `getAttribute` href
182
- */
183
- toHaveLink(href: string, options?: ExpectWebdriverIO.StringOptions): R;
213
+ * `WebdriverIO.Element` -> `getAttribute` href
214
+ */
215
+ toHaveLink(href: string, options?: ExpectWebdriverIO.StringOptions): R
184
216
 
185
217
  /**
186
- * `WebdriverIO.Element` -> `getAttribute` href
187
- * Element's href includes the value provided
188
- */
189
- toHaveHrefContaining(href: string, options?: ExpectWebdriverIO.StringOptions): R;
218
+ * `WebdriverIO.Element` -> `getAttribute` href
219
+ * Element's href includes the value provided
220
+ */
221
+ toHaveHrefContaining(href: string, options?: ExpectWebdriverIO.StringOptions): R
190
222
  /**
191
- * `WebdriverIO.Element` -> `getAttribute` href
192
- * Element's href includes the value provided
193
- */
194
- toHaveLinkContaining(href: string, options?: ExpectWebdriverIO.StringOptions): R;
223
+ * `WebdriverIO.Element` -> `getAttribute` href
224
+ * Element's href includes the value provided
225
+ */
226
+ toHaveLinkContaining(href: string, options?: ExpectWebdriverIO.StringOptions): R
195
227
 
196
228
  /**
197
- * `WebdriverIO.Element` -> `getProperty` value
198
- */
199
- toHaveId(id: string, options?: ExpectWebdriverIO.StringOptions): R;
229
+ * `WebdriverIO.Element` -> `getProperty` value
230
+ */
231
+ toHaveId(id: string, options?: ExpectWebdriverIO.StringOptions): R
200
232
 
201
233
  /**
202
234
  * `WebdriverIO.Element` -> `getText`
203
235
  */
204
- toHaveText(text: string, options?: ExpectWebdriverIO.StringOptions): R;
236
+ toHaveText(text: string, options?: ExpectWebdriverIO.StringOptions): R
205
237
  /**
206
- * `WebdriverIO.Element` -> `getText`
207
- * Element's text includes the text provided
208
- */
209
- toHaveTextContaining(text: string, options?: ExpectWebdriverIO.StringOptions): R;
238
+ * `WebdriverIO.Element` -> `getText`
239
+ * Element's text includes the text provided
240
+ */
241
+ toHaveTextContaining(text: string, options?: ExpectWebdriverIO.StringOptions): R
210
242
 
211
243
  // ===== browser only =====
212
244
  /**
213
245
  * `WebdriverIO.Browser` -> `getUrl`
214
246
  */
215
- toHaveUrl(url: string, options?: ExpectWebdriverIO.StringOptions): R;
247
+ toHaveUrl(url: string, options?: ExpectWebdriverIO.StringOptions): R
216
248
 
217
249
  // ===== browser only =====
218
250
  /**
219
251
  * `WebdriverIO.Browser` -> `getUrl`
220
252
  * Browser's url includes the provided text
221
253
  */
222
- toHaveUrlContaining(url: string, options?: ExpectWebdriverIO.StringOptions): R;
254
+ toHaveUrlContaining(url: string, options?: ExpectWebdriverIO.StringOptions): R
223
255
 
224
256
  /**
225
257
  * `WebdriverIO.Browser` -> `getTitle`
226
258
  */
227
- toHaveTitle(title: string, options?: ExpectWebdriverIO.StringOptions): R;
259
+ toHaveTitle(title: string, options?: ExpectWebdriverIO.StringOptions): R
228
260
 
229
261
  // ===== browser only =====
230
262
  /**
231
263
  * `WebdriverIO.Browser` -> `getTitle`
232
264
  * Browser's title includes the provided text
233
265
  */
234
- toHaveTitleContaining(title: string, options?: ExpectWebdriverIO.StringOptions): R;
266
+ toHaveTitleContaining(title: string, options?: ExpectWebdriverIO.StringOptions): R
235
267
 
236
268
  // ===== $$ only =====
237
269
  /**
238
- * `WebdriverIO.ElementArray` -> `$$('...').length`
239
- * supports less / greater then or equals to be passed in options
240
- */
241
- toBeElementsArrayOfSize(size: number | ExpectWebdriverIO.NumberOptions, options?: ExpectWebdriverIO.NumberOptions): R;
270
+ * `WebdriverIO.ElementArray` -> `$$('...').length`
271
+ * supports less / greater then or equals to be passed in options
272
+ */
273
+ toBeElementsArrayOfSize(
274
+ size: number | ExpectWebdriverIO.NumberOptions,
275
+ options?: ExpectWebdriverIO.NumberOptions
276
+ ): R
277
+
278
+ // ==== network mock ====
279
+
280
+ /**
281
+ * Check that `WebdriverIO.Mock` was called
282
+ */
283
+ toBeRequested(options?: ExpectWebdriverIO.CommandOptions): R
284
+
285
+ /**
286
+ * Check that `WebdriverIO.Mock` was called N times
287
+ */
288
+ toBeRequestedTimes(
289
+ times: number | ExpectWebdriverIO.NumberOptions,
290
+ options?: ExpectWebdriverIO.NumberOptions
291
+ ): R
292
+
293
+ /**
294
+ * Check that `WebdriverIO.Mock` was called with the specific parameters
295
+ */
296
+ toBeRequestedWith(requestedWith: RequestedWith, options?: ExpectWebdriverIO.CommandOptions): R
297
+ }
298
+
299
+ type RequestedWith = {
300
+ url?: string | ExpectWebdriverIO.PartialMatcher | ((url: string) => boolean)
301
+ method?: string | Array<string>
302
+ statusCode?: number | Array<number>,
303
+ requestHeaders?:
304
+ | Record<string, string>
305
+ | ExpectWebdriverIO.PartialMatcher
306
+ | ((headers: Record<string, string>) => boolean)
307
+ responseHeaders?:
308
+ | Record<string, string>
309
+ | ExpectWebdriverIO.PartialMatcher
310
+ | ((headers: Record<string, string>) => boolean)
311
+ postData?:
312
+ | string
313
+ | ExpectWebdriverIO.JsonCompatible
314
+ | ExpectWebdriverIO.PartialMatcher
315
+ | ((r: string | undefined) => boolean)
316
+ response?:
317
+ | string
318
+ | ExpectWebdriverIO.JsonCompatible
319
+ | ExpectWebdriverIO.PartialMatcher
320
+ | ((r: string) => boolean)
321
+ }
322
+
323
+ type jsonPrimitive = string | number | boolean | null
324
+ type jsonObject = { [x: string]: jsonPrimitive | jsonObject | jsonArray }
325
+ type jsonArray = Array<jsonPrimitive | jsonObject | jsonArray>
326
+ type JsonCompatible = jsonObject | jsonArray
327
+
328
+ interface PartialMatcher {
329
+ sample?: any
330
+ asymmetricMatch?(...args: any[]): boolean
242
331
  }
243
332
  }
244
333
 
245
- declare module "expect-webdriverio" {
334
+ declare module 'expect-webdriverio' {
246
335
  export = ExpectWebdriverIO
247
336
  }
@@ -1,9 +1,9 @@
1
1
  /// <reference types="expect-webdriverio/types/standalone"/>
2
2
 
3
- declare const expect: jest.Expect
3
+ declare const expect: ExpectWebdriverIO.Expect
4
4
 
5
5
  declare namespace NodeJS {
6
6
  interface Global {
7
- expect: jest.Expect;
7
+ expect: ExpectWebdriverIO.Expect;
8
8
  }
9
9
  }
@@ -1,9 +1,9 @@
1
1
  /// <reference types="expect-webdriverio/types/standalone"/>
2
2
 
3
- declare const expectWdio: jest.Expect
3
+ declare const expectWdio: ExpectWebdriverIO.Expect
4
4
 
5
5
  declare namespace NodeJS {
6
6
  interface Global {
7
- expectWdio: jest.Expect;
7
+ expectWdio: ExpectWebdriverIO.Expect;
8
8
  }
9
9
  }
@@ -1,2 +1,24 @@
1
- /// <reference types="expect-webdriverio/types/jest-expect-clone/jest-expect"/>
2
- /// <reference types="expect-webdriverio/jest"/>
1
+ /// <reference types="expect-webdriverio/types/expect-webdriverio"/>
2
+
3
+ declare namespace ExpectWebdriverIO {
4
+ interface Matchers<R, T> extends Readonly<import('expect/build/types').Matchers<R>> {
5
+ not: Matchers<R, T>
6
+ resolves: Matchers<Promise<R>, T>
7
+ rejects: Matchers<Promise<R>, T>
8
+ }
9
+
10
+ type Expect = {
11
+ <T = unknown>(actual: T): Matchers<T, T>
12
+ extend(map: Record<string, Function>): void
13
+ } & AsymmetricMatchers
14
+
15
+ type AsymmetricMatchers = {
16
+ any(expectedObject: any): PartialMatcher
17
+ anything(): PartialMatcher
18
+ arrayContaining(sample: Array<unknown>): PartialMatcher
19
+ objectContaining(sample: Record<string, unknown>): PartialMatcher
20
+ stringContaining(expected: string): PartialMatcher
21
+ stringMatching(expected: string | RegExp): PartialMatcher
22
+ not: AsymmetricMatchers
23
+ }
24
+ }
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toHaveClassContaining = void 0;
4
- const expectAdapter_1 = require("../../util/expectAdapter");
5
- const toHaveAttribute_1 = require("./toHaveAttribute");
6
- function toHaveClassContainingFn(el, className, options = {}) {
7
- return toHaveAttribute_1.toHaveAttributeFn.call(this, el, 'class', className, {
8
- ...options,
9
- containing: true
10
- });
11
- }
12
- function toHaveClassContaining(...args) {
13
- return expectAdapter_1.runExpect.call(this, toHaveClassContainingFn, args);
14
- }
15
- exports.toHaveClassContaining = toHaveClassContaining;
File without changes