expect-webdriverio 1.3.1 → 2.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.
@@ -10,258 +10,321 @@ declare namespace ExpectWebdriverIO {
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
108
117
  * @deprecated since v1.3.1 - use `toHaveElementClass` instead.
109
118
  */
110
- toHaveClass(className: string, options?: ExpectWebdriverIO.StringOptions): R;
119
+ toHaveClass(className: string, options?: ExpectWebdriverIO.StringOptions): R
111
120
 
112
121
  /**
113
122
  * `WebdriverIO.Element` -> `getAttribute` class
114
123
  */
115
- toHaveElementClass(className: string, options?: ExpectWebdriverIO.StringOptions): R;
124
+ toHaveElementClass(className: string, options?: ExpectWebdriverIO.StringOptions): R
116
125
 
117
126
  /**
118
127
  * `WebdriverIO.Element` -> `getAttribute` class
119
128
  * @deprecated since v1.3.1 - use `toHaveElementClassContaining` instead.
120
129
  * Element's class includes the className.
121
130
  */
122
- toHaveClassContaining(className: string, options?: ExpectWebdriverIO.StringOptions): R;
131
+ toHaveClassContaining(className: string, options?: ExpectWebdriverIO.StringOptions): R
123
132
 
124
133
  /**
125
134
  * `WebdriverIO.Element` -> `getAttribute` class
126
135
  * Element's class includes the className.
127
136
  */
128
- toHaveElementClassContaining(className: string, options?: ExpectWebdriverIO.StringOptions): R;
137
+ toHaveElementClassContaining(className: string, options?: ExpectWebdriverIO.StringOptions): R
129
138
 
130
139
  /**
131
140
  * `WebdriverIO.Element` -> `getProperty`
132
- * @deprecated since v1.3.1 - use `toHaveElementProperty` instead.
133
141
  */
134
- toHaveProperty(property: string, value?: any, options?: ExpectWebdriverIO.StringOptions): R;
142
+ toHaveElementProperty(property: string, value?: any, options?: ExpectWebdriverIO.StringOptions): R
135
143
 
136
144
  /**
137
- * `WebdriverIO.Element` -> `getProperty`
145
+ * `WebdriverIO.Element` -> `getProperty` value
138
146
  */
139
- toHaveElementProperty(property: string, value?: any, options?: ExpectWebdriverIO.StringOptions): R;
140
-
141
- /**
142
- * `WebdriverIO.Element` -> `getProperty` value
143
- */
144
- toHaveValue(value: string, options?: ExpectWebdriverIO.StringOptions): R;
147
+ toHaveValue(value: string, options?: ExpectWebdriverIO.StringOptions): R
145
148
  /**
146
149
  * `WebdriverIO.Element` -> `getProperty` value
147
150
  * Element's value includes the value.
148
151
  */
149
- toHaveValueContaining(value: string, options?: ExpectWebdriverIO.StringOptions): R;
152
+ toHaveValueContaining(value: string, options?: ExpectWebdriverIO.StringOptions): R
150
153
 
151
154
  /**
152
- * `WebdriverIO.Element` -> `isClickable`
153
- */
154
- toBeClickable(options?: ExpectWebdriverIO.StringOptions): R;
155
+ * `WebdriverIO.Element` -> `isClickable`
156
+ */
157
+ toBeClickable(options?: ExpectWebdriverIO.StringOptions): R
155
158
 
156
159
  /**
157
- * `WebdriverIO.Element` -> `!isEnabled`
158
- */
159
- toBeDisabled(options?: ExpectWebdriverIO.StringOptions): R;
160
+ * `WebdriverIO.Element` -> `!isEnabled`
161
+ */
162
+ toBeDisabled(options?: ExpectWebdriverIO.StringOptions): R
160
163
 
161
164
  /**
162
- * `WebdriverIO.Element` -> `isDisplayedInViewport`
163
- */
164
- toBeDisplayedInViewport(options?: ExpectWebdriverIO.StringOptions): R;
165
+ * `WebdriverIO.Element` -> `isDisplayedInViewport`
166
+ */
167
+ toBeDisplayedInViewport(options?: ExpectWebdriverIO.StringOptions): R
165
168
  /**
166
- * `WebdriverIO.Element` -> `isDisplayedInViewport`
167
- */
168
- toBeVisibleInViewport(options?: ExpectWebdriverIO.StringOptions): R;
169
+ * `WebdriverIO.Element` -> `isDisplayedInViewport`
170
+ */
171
+ toBeVisibleInViewport(options?: ExpectWebdriverIO.StringOptions): R
169
172
 
170
173
  /**
171
- * `WebdriverIO.Element` -> `isEnabled`
172
- */
173
- toBeEnabled(options?: ExpectWebdriverIO.StringOptions): R;
174
+ * `WebdriverIO.Element` -> `isEnabled`
175
+ */
176
+ toBeEnabled(options?: ExpectWebdriverIO.StringOptions): R
174
177
 
175
178
  /**
176
- * `WebdriverIO.Element` -> `isFocused`
177
- */
178
- toBeFocused(options?: ExpectWebdriverIO.StringOptions): R;
179
+ * `WebdriverIO.Element` -> `isFocused`
180
+ */
181
+ toBeFocused(options?: ExpectWebdriverIO.StringOptions): R
179
182
 
180
183
  /**
181
- * `WebdriverIO.Element` -> `isSelected`
182
- */
183
- toBeSelected(options?: ExpectWebdriverIO.StringOptions): R;
184
+ * `WebdriverIO.Element` -> `isSelected`
185
+ */
186
+ toBeSelected(options?: ExpectWebdriverIO.StringOptions): R
184
187
 
185
188
  /**
186
- * `WebdriverIO.Element` -> `isSelected`
187
- */
188
- toBeChecked(options?: ExpectWebdriverIO.StringOptions): R;
189
+ * `WebdriverIO.Element` -> `isSelected`
190
+ */
191
+ toBeChecked(options?: ExpectWebdriverIO.StringOptions): R
189
192
 
190
193
  /**
191
- * `WebdriverIO.Element` -> `$$('./*').length`
192
- * supports less / greater then or equals to be passed in options
193
- */
194
- toHaveChildren(size?: number | ExpectWebdriverIO.NumberOptions, options?: ExpectWebdriverIO.NumberOptions): R;
194
+ * `WebdriverIO.Element` -> `$$('./*').length`
195
+ * supports less / greater then or equals to be passed in options
196
+ */
197
+ toHaveChildren(
198
+ size?: number | ExpectWebdriverIO.NumberOptions,
199
+ options?: ExpectWebdriverIO.NumberOptions
200
+ ): R
195
201
 
196
202
  /**
197
- * `WebdriverIO.Element` -> `getAttribute` href
198
- */
199
- toHaveHref(href: string, options?: ExpectWebdriverIO.StringOptions): R;
203
+ * `WebdriverIO.Element` -> `getAttribute` href
204
+ */
205
+ toHaveHref(href: string, options?: ExpectWebdriverIO.StringOptions): R
200
206
  /**
201
- * `WebdriverIO.Element` -> `getAttribute` href
202
- */
203
- toHaveLink(href: string, options?: ExpectWebdriverIO.StringOptions): R;
207
+ * `WebdriverIO.Element` -> `getAttribute` href
208
+ */
209
+ toHaveLink(href: string, options?: ExpectWebdriverIO.StringOptions): R
204
210
 
205
211
  /**
206
- * `WebdriverIO.Element` -> `getAttribute` href
207
- * Element's href includes the value provided
208
- */
209
- toHaveHrefContaining(href: string, options?: ExpectWebdriverIO.StringOptions): R;
212
+ * `WebdriverIO.Element` -> `getAttribute` href
213
+ * Element's href includes the value provided
214
+ */
215
+ toHaveHrefContaining(href: string, options?: ExpectWebdriverIO.StringOptions): R
210
216
  /**
211
- * `WebdriverIO.Element` -> `getAttribute` href
212
- * Element's href includes the value provided
213
- */
214
- toHaveLinkContaining(href: string, options?: ExpectWebdriverIO.StringOptions): R;
217
+ * `WebdriverIO.Element` -> `getAttribute` href
218
+ * Element's href includes the value provided
219
+ */
220
+ toHaveLinkContaining(href: string, options?: ExpectWebdriverIO.StringOptions): R
215
221
 
216
222
  /**
217
- * `WebdriverIO.Element` -> `getProperty` value
218
- */
219
- toHaveId(id: string, options?: ExpectWebdriverIO.StringOptions): R;
223
+ * `WebdriverIO.Element` -> `getProperty` value
224
+ */
225
+ toHaveId(id: string, options?: ExpectWebdriverIO.StringOptions): R
220
226
 
221
227
  /**
222
228
  * `WebdriverIO.Element` -> `getText`
223
229
  */
224
- toHaveText(text: string, options?: ExpectWebdriverIO.StringOptions): R;
230
+ toHaveText(text: string | string[], options?: ExpectWebdriverIO.StringOptions): R
225
231
  /**
226
- * `WebdriverIO.Element` -> `getText`
227
- * Element's text includes the text provided
228
- */
229
- toHaveTextContaining(text: string, options?: ExpectWebdriverIO.StringOptions): R;
232
+ * `WebdriverIO.Element` -> `getText`
233
+ * Element's text includes the text provided
234
+ */
235
+ toHaveTextContaining(text: string | string[], options?: ExpectWebdriverIO.StringOptions): R
230
236
 
231
237
  // ===== browser only =====
232
238
  /**
233
239
  * `WebdriverIO.Browser` -> `getUrl`
234
240
  */
235
- toHaveUrl(url: string, options?: ExpectWebdriverIO.StringOptions): R;
241
+ toHaveUrl(url: string, options?: ExpectWebdriverIO.StringOptions): R
236
242
 
237
243
  // ===== browser only =====
238
244
  /**
239
245
  * `WebdriverIO.Browser` -> `getUrl`
240
246
  * Browser's url includes the provided text
241
247
  */
242
- toHaveUrlContaining(url: string, options?: ExpectWebdriverIO.StringOptions): R;
248
+ toHaveUrlContaining(url: string, options?: ExpectWebdriverIO.StringOptions): R
243
249
 
244
250
  /**
245
251
  * `WebdriverIO.Browser` -> `getTitle`
246
252
  */
247
- toHaveTitle(title: string, options?: ExpectWebdriverIO.StringOptions): R;
253
+ toHaveTitle(title: string, options?: ExpectWebdriverIO.StringOptions): R
248
254
 
249
255
  // ===== browser only =====
250
256
  /**
251
257
  * `WebdriverIO.Browser` -> `getTitle`
252
258
  * Browser's title includes the provided text
253
259
  */
254
- toHaveTitleContaining(title: string, options?: ExpectWebdriverIO.StringOptions): R;
260
+ toHaveTitleContaining(title: string, options?: ExpectWebdriverIO.StringOptions): R
255
261
 
256
262
  // ===== $$ only =====
257
263
  /**
258
- * `WebdriverIO.ElementArray` -> `$$('...').length`
259
- * supports less / greater then or equals to be passed in options
260
- */
261
- toBeElementsArrayOfSize(size: number | ExpectWebdriverIO.NumberOptions, options?: ExpectWebdriverIO.NumberOptions): R;
264
+ * `WebdriverIO.ElementArray` -> `$$('...').length`
265
+ * supports less / greater then or equals to be passed in options
266
+ */
267
+ toBeElementsArrayOfSize(
268
+ size: number | ExpectWebdriverIO.NumberOptions,
269
+ options?: ExpectWebdriverIO.NumberOptions
270
+ ): R
271
+
272
+ // ==== network mock ====
273
+
274
+ /**
275
+ * Check that `WebdriverIO.Mock` was called
276
+ */
277
+ toBeRequested(options?: ExpectWebdriverIO.CommandOptions): R
278
+
279
+ /**
280
+ * Check that `WebdriverIO.Mock` was called N times
281
+ */
282
+ toBeRequestedTimes(
283
+ times: number | ExpectWebdriverIO.NumberOptions,
284
+ options?: ExpectWebdriverIO.NumberOptions
285
+ ): R
286
+
287
+ /**
288
+ * Check that `WebdriverIO.Mock` was called with the specific parameters
289
+ */
290
+ toBeRequestedWith(requestedWith: RequestedWith, options?: ExpectWebdriverIO.CommandOptions): R
291
+ }
292
+
293
+ type RequestedWith = {
294
+ url?: string | ExpectWebdriverIO.PartialMatcher | ((url: string) => boolean)
295
+ method?: string | Array<string>
296
+ statusCode?: number | Array<number>
297
+ requestHeaders?:
298
+ | Record<string, string>
299
+ | ExpectWebdriverIO.PartialMatcher
300
+ | ((headers: Record<string, string>) => boolean)
301
+ responseHeaders?:
302
+ | Record<string, string>
303
+ | ExpectWebdriverIO.PartialMatcher
304
+ | ((headers: Record<string, string>) => boolean)
305
+ postData?:
306
+ | string
307
+ | ExpectWebdriverIO.JsonCompatible
308
+ | ExpectWebdriverIO.PartialMatcher
309
+ | ((r: string | undefined) => boolean)
310
+ response?:
311
+ | string
312
+ | ExpectWebdriverIO.JsonCompatible
313
+ | ExpectWebdriverIO.PartialMatcher
314
+ | ((r: string) => boolean)
315
+ }
316
+
317
+ type jsonPrimitive = string | number | boolean | null
318
+ type jsonObject = { [x: string]: jsonPrimitive | jsonObject | jsonArray }
319
+ type jsonArray = Array<jsonPrimitive | jsonObject | jsonArray>
320
+ type JsonCompatible = jsonObject | jsonArray
321
+
322
+ interface PartialMatcher {
323
+ sample?: any
324
+ asymmetricMatch?(...args: any[]): boolean
262
325
  }
263
326
  }
264
327
 
265
- declare module "expect-webdriverio" {
328
+ declare module 'expect-webdriverio' {
266
329
  export = ExpectWebdriverIO
267
330
  }
@@ -1,12 +1,24 @@
1
1
  /// <reference types="expect-webdriverio/types/expect-webdriverio"/>
2
2
 
3
3
  declare namespace ExpectWebdriverIO {
4
- interface Matchers <R,T> extends Readonly<import('expect/build/types').Matchers<R>> {
5
- not: Matchers <R,T>
4
+ interface Matchers<R, T> extends Readonly<import('expect/build/types').Matchers<R>> {
5
+ not: Matchers<R, T>
6
6
  resolves: Matchers<Promise<R>, T>
7
7
  rejects: Matchers<Promise<R>, T>
8
8
  }
9
+
9
10
  type Expect = {
10
- <T = unknown>(actual: T): Matchers<T, T>;
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
11
23
  }
12
24
  }
File without changes