cypress 9.1.0 → 9.3.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +25 -25
- package/bin/cypress +3 -3
- package/lib/cli.js +14 -14
- package/lib/cypress.js +27 -27
- package/lib/errors.js +25 -25
- package/lib/exec/run.js +13 -13
- package/lib/exec/shared.js +8 -8
- package/lib/tasks/cache.js +3 -3
- package/lib/tasks/download.js +76 -48
- package/lib/tasks/get-folder-size.js +8 -8
- package/lib/tasks/state.js +17 -17
- package/lib/tasks/verify.js +12 -12
- package/lib/util.js +45 -45
- package/package.json +6 -5
- package/types/chai/index.d.ts +5 -5
- package/types/cy-blob-util.d.ts +13 -13
- package/types/cy-bluebird.d.ts +12 -12
- package/types/cy-chai.d.ts +10 -10
- package/types/cy-http.d.ts +13 -13
- package/types/cy-minimatch.d.ts +96 -96
- package/types/cypress-eventemitter.d.ts +33 -29
- package/types/cypress-expect.d.ts +3 -3
- package/types/cypress-global-vars.d.ts +22 -22
- package/types/cypress-npm-api.d.ts +404 -404
- package/types/cypress-type-helpers.d.ts +2 -2
- package/types/cypress.d.ts +5860 -5774
- package/types/index.d.ts +33 -33
- package/types/jquery/JQuery.d.ts +12939 -12939
- package/types/jquery/legacy.d.ts +200 -200
- package/types/jquery/misc.d.ts +6661 -6661
- package/types/minimatch/index.d.ts +0 -0
- package/types/mocha/index.d.ts +2801 -2801
- package/types/net-stubbing.ts +553 -553
- package/types/sinon/index.d.ts +227 -217
- package/types/sinon/ts3.1/index.d.ts +0 -1789
package/types/net-stubbing.ts
CHANGED
@@ -1,553 +1,553 @@
|
|
1
|
-
// Copied from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/methods/index.d.ts
|
2
|
-
type Method =
|
3
|
-
| 'ACL'
|
4
|
-
| 'BIND'
|
5
|
-
| 'CHECKOUT'
|
6
|
-
| 'CONNECT'
|
7
|
-
| 'COPY'
|
8
|
-
| 'DELETE'
|
9
|
-
| 'GET'
|
10
|
-
| 'HEAD'
|
11
|
-
| 'LINK'
|
12
|
-
| 'LOCK'
|
13
|
-
| 'M-SEARCH'
|
14
|
-
| 'MERGE'
|
15
|
-
| 'MKACTIVITY'
|
16
|
-
| 'MKCALENDAR'
|
17
|
-
| 'MKCOL'
|
18
|
-
| 'MOVE'
|
19
|
-
| 'NOTIFY'
|
20
|
-
| 'OPTIONS'
|
21
|
-
| 'PATCH'
|
22
|
-
| 'POST'
|
23
|
-
| 'PROPFIND'
|
24
|
-
| 'PROPPATCH'
|
25
|
-
| 'PURGE'
|
26
|
-
| 'PUT'
|
27
|
-
| 'REBIND'
|
28
|
-
| 'REPORT'
|
29
|
-
| 'SEARCH'
|
30
|
-
| 'SOURCE'
|
31
|
-
| 'SUBSCRIBE'
|
32
|
-
| 'TRACE'
|
33
|
-
| 'UNBIND'
|
34
|
-
| 'UNLINK'
|
35
|
-
| 'UNLOCK'
|
36
|
-
| 'UNSUBSCRIBE'
|
37
|
-
| 'acl'
|
38
|
-
| 'bind'
|
39
|
-
| 'checkout'
|
40
|
-
| 'connect'
|
41
|
-
| 'copy'
|
42
|
-
| 'delete'
|
43
|
-
| 'get'
|
44
|
-
| 'head'
|
45
|
-
| 'link'
|
46
|
-
| 'lock'
|
47
|
-
| 'm-search'
|
48
|
-
| 'merge'
|
49
|
-
| 'mkactivity'
|
50
|
-
| 'mkcalendar'
|
51
|
-
| 'mkcol'
|
52
|
-
| 'move'
|
53
|
-
| 'notify'
|
54
|
-
| 'options'
|
55
|
-
| 'patch'
|
56
|
-
| 'post'
|
57
|
-
| 'propfind'
|
58
|
-
| 'proppatch'
|
59
|
-
| 'purge'
|
60
|
-
| 'put'
|
61
|
-
| 'rebind'
|
62
|
-
| 'report'
|
63
|
-
| 'search'
|
64
|
-
| 'source'
|
65
|
-
| 'subscribe'
|
66
|
-
| 'trace'
|
67
|
-
| 'unbind'
|
68
|
-
| 'unlink'
|
69
|
-
| 'unlock'
|
70
|
-
| 'unsubscribe'
|
71
|
-
export namespace CyHttpMessages {
|
72
|
-
export interface BaseMessage {
|
73
|
-
/**
|
74
|
-
* The body of the HTTP message.
|
75
|
-
* If a JSON Content-Type was used and the body was valid JSON, this will be an object.
|
76
|
-
* If the body was binary content, this will be a buffer.
|
77
|
-
*/
|
78
|
-
body: any
|
79
|
-
/**
|
80
|
-
* The headers of the HTTP message.
|
81
|
-
*/
|
82
|
-
headers: { [key: string]: string | string[] }
|
83
|
-
}
|
84
|
-
|
85
|
-
export type IncomingResponse = BaseMessage & {
|
86
|
-
/**
|
87
|
-
* The HTTP status code of the response.
|
88
|
-
*/
|
89
|
-
statusCode: number
|
90
|
-
/**
|
91
|
-
* The HTTP status message.
|
92
|
-
*/
|
93
|
-
statusMessage: string
|
94
|
-
/**
|
95
|
-
* Kilobytes per second to send 'body'.
|
96
|
-
*/
|
97
|
-
throttleKbps?: number
|
98
|
-
/**
|
99
|
-
* Milliseconds to delay before the response is sent.
|
100
|
-
*/
|
101
|
-
delay?: number
|
102
|
-
}
|
103
|
-
|
104
|
-
export type IncomingHttpResponse = IncomingResponse & {
|
105
|
-
/**
|
106
|
-
* Continue the HTTP response, merging the supplied values with the real response.
|
107
|
-
*/
|
108
|
-
send(status: number, body?: string | number | object, headers?: { [key: string]: string }): void
|
109
|
-
send(body: string | object, headers?: { [key: string]: string }): void
|
110
|
-
send(staticResponse: StaticResponse): void
|
111
|
-
/**
|
112
|
-
* Continue the HTTP response to the browser, including any modifications made to `res`.
|
113
|
-
*/
|
114
|
-
send(): void
|
115
|
-
/**
|
116
|
-
* Wait for `delay` milliseconds before sending the response to the client.
|
117
|
-
*/
|
118
|
-
setDelay: (delay: number) => IncomingHttpResponse
|
119
|
-
/**
|
120
|
-
* Serve the response at `throttleKbps` kilobytes per second.
|
121
|
-
*/
|
122
|
-
setThrottle: (throttleKbps: number) => IncomingHttpResponse
|
123
|
-
}
|
124
|
-
|
125
|
-
export type IncomingRequest = BaseMessage & {
|
126
|
-
/**
|
127
|
-
* Request HTTP method (GET, POST, ...).
|
128
|
-
*/
|
129
|
-
method: string
|
130
|
-
/**
|
131
|
-
* Request URL.
|
132
|
-
*/
|
133
|
-
url: string
|
134
|
-
/**
|
135
|
-
* URL query string as object.
|
136
|
-
*/
|
137
|
-
query: Record<string, string|number>
|
138
|
-
/**
|
139
|
-
* The HTTP version used in the request. Read only.
|
140
|
-
*/
|
141
|
-
httpVersion: string
|
142
|
-
/**
|
143
|
-
* If provided, the number of milliseconds before an upstream response to this request
|
144
|
-
* will time out and cause an error. By default, `responseTimeout` from config is used.
|
145
|
-
*/
|
146
|
-
responseTimeout?: number
|
147
|
-
/**
|
148
|
-
* Set if redirects should be followed when this request is made. By default, requests will
|
149
|
-
* not follow redirects before yielding the response (the 3xx redirect is yielded)
|
150
|
-
*/
|
151
|
-
followRedirect?: boolean
|
152
|
-
/**
|
153
|
-
* If set, `cy.wait` can be used to await the request/response cycle to complete for this
|
154
|
-
* request via `cy.wait('@alias')`.
|
155
|
-
*/
|
156
|
-
alias?: string
|
157
|
-
}
|
158
|
-
|
159
|
-
export interface IncomingHttpRequest extends IncomingRequest, RequestEvents {
|
160
|
-
/**
|
161
|
-
* Destroy the request and respond with a network error.
|
162
|
-
*/
|
163
|
-
destroy(): void
|
164
|
-
/**
|
165
|
-
* Send the request outgoing, skipping any other request handlers.
|
166
|
-
* If a function is passed, the request will be sent outgoing, and the function will be called
|
167
|
-
* with the response from the upstream server.
|
168
|
-
*/
|
169
|
-
continue(interceptor?: HttpResponseInterceptor): void
|
170
|
-
/**
|
171
|
-
* Control the response to this request.
|
172
|
-
* If a function is passed, the request will be sent outgoing, and the function will be called
|
173
|
-
* with the response from the upstream server.
|
174
|
-
* If a `StaticResponse` is passed, it will be used as the response, and no request will be made
|
175
|
-
* to the upstream server.
|
176
|
-
*/
|
177
|
-
reply(interceptor?: StaticResponse | HttpResponseInterceptor): void
|
178
|
-
/**
|
179
|
-
* Shortcut to reply to the request with a body and optional headers.
|
180
|
-
*/
|
181
|
-
reply(body: string | object, headers?: { [key: string]: string }): void
|
182
|
-
/**
|
183
|
-
* Shortcut to reply to the request with an HTTP status code and optional body and headers.
|
184
|
-
*/
|
185
|
-
reply(status: number, body?: string | object, headers?: { [key: string]: string }): void
|
186
|
-
/**
|
187
|
-
* Respond to this request with a redirect to a new `location`.
|
188
|
-
* @param statusCode HTTP status code to redirect with. Default: 302
|
189
|
-
*/
|
190
|
-
redirect(location: string, statusCode?: number): void
|
191
|
-
}
|
192
|
-
|
193
|
-
export interface ResponseComplete {
|
194
|
-
finalResBody?: BaseMessage['body']
|
195
|
-
}
|
196
|
-
|
197
|
-
export interface NetworkError {
|
198
|
-
error: any
|
199
|
-
}
|
200
|
-
}
|
201
|
-
|
202
|
-
export interface DictMatcher<T> {
|
203
|
-
[key: string]: T
|
204
|
-
}
|
205
|
-
|
206
|
-
/**
|
207
|
-
* Matches a string using glob (`*`) matching.
|
208
|
-
*/
|
209
|
-
export type GlobPattern = string
|
210
|
-
|
211
|
-
/**
|
212
|
-
* Interceptor for an HTTP request. If a Promise is returned, it will be awaited before passing the
|
213
|
-
* request to the next handler (if there is one), otherwise the request will be passed to the next
|
214
|
-
* handler synchronously.
|
215
|
-
*/
|
216
|
-
export type HttpRequestInterceptor = (req: CyHttpMessages.IncomingHttpRequest) => void | Promise<void>
|
217
|
-
|
218
|
-
/**
|
219
|
-
* Interceptor for an HTTP response. If a Promise is returned, it will be awaited before passing the
|
220
|
-
* request to the next handler (if there is one), otherwise the request will be passed to the next
|
221
|
-
* handler synchronously.
|
222
|
-
*/
|
223
|
-
export type HttpResponseInterceptor = (res: CyHttpMessages.IncomingHttpResponse) => void | Promise<void>
|
224
|
-
|
225
|
-
/**
|
226
|
-
* Matches a single number or any of an array of acceptable numbers.
|
227
|
-
*/
|
228
|
-
export type NumberMatcher = number | number[]
|
229
|
-
|
230
|
-
/**
|
231
|
-
* Metadata for a subscription for an interception event.
|
232
|
-
*/
|
233
|
-
export interface Subscription {
|
234
|
-
/**
|
235
|
-
* If not defined, this is a default subscription.
|
236
|
-
*/
|
237
|
-
id?: string
|
238
|
-
routeId: string
|
239
|
-
eventName: string
|
240
|
-
await: boolean
|
241
|
-
skip?: boolean
|
242
|
-
}
|
243
|
-
|
244
|
-
interface RequestEvents {
|
245
|
-
/**
|
246
|
-
* Emitted before `response` and before any `req.continue` handlers.
|
247
|
-
* Modifications to `res` will be applied to the incoming response.
|
248
|
-
* If a promise is returned from `cb`, it will be awaited before processing other event handlers.
|
249
|
-
*/
|
250
|
-
on(eventName: 'before:response', cb: HttpResponseInterceptor): this
|
251
|
-
/**
|
252
|
-
* Emitted after `before:response` and after any `req.continue` handlers - before the response is sent to the browser.
|
253
|
-
* Modifications to `res` will be applied to the incoming response.
|
254
|
-
* If a promise is returned from `cb`, it will be awaited before processing other event handlers.
|
255
|
-
*/
|
256
|
-
on(eventName: 'response', cb: HttpResponseInterceptor): this
|
257
|
-
/**
|
258
|
-
* Emitted once the response to a request has finished sending to the browser.
|
259
|
-
* Modifications to `res` have no impact.
|
260
|
-
* If a promise is returned from `cb`, it will be awaited before processing other event handlers.
|
261
|
-
*/
|
262
|
-
on(eventName: 'after:response', cb: (res: CyHttpMessages.IncomingResponse) => void | Promise<void>): this
|
263
|
-
}
|
264
|
-
|
265
|
-
/**
|
266
|
-
* Request/response cycle.
|
267
|
-
*/
|
268
|
-
export interface Interception {
|
269
|
-
id: string
|
270
|
-
/* @internal */
|
271
|
-
browserRequestId?: string
|
272
|
-
routeId: string
|
273
|
-
/* @internal */
|
274
|
-
setLogFlag: (flag: 'spied' | 'stubbed' | 'reqModified' | 'resModified') => void
|
275
|
-
request: CyHttpMessages.IncomingRequest
|
276
|
-
/**
|
277
|
-
* Was `cy.wait()` used to wait on this request?
|
278
|
-
* @internal
|
279
|
-
*/
|
280
|
-
requestWaited: boolean
|
281
|
-
response?: CyHttpMessages.IncomingResponse
|
282
|
-
/**
|
283
|
-
* The error that occurred during this request.
|
284
|
-
*/
|
285
|
-
error?: Error
|
286
|
-
/**
|
287
|
-
* Was `cy.wait()` used to wait on the response to this request?
|
288
|
-
* @internal
|
289
|
-
*/
|
290
|
-
responseWaited: boolean
|
291
|
-
/* @internal */
|
292
|
-
state: InterceptionState
|
293
|
-
/* @internal */
|
294
|
-
subscriptions: Array<{
|
295
|
-
subscription: Subscription
|
296
|
-
handler: (data: any) => Promise<void> | void
|
297
|
-
}>
|
298
|
-
}
|
299
|
-
|
300
|
-
export type InterceptionState =
|
301
|
-
'Received' |
|
302
|
-
'Intercepted' |
|
303
|
-
'ResponseReceived' |
|
304
|
-
'ResponseIntercepted' |
|
305
|
-
'Complete' |
|
306
|
-
'Errored'
|
307
|
-
|
308
|
-
export interface Route {
|
309
|
-
alias?: string
|
310
|
-
log: any
|
311
|
-
options: RouteMatcherOptions
|
312
|
-
handler: RouteHandler
|
313
|
-
hitCount: number
|
314
|
-
requests: { [key: string]: Interception }
|
315
|
-
command: any
|
316
|
-
}
|
317
|
-
|
318
|
-
export interface RouteMap { [key: string]: Route }
|
319
|
-
|
320
|
-
/**
|
321
|
-
* A `RouteMatcher` describes a filter for HTTP requests.
|
322
|
-
*/
|
323
|
-
export type RouteMatcher = StringMatcher | RouteMatcherOptions
|
324
|
-
|
325
|
-
export type RouteMatcherOptions = RouteMatcherOptionsGeneric<StringMatcher>
|
326
|
-
|
327
|
-
export interface RouteMatcherOptionsGeneric<S> {
|
328
|
-
/**
|
329
|
-
* Match against the username and password used in HTTP Basic authentication.
|
330
|
-
*/
|
331
|
-
auth?: { username: S, password: S }
|
332
|
-
/**
|
333
|
-
* Match against HTTP headers on the request.
|
334
|
-
*/
|
335
|
-
headers?: DictMatcher<S>
|
336
|
-
/**
|
337
|
-
* Match against the requested HTTP hostname.
|
338
|
-
*/
|
339
|
-
hostname?: S
|
340
|
-
/**
|
341
|
-
* If 'true', only HTTPS requests will be matched.
|
342
|
-
* If 'false', only HTTP requests will be matched.
|
343
|
-
*/
|
344
|
-
https?: boolean
|
345
|
-
/**
|
346
|
-
* Match against the request's HTTP method.
|
347
|
-
* @default '*'
|
348
|
-
*/
|
349
|
-
method?: S
|
350
|
-
/**
|
351
|
-
* If `true`, this handler will be called before any non-`middleware` handlers, in the order it was defined.
|
352
|
-
* Can only be used with a dynamic request handler.
|
353
|
-
* @default false
|
354
|
-
*/
|
355
|
-
middleware?: boolean
|
356
|
-
/**
|
357
|
-
* Match on request path after the hostname, including query params.
|
358
|
-
*/
|
359
|
-
path?: S
|
360
|
-
/**
|
361
|
-
* Matches like `path`, but without query params.
|
362
|
-
*/
|
363
|
-
pathname?: S
|
364
|
-
/**
|
365
|
-
* Match based on requested port, or pass an array of ports
|
366
|
-
* to match against any in that array.
|
367
|
-
*/
|
368
|
-
port?: NumberMatcher
|
369
|
-
/**
|
370
|
-
* Match on parsed querystring parameters.
|
371
|
-
*/
|
372
|
-
query?: DictMatcher<S>
|
373
|
-
/**
|
374
|
-
* If set, this `RouteMatcher` will only match the first `times` requests.
|
375
|
-
*/
|
376
|
-
times?: number
|
377
|
-
/**
|
378
|
-
* Match against the full request URL.
|
379
|
-
* If a string is passed, it will be used as a substring match,
|
380
|
-
* not an equality match.
|
381
|
-
*/
|
382
|
-
url?: S
|
383
|
-
}
|
384
|
-
|
385
|
-
export type RouteHandlerController = HttpRequestInterceptor
|
386
|
-
|
387
|
-
export type RouteHandler = string | StaticResponse | RouteHandlerController | object
|
388
|
-
|
389
|
-
/**
|
390
|
-
* Describes a response that will be sent back to the browser to fulfill the request.
|
391
|
-
*/
|
392
|
-
export type StaticResponse = GenericStaticResponse<string, string | object | boolean | ArrayBuffer | null> & {
|
393
|
-
/**
|
394
|
-
* Milliseconds to delay before the response is sent.
|
395
|
-
* @deprecated Use `delay` instead of `delayMs`.
|
396
|
-
*/
|
397
|
-
delayMs?: number
|
398
|
-
}
|
399
|
-
|
400
|
-
export interface GenericStaticResponse<Fixture, Body> {
|
401
|
-
/**
|
402
|
-
* Serve a fixture as the response body.
|
403
|
-
*/
|
404
|
-
fixture?: Fixture
|
405
|
-
/**
|
406
|
-
* Serve a static string/JSON object as the response body.
|
407
|
-
*/
|
408
|
-
body?: Body
|
409
|
-
/**
|
410
|
-
* HTTP headers to accompany the response.
|
411
|
-
* @default {}
|
412
|
-
*/
|
413
|
-
headers?: { [key: string]: string }
|
414
|
-
/**
|
415
|
-
* The HTTP status code to send.
|
416
|
-
* @default 200
|
417
|
-
*/
|
418
|
-
statusCode?: number
|
419
|
-
/**
|
420
|
-
* If 'forceNetworkError' is truthy, Cypress will destroy the browser connection
|
421
|
-
* and send no response. Useful for simulating a server that is not reachable.
|
422
|
-
* Must not be set in combination with other options.
|
423
|
-
*/
|
424
|
-
forceNetworkError?: boolean
|
425
|
-
/**
|
426
|
-
* Kilobytes per second to send 'body'.
|
427
|
-
*/
|
428
|
-
throttleKbps?: number
|
429
|
-
/**
|
430
|
-
* Milliseconds to delay before the response is sent.
|
431
|
-
*/
|
432
|
-
delay?: number
|
433
|
-
}
|
434
|
-
|
435
|
-
/**
|
436
|
-
* Either a `GlobPattern` string or a `RegExp`.
|
437
|
-
*/
|
438
|
-
export type StringMatcher = GlobPattern | RegExp
|
439
|
-
|
440
|
-
interface WaitOptions {
|
441
|
-
/**
|
442
|
-
* Displays the command in the Command Log
|
443
|
-
*
|
444
|
-
* @default true
|
445
|
-
*/
|
446
|
-
log: boolean
|
447
|
-
/**
|
448
|
-
* Time to wait for the request (ms)
|
449
|
-
*
|
450
|
-
* @default {@link Timeoutable#timeout}
|
451
|
-
* @see https://on.cypress.io/configuration#Timeouts
|
452
|
-
*/
|
453
|
-
requestTimeout: number
|
454
|
-
/**
|
455
|
-
* Time to wait for the response (ms)
|
456
|
-
*
|
457
|
-
* @default {@link Timeoutable#timeout}
|
458
|
-
* @see https://on.cypress.io/configuration#Timeouts
|
459
|
-
*/
|
460
|
-
responseTimeout: number
|
461
|
-
/**
|
462
|
-
* Time to wait (ms)
|
463
|
-
*
|
464
|
-
* @default defaultCommandTimeout
|
465
|
-
* @see https://on.cypress.io/configuration#Timeouts
|
466
|
-
*/
|
467
|
-
timeout: number
|
468
|
-
}
|
469
|
-
|
470
|
-
declare global {
|
471
|
-
namespace Cypress {
|
472
|
-
// TODO: Why is Subject unused?
|
473
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
474
|
-
interface Chainable<Subject = any> {
|
475
|
-
/**
|
476
|
-
* Use `cy.intercept()` to stub and intercept HTTP requests and responses.
|
477
|
-
*
|
478
|
-
* @see https://on.cypress.io/intercept
|
479
|
-
* @example
|
480
|
-
* cy.intercept('https://localhost:7777/users', [{id: 1, name: 'Pat'}])
|
481
|
-
* @example
|
482
|
-
* cy.intercept('https://localhost:7777/protected-endpoint', (req) => {
|
483
|
-
* req.headers['authorization'] = 'basic fooabc123'
|
484
|
-
* })
|
485
|
-
* @example
|
486
|
-
* cy.intercept('https://localhost:7777/some-response', (req) => {
|
487
|
-
* req.continue(res => {
|
488
|
-
* res.body = 'some new body'
|
489
|
-
* })
|
490
|
-
* })
|
491
|
-
*/
|
492
|
-
intercept(url: RouteMatcher, response?: RouteHandler): Chainable<null>
|
493
|
-
/**
|
494
|
-
* Use `cy.intercept()` to stub and intercept HTTP requests and responses.
|
495
|
-
*
|
496
|
-
* @see https://on.cypress.io/intercept
|
497
|
-
* @example
|
498
|
-
* cy.intercept('GET', 'http://foo.com/fruits', ['apple', 'banana', 'cherry'])
|
499
|
-
*/
|
500
|
-
intercept(method: Method, url: RouteMatcher, response?: RouteHandler): Chainable<null>
|
501
|
-
/**
|
502
|
-
* Use `cy.intercept()` to stub and intercept HTTP requests and responses.
|
503
|
-
*
|
504
|
-
* @see https://on.cypress.io/intercept
|
505
|
-
*
|
506
|
-
* @example
|
507
|
-
* cy.intercept('/fruits', { middleware: true }, (req) => { ... })
|
508
|
-
*
|
509
|
-
* @param mergeRouteMatcher Additional route matcher options to merge with `url`. Typically used for middleware.
|
510
|
-
*/
|
511
|
-
intercept(url: StringMatcher, mergeRouteMatcher: Omit<RouteMatcherOptions, 'url'>, response: RouteHandler): Chainable<null>
|
512
|
-
/**
|
513
|
-
* Wait for a specific request to complete.
|
514
|
-
*
|
515
|
-
* @see https://on.cypress.io/wait
|
516
|
-
* @param {string} alias - Name of the alias to wait for.
|
517
|
-
*
|
518
|
-
```
|
519
|
-
// Wait for the route aliased as 'getAccount' to respond
|
520
|
-
// without changing or stubbing its response
|
521
|
-
cy.intercept('https://api.example.com/accounts/*').as('getAccount')
|
522
|
-
cy.visit('/accounts/123')
|
523
|
-
cy.wait('@getAccount').then((interception) => {
|
524
|
-
// we can now access the low level request
|
525
|
-
// that contains the request body,
|
526
|
-
// response body, status, etc
|
527
|
-
})
|
528
|
-
```
|
529
|
-
*/
|
530
|
-
wait(alias: string, options?: Partial<WaitOptions>): Chainable<Interception>
|
531
|
-
/**
|
532
|
-
* Wait for list of requests to complete.
|
533
|
-
*
|
534
|
-
* @see https://on.cypress.io/wait
|
535
|
-
* @param {string[]} aliases - An array of aliased routes as defined using the `.as()` command.
|
536
|
-
*
|
537
|
-
```
|
538
|
-
// wait for 3 XHR requests to complete
|
539
|
-
cy.intercept('users/*').as('getUsers')
|
540
|
-
cy.intercept('activities/*').as('getActivities')
|
541
|
-
cy.intercept('comments/*').as('getComments')
|
542
|
-
cy.visit('/dashboard')
|
543
|
-
|
544
|
-
cy.wait(['@getUsers', '@getActivities', '@getComments'])
|
545
|
-
.then((interceptions) => {
|
546
|
-
// intercepts will now be an array of matching HTTP requests
|
547
|
-
})
|
548
|
-
```
|
549
|
-
*/
|
550
|
-
wait(alias: string[], options?: Partial<WaitOptions>): Chainable<Interception[]>
|
551
|
-
}
|
552
|
-
}
|
553
|
-
}
|
1
|
+
// Copied from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/methods/index.d.ts
|
2
|
+
type Method =
|
3
|
+
| 'ACL'
|
4
|
+
| 'BIND'
|
5
|
+
| 'CHECKOUT'
|
6
|
+
| 'CONNECT'
|
7
|
+
| 'COPY'
|
8
|
+
| 'DELETE'
|
9
|
+
| 'GET'
|
10
|
+
| 'HEAD'
|
11
|
+
| 'LINK'
|
12
|
+
| 'LOCK'
|
13
|
+
| 'M-SEARCH'
|
14
|
+
| 'MERGE'
|
15
|
+
| 'MKACTIVITY'
|
16
|
+
| 'MKCALENDAR'
|
17
|
+
| 'MKCOL'
|
18
|
+
| 'MOVE'
|
19
|
+
| 'NOTIFY'
|
20
|
+
| 'OPTIONS'
|
21
|
+
| 'PATCH'
|
22
|
+
| 'POST'
|
23
|
+
| 'PROPFIND'
|
24
|
+
| 'PROPPATCH'
|
25
|
+
| 'PURGE'
|
26
|
+
| 'PUT'
|
27
|
+
| 'REBIND'
|
28
|
+
| 'REPORT'
|
29
|
+
| 'SEARCH'
|
30
|
+
| 'SOURCE'
|
31
|
+
| 'SUBSCRIBE'
|
32
|
+
| 'TRACE'
|
33
|
+
| 'UNBIND'
|
34
|
+
| 'UNLINK'
|
35
|
+
| 'UNLOCK'
|
36
|
+
| 'UNSUBSCRIBE'
|
37
|
+
| 'acl'
|
38
|
+
| 'bind'
|
39
|
+
| 'checkout'
|
40
|
+
| 'connect'
|
41
|
+
| 'copy'
|
42
|
+
| 'delete'
|
43
|
+
| 'get'
|
44
|
+
| 'head'
|
45
|
+
| 'link'
|
46
|
+
| 'lock'
|
47
|
+
| 'm-search'
|
48
|
+
| 'merge'
|
49
|
+
| 'mkactivity'
|
50
|
+
| 'mkcalendar'
|
51
|
+
| 'mkcol'
|
52
|
+
| 'move'
|
53
|
+
| 'notify'
|
54
|
+
| 'options'
|
55
|
+
| 'patch'
|
56
|
+
| 'post'
|
57
|
+
| 'propfind'
|
58
|
+
| 'proppatch'
|
59
|
+
| 'purge'
|
60
|
+
| 'put'
|
61
|
+
| 'rebind'
|
62
|
+
| 'report'
|
63
|
+
| 'search'
|
64
|
+
| 'source'
|
65
|
+
| 'subscribe'
|
66
|
+
| 'trace'
|
67
|
+
| 'unbind'
|
68
|
+
| 'unlink'
|
69
|
+
| 'unlock'
|
70
|
+
| 'unsubscribe'
|
71
|
+
export namespace CyHttpMessages {
|
72
|
+
export interface BaseMessage {
|
73
|
+
/**
|
74
|
+
* The body of the HTTP message.
|
75
|
+
* If a JSON Content-Type was used and the body was valid JSON, this will be an object.
|
76
|
+
* If the body was binary content, this will be a buffer.
|
77
|
+
*/
|
78
|
+
body: any
|
79
|
+
/**
|
80
|
+
* The headers of the HTTP message.
|
81
|
+
*/
|
82
|
+
headers: { [key: string]: string | string[] }
|
83
|
+
}
|
84
|
+
|
85
|
+
export type IncomingResponse = BaseMessage & {
|
86
|
+
/**
|
87
|
+
* The HTTP status code of the response.
|
88
|
+
*/
|
89
|
+
statusCode: number
|
90
|
+
/**
|
91
|
+
* The HTTP status message.
|
92
|
+
*/
|
93
|
+
statusMessage: string
|
94
|
+
/**
|
95
|
+
* Kilobytes per second to send 'body'.
|
96
|
+
*/
|
97
|
+
throttleKbps?: number
|
98
|
+
/**
|
99
|
+
* Milliseconds to delay before the response is sent.
|
100
|
+
*/
|
101
|
+
delay?: number
|
102
|
+
}
|
103
|
+
|
104
|
+
export type IncomingHttpResponse = IncomingResponse & {
|
105
|
+
/**
|
106
|
+
* Continue the HTTP response, merging the supplied values with the real response.
|
107
|
+
*/
|
108
|
+
send(status: number, body?: string | number | object, headers?: { [key: string]: string }): void
|
109
|
+
send(body: string | object, headers?: { [key: string]: string }): void
|
110
|
+
send(staticResponse: StaticResponse): void
|
111
|
+
/**
|
112
|
+
* Continue the HTTP response to the browser, including any modifications made to `res`.
|
113
|
+
*/
|
114
|
+
send(): void
|
115
|
+
/**
|
116
|
+
* Wait for `delay` milliseconds before sending the response to the client.
|
117
|
+
*/
|
118
|
+
setDelay: (delay: number) => IncomingHttpResponse
|
119
|
+
/**
|
120
|
+
* Serve the response at `throttleKbps` kilobytes per second.
|
121
|
+
*/
|
122
|
+
setThrottle: (throttleKbps: number) => IncomingHttpResponse
|
123
|
+
}
|
124
|
+
|
125
|
+
export type IncomingRequest = BaseMessage & {
|
126
|
+
/**
|
127
|
+
* Request HTTP method (GET, POST, ...).
|
128
|
+
*/
|
129
|
+
method: string
|
130
|
+
/**
|
131
|
+
* Request URL.
|
132
|
+
*/
|
133
|
+
url: string
|
134
|
+
/**
|
135
|
+
* URL query string as object.
|
136
|
+
*/
|
137
|
+
query: Record<string, string|number>
|
138
|
+
/**
|
139
|
+
* The HTTP version used in the request. Read only.
|
140
|
+
*/
|
141
|
+
httpVersion: string
|
142
|
+
/**
|
143
|
+
* If provided, the number of milliseconds before an upstream response to this request
|
144
|
+
* will time out and cause an error. By default, `responseTimeout` from config is used.
|
145
|
+
*/
|
146
|
+
responseTimeout?: number
|
147
|
+
/**
|
148
|
+
* Set if redirects should be followed when this request is made. By default, requests will
|
149
|
+
* not follow redirects before yielding the response (the 3xx redirect is yielded)
|
150
|
+
*/
|
151
|
+
followRedirect?: boolean
|
152
|
+
/**
|
153
|
+
* If set, `cy.wait` can be used to await the request/response cycle to complete for this
|
154
|
+
* request via `cy.wait('@alias')`.
|
155
|
+
*/
|
156
|
+
alias?: string
|
157
|
+
}
|
158
|
+
|
159
|
+
export interface IncomingHttpRequest extends IncomingRequest, RequestEvents {
|
160
|
+
/**
|
161
|
+
* Destroy the request and respond with a network error.
|
162
|
+
*/
|
163
|
+
destroy(): void
|
164
|
+
/**
|
165
|
+
* Send the request outgoing, skipping any other request handlers.
|
166
|
+
* If a function is passed, the request will be sent outgoing, and the function will be called
|
167
|
+
* with the response from the upstream server.
|
168
|
+
*/
|
169
|
+
continue(interceptor?: HttpResponseInterceptor): void
|
170
|
+
/**
|
171
|
+
* Control the response to this request.
|
172
|
+
* If a function is passed, the request will be sent outgoing, and the function will be called
|
173
|
+
* with the response from the upstream server.
|
174
|
+
* If a `StaticResponse` is passed, it will be used as the response, and no request will be made
|
175
|
+
* to the upstream server.
|
176
|
+
*/
|
177
|
+
reply(interceptor?: StaticResponse | HttpResponseInterceptor): void
|
178
|
+
/**
|
179
|
+
* Shortcut to reply to the request with a body and optional headers.
|
180
|
+
*/
|
181
|
+
reply(body: string | object, headers?: { [key: string]: string }): void
|
182
|
+
/**
|
183
|
+
* Shortcut to reply to the request with an HTTP status code and optional body and headers.
|
184
|
+
*/
|
185
|
+
reply(status: number, body?: string | object, headers?: { [key: string]: string }): void
|
186
|
+
/**
|
187
|
+
* Respond to this request with a redirect to a new `location`.
|
188
|
+
* @param statusCode HTTP status code to redirect with. Default: 302
|
189
|
+
*/
|
190
|
+
redirect(location: string, statusCode?: number): void
|
191
|
+
}
|
192
|
+
|
193
|
+
export interface ResponseComplete {
|
194
|
+
finalResBody?: BaseMessage['body']
|
195
|
+
}
|
196
|
+
|
197
|
+
export interface NetworkError {
|
198
|
+
error: any
|
199
|
+
}
|
200
|
+
}
|
201
|
+
|
202
|
+
export interface DictMatcher<T> {
|
203
|
+
[key: string]: T
|
204
|
+
}
|
205
|
+
|
206
|
+
/**
|
207
|
+
* Matches a string using glob (`*`) matching.
|
208
|
+
*/
|
209
|
+
export type GlobPattern = string
|
210
|
+
|
211
|
+
/**
|
212
|
+
* Interceptor for an HTTP request. If a Promise is returned, it will be awaited before passing the
|
213
|
+
* request to the next handler (if there is one), otherwise the request will be passed to the next
|
214
|
+
* handler synchronously.
|
215
|
+
*/
|
216
|
+
export type HttpRequestInterceptor = (req: CyHttpMessages.IncomingHttpRequest) => void | Promise<void>
|
217
|
+
|
218
|
+
/**
|
219
|
+
* Interceptor for an HTTP response. If a Promise is returned, it will be awaited before passing the
|
220
|
+
* request to the next handler (if there is one), otherwise the request will be passed to the next
|
221
|
+
* handler synchronously.
|
222
|
+
*/
|
223
|
+
export type HttpResponseInterceptor = (res: CyHttpMessages.IncomingHttpResponse) => void | Promise<void>
|
224
|
+
|
225
|
+
/**
|
226
|
+
* Matches a single number or any of an array of acceptable numbers.
|
227
|
+
*/
|
228
|
+
export type NumberMatcher = number | number[]
|
229
|
+
|
230
|
+
/**
|
231
|
+
* Metadata for a subscription for an interception event.
|
232
|
+
*/
|
233
|
+
export interface Subscription {
|
234
|
+
/**
|
235
|
+
* If not defined, this is a default subscription.
|
236
|
+
*/
|
237
|
+
id?: string
|
238
|
+
routeId: string
|
239
|
+
eventName: string
|
240
|
+
await: boolean
|
241
|
+
skip?: boolean
|
242
|
+
}
|
243
|
+
|
244
|
+
interface RequestEvents {
|
245
|
+
/**
|
246
|
+
* Emitted before `response` and before any `req.continue` handlers.
|
247
|
+
* Modifications to `res` will be applied to the incoming response.
|
248
|
+
* If a promise is returned from `cb`, it will be awaited before processing other event handlers.
|
249
|
+
*/
|
250
|
+
on(eventName: 'before:response', cb: HttpResponseInterceptor): this
|
251
|
+
/**
|
252
|
+
* Emitted after `before:response` and after any `req.continue` handlers - before the response is sent to the browser.
|
253
|
+
* Modifications to `res` will be applied to the incoming response.
|
254
|
+
* If a promise is returned from `cb`, it will be awaited before processing other event handlers.
|
255
|
+
*/
|
256
|
+
on(eventName: 'response', cb: HttpResponseInterceptor): this
|
257
|
+
/**
|
258
|
+
* Emitted once the response to a request has finished sending to the browser.
|
259
|
+
* Modifications to `res` have no impact.
|
260
|
+
* If a promise is returned from `cb`, it will be awaited before processing other event handlers.
|
261
|
+
*/
|
262
|
+
on(eventName: 'after:response', cb: (res: CyHttpMessages.IncomingResponse) => void | Promise<void>): this
|
263
|
+
}
|
264
|
+
|
265
|
+
/**
|
266
|
+
* Request/response cycle.
|
267
|
+
*/
|
268
|
+
export interface Interception {
|
269
|
+
id: string
|
270
|
+
/* @internal */
|
271
|
+
browserRequestId?: string
|
272
|
+
routeId: string
|
273
|
+
/* @internal */
|
274
|
+
setLogFlag: (flag: 'spied' | 'stubbed' | 'reqModified' | 'resModified') => void
|
275
|
+
request: CyHttpMessages.IncomingRequest
|
276
|
+
/**
|
277
|
+
* Was `cy.wait()` used to wait on this request?
|
278
|
+
* @internal
|
279
|
+
*/
|
280
|
+
requestWaited: boolean
|
281
|
+
response?: CyHttpMessages.IncomingResponse
|
282
|
+
/**
|
283
|
+
* The error that occurred during this request.
|
284
|
+
*/
|
285
|
+
error?: Error
|
286
|
+
/**
|
287
|
+
* Was `cy.wait()` used to wait on the response to this request?
|
288
|
+
* @internal
|
289
|
+
*/
|
290
|
+
responseWaited: boolean
|
291
|
+
/* @internal */
|
292
|
+
state: InterceptionState
|
293
|
+
/* @internal */
|
294
|
+
subscriptions: Array<{
|
295
|
+
subscription: Subscription
|
296
|
+
handler: (data: any) => Promise<void> | void
|
297
|
+
}>
|
298
|
+
}
|
299
|
+
|
300
|
+
export type InterceptionState =
|
301
|
+
'Received' |
|
302
|
+
'Intercepted' |
|
303
|
+
'ResponseReceived' |
|
304
|
+
'ResponseIntercepted' |
|
305
|
+
'Complete' |
|
306
|
+
'Errored'
|
307
|
+
|
308
|
+
export interface Route {
|
309
|
+
alias?: string
|
310
|
+
log: any
|
311
|
+
options: RouteMatcherOptions
|
312
|
+
handler: RouteHandler
|
313
|
+
hitCount: number
|
314
|
+
requests: { [key: string]: Interception }
|
315
|
+
command: any
|
316
|
+
}
|
317
|
+
|
318
|
+
export interface RouteMap { [key: string]: Route }
|
319
|
+
|
320
|
+
/**
|
321
|
+
* A `RouteMatcher` describes a filter for HTTP requests.
|
322
|
+
*/
|
323
|
+
export type RouteMatcher = StringMatcher | RouteMatcherOptions
|
324
|
+
|
325
|
+
export type RouteMatcherOptions = RouteMatcherOptionsGeneric<StringMatcher>
|
326
|
+
|
327
|
+
export interface RouteMatcherOptionsGeneric<S> {
|
328
|
+
/**
|
329
|
+
* Match against the username and password used in HTTP Basic authentication.
|
330
|
+
*/
|
331
|
+
auth?: { username: S, password: S }
|
332
|
+
/**
|
333
|
+
* Match against HTTP headers on the request.
|
334
|
+
*/
|
335
|
+
headers?: DictMatcher<S>
|
336
|
+
/**
|
337
|
+
* Match against the requested HTTP hostname.
|
338
|
+
*/
|
339
|
+
hostname?: S
|
340
|
+
/**
|
341
|
+
* If 'true', only HTTPS requests will be matched.
|
342
|
+
* If 'false', only HTTP requests will be matched.
|
343
|
+
*/
|
344
|
+
https?: boolean
|
345
|
+
/**
|
346
|
+
* Match against the request's HTTP method.
|
347
|
+
* @default '*'
|
348
|
+
*/
|
349
|
+
method?: S
|
350
|
+
/**
|
351
|
+
* If `true`, this handler will be called before any non-`middleware` handlers, in the order it was defined.
|
352
|
+
* Can only be used with a dynamic request handler.
|
353
|
+
* @default false
|
354
|
+
*/
|
355
|
+
middleware?: boolean
|
356
|
+
/**
|
357
|
+
* Match on request path after the hostname, including query params.
|
358
|
+
*/
|
359
|
+
path?: S
|
360
|
+
/**
|
361
|
+
* Matches like `path`, but without query params.
|
362
|
+
*/
|
363
|
+
pathname?: S
|
364
|
+
/**
|
365
|
+
* Match based on requested port, or pass an array of ports
|
366
|
+
* to match against any in that array.
|
367
|
+
*/
|
368
|
+
port?: NumberMatcher
|
369
|
+
/**
|
370
|
+
* Match on parsed querystring parameters.
|
371
|
+
*/
|
372
|
+
query?: DictMatcher<S>
|
373
|
+
/**
|
374
|
+
* If set, this `RouteMatcher` will only match the first `times` requests.
|
375
|
+
*/
|
376
|
+
times?: number
|
377
|
+
/**
|
378
|
+
* Match against the full request URL.
|
379
|
+
* If a string is passed, it will be used as a substring match,
|
380
|
+
* not an equality match.
|
381
|
+
*/
|
382
|
+
url?: S
|
383
|
+
}
|
384
|
+
|
385
|
+
export type RouteHandlerController = HttpRequestInterceptor
|
386
|
+
|
387
|
+
export type RouteHandler = string | StaticResponse | RouteHandlerController | object
|
388
|
+
|
389
|
+
/**
|
390
|
+
* Describes a response that will be sent back to the browser to fulfill the request.
|
391
|
+
*/
|
392
|
+
export type StaticResponse = GenericStaticResponse<string, string | object | boolean | ArrayBuffer | null> & {
|
393
|
+
/**
|
394
|
+
* Milliseconds to delay before the response is sent.
|
395
|
+
* @deprecated Use `delay` instead of `delayMs`.
|
396
|
+
*/
|
397
|
+
delayMs?: number
|
398
|
+
}
|
399
|
+
|
400
|
+
export interface GenericStaticResponse<Fixture, Body> {
|
401
|
+
/**
|
402
|
+
* Serve a fixture as the response body.
|
403
|
+
*/
|
404
|
+
fixture?: Fixture
|
405
|
+
/**
|
406
|
+
* Serve a static string/JSON object as the response body.
|
407
|
+
*/
|
408
|
+
body?: Body
|
409
|
+
/**
|
410
|
+
* HTTP headers to accompany the response.
|
411
|
+
* @default {}
|
412
|
+
*/
|
413
|
+
headers?: { [key: string]: string }
|
414
|
+
/**
|
415
|
+
* The HTTP status code to send.
|
416
|
+
* @default 200
|
417
|
+
*/
|
418
|
+
statusCode?: number
|
419
|
+
/**
|
420
|
+
* If 'forceNetworkError' is truthy, Cypress will destroy the browser connection
|
421
|
+
* and send no response. Useful for simulating a server that is not reachable.
|
422
|
+
* Must not be set in combination with other options.
|
423
|
+
*/
|
424
|
+
forceNetworkError?: boolean
|
425
|
+
/**
|
426
|
+
* Kilobytes per second to send 'body'.
|
427
|
+
*/
|
428
|
+
throttleKbps?: number
|
429
|
+
/**
|
430
|
+
* Milliseconds to delay before the response is sent.
|
431
|
+
*/
|
432
|
+
delay?: number
|
433
|
+
}
|
434
|
+
|
435
|
+
/**
|
436
|
+
* Either a `GlobPattern` string or a `RegExp`.
|
437
|
+
*/
|
438
|
+
export type StringMatcher = GlobPattern | RegExp
|
439
|
+
|
440
|
+
interface WaitOptions {
|
441
|
+
/**
|
442
|
+
* Displays the command in the Command Log
|
443
|
+
*
|
444
|
+
* @default true
|
445
|
+
*/
|
446
|
+
log: boolean
|
447
|
+
/**
|
448
|
+
* Time to wait for the request (ms)
|
449
|
+
*
|
450
|
+
* @default {@link Timeoutable#timeout}
|
451
|
+
* @see https://on.cypress.io/configuration#Timeouts
|
452
|
+
*/
|
453
|
+
requestTimeout: number
|
454
|
+
/**
|
455
|
+
* Time to wait for the response (ms)
|
456
|
+
*
|
457
|
+
* @default {@link Timeoutable#timeout}
|
458
|
+
* @see https://on.cypress.io/configuration#Timeouts
|
459
|
+
*/
|
460
|
+
responseTimeout: number
|
461
|
+
/**
|
462
|
+
* Time to wait (ms)
|
463
|
+
*
|
464
|
+
* @default defaultCommandTimeout
|
465
|
+
* @see https://on.cypress.io/configuration#Timeouts
|
466
|
+
*/
|
467
|
+
timeout: number
|
468
|
+
}
|
469
|
+
|
470
|
+
declare global {
|
471
|
+
namespace Cypress {
|
472
|
+
// TODO: Why is Subject unused?
|
473
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
474
|
+
interface Chainable<Subject = any> {
|
475
|
+
/**
|
476
|
+
* Use `cy.intercept()` to stub and intercept HTTP requests and responses.
|
477
|
+
*
|
478
|
+
* @see https://on.cypress.io/intercept
|
479
|
+
* @example
|
480
|
+
* cy.intercept('https://localhost:7777/users', [{id: 1, name: 'Pat'}])
|
481
|
+
* @example
|
482
|
+
* cy.intercept('https://localhost:7777/protected-endpoint', (req) => {
|
483
|
+
* req.headers['authorization'] = 'basic fooabc123'
|
484
|
+
* })
|
485
|
+
* @example
|
486
|
+
* cy.intercept('https://localhost:7777/some-response', (req) => {
|
487
|
+
* req.continue(res => {
|
488
|
+
* res.body = 'some new body'
|
489
|
+
* })
|
490
|
+
* })
|
491
|
+
*/
|
492
|
+
intercept(url: RouteMatcher, response?: RouteHandler): Chainable<null>
|
493
|
+
/**
|
494
|
+
* Use `cy.intercept()` to stub and intercept HTTP requests and responses.
|
495
|
+
*
|
496
|
+
* @see https://on.cypress.io/intercept
|
497
|
+
* @example
|
498
|
+
* cy.intercept('GET', 'http://foo.com/fruits', ['apple', 'banana', 'cherry'])
|
499
|
+
*/
|
500
|
+
intercept(method: Method, url: RouteMatcher, response?: RouteHandler): Chainable<null>
|
501
|
+
/**
|
502
|
+
* Use `cy.intercept()` to stub and intercept HTTP requests and responses.
|
503
|
+
*
|
504
|
+
* @see https://on.cypress.io/intercept
|
505
|
+
*
|
506
|
+
* @example
|
507
|
+
* cy.intercept('/fruits', { middleware: true }, (req) => { ... })
|
508
|
+
*
|
509
|
+
* @param mergeRouteMatcher Additional route matcher options to merge with `url`. Typically used for middleware.
|
510
|
+
*/
|
511
|
+
intercept(url: StringMatcher, mergeRouteMatcher: Omit<RouteMatcherOptions, 'url'>, response: RouteHandler): Chainable<null>
|
512
|
+
/**
|
513
|
+
* Wait for a specific request to complete.
|
514
|
+
*
|
515
|
+
* @see https://on.cypress.io/wait
|
516
|
+
* @param {string} alias - Name of the alias to wait for.
|
517
|
+
*
|
518
|
+
```
|
519
|
+
// Wait for the route aliased as 'getAccount' to respond
|
520
|
+
// without changing or stubbing its response
|
521
|
+
cy.intercept('https://api.example.com/accounts/*').as('getAccount')
|
522
|
+
cy.visit('/accounts/123')
|
523
|
+
cy.wait('@getAccount').then((interception) => {
|
524
|
+
// we can now access the low level request
|
525
|
+
// that contains the request body,
|
526
|
+
// response body, status, etc
|
527
|
+
})
|
528
|
+
```
|
529
|
+
*/
|
530
|
+
wait(alias: string, options?: Partial<WaitOptions>): Chainable<Interception>
|
531
|
+
/**
|
532
|
+
* Wait for list of requests to complete.
|
533
|
+
*
|
534
|
+
* @see https://on.cypress.io/wait
|
535
|
+
* @param {string[]} aliases - An array of aliased routes as defined using the `.as()` command.
|
536
|
+
*
|
537
|
+
```
|
538
|
+
// wait for 3 XHR requests to complete
|
539
|
+
cy.intercept('users/*').as('getUsers')
|
540
|
+
cy.intercept('activities/*').as('getActivities')
|
541
|
+
cy.intercept('comments/*').as('getComments')
|
542
|
+
cy.visit('/dashboard')
|
543
|
+
|
544
|
+
cy.wait(['@getUsers', '@getActivities', '@getComments'])
|
545
|
+
.then((interceptions) => {
|
546
|
+
// intercepts will now be an array of matching HTTP requests
|
547
|
+
})
|
548
|
+
```
|
549
|
+
*/
|
550
|
+
wait(alias: string[], options?: Partial<WaitOptions>): Chainable<Interception[]>
|
551
|
+
}
|
552
|
+
}
|
553
|
+
}
|