cypress 13.9.0 → 13.11.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cypress",
3
- "version": "13.9.0",
3
+ "version": "13.11.0",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "postinstall": "node index.js --exec install",
@@ -134,8 +134,8 @@
134
134
  },
135
135
  "buildInfo": {
136
136
  "commitBranch": "develop",
137
- "commitSha": "b31740c00d2c8842043204dbf8189a0e2b7e1bfe",
138
- "commitDate": "2024-05-07T17:37:08.000Z",
137
+ "commitSha": "09c6876637d13686178ef934f988b757d04cf813",
138
+ "commitDate": "2024-06-04T18:16:38.000Z",
139
139
  "stable": true
140
140
  },
141
141
  "description": "Cypress is a next generation front end testing tool built for the modern web",
@@ -1,91 +1,91 @@
1
1
  // Copied from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/methods/index.d.ts
2
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'
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
71
 
72
72
  export type ResourceType = 'document' | 'fetch' | 'xhr' | 'websocket' | 'stylesheet' | 'script' | 'image' | 'font' | 'cspviolationreport' | 'ping' | 'manifest' | 'other'
73
73
 
74
74
  export namespace CyHttpMessages {
75
- export interface BaseMessage {
75
+ export interface BaseMessage<T = any> {
76
76
  /**
77
77
  * The body of the HTTP message.
78
78
  * If a JSON Content-Type was used and the body was valid JSON, this will be an object.
79
79
  * If the body was binary content, this will be a buffer.
80
80
  */
81
- body: any
81
+ body: T
82
82
  /**
83
83
  * The headers of the HTTP message.
84
84
  */
85
85
  headers: { [key: string]: string | string[] }
86
86
  }
87
87
 
88
- export type IncomingResponse = BaseMessage & {
88
+ export type IncomingResponse<T = any> = BaseMessage<T> & {
89
89
  /**
90
90
  * The HTTP status code of the response.
91
91
  */
@@ -104,7 +104,7 @@ export namespace CyHttpMessages {
104
104
  delay?: number
105
105
  }
106
106
 
107
- export type IncomingHttpResponse = IncomingResponse & {
107
+ export type IncomingHttpResponse<T = any> = IncomingResponse<T> & {
108
108
  /**
109
109
  * Continue the HTTP response, merging the supplied values with the real response.
110
110
  */
@@ -118,14 +118,14 @@ export namespace CyHttpMessages {
118
118
  /**
119
119
  * Wait for `delay` milliseconds before sending the response to the client.
120
120
  */
121
- setDelay: (delay: number) => IncomingHttpResponse
121
+ setDelay: (delay: number) => IncomingHttpResponse<T>
122
122
  /**
123
123
  * Serve the response at `throttleKbps` kilobytes per second.
124
124
  */
125
- setThrottle: (throttleKbps: number) => IncomingHttpResponse
125
+ setThrottle: (throttleKbps: number) => IncomingHttpResponse<T>
126
126
  }
127
127
 
128
- export type IncomingRequest = BaseMessage & {
128
+ export type IncomingRequest<T = any> = BaseMessage<T> & {
129
129
  /**
130
130
  * Request HTTP method (GET, POST, ...).
131
131
  */
@@ -137,7 +137,7 @@ export namespace CyHttpMessages {
137
137
  /**
138
138
  * URL query string as object.
139
139
  */
140
- query: Record<string, string|number>
140
+ query: Record<string, string | number>
141
141
  /**
142
142
  * The HTTP version used in the request. Read only.
143
143
  */
@@ -163,7 +163,7 @@ export namespace CyHttpMessages {
163
163
  alias?: string
164
164
  }
165
165
 
166
- export interface IncomingHttpRequest extends IncomingRequest, RequestEvents {
166
+ export interface IncomingHttpRequest<TRequest = any, TResponse = any> extends IncomingRequest<TRequest>, RequestEvents<TResponse> {
167
167
  /**
168
168
  * Destroy the request and respond with a network error.
169
169
  */
@@ -173,7 +173,7 @@ export namespace CyHttpMessages {
173
173
  * If a function is passed, the request will be sent outgoing, and the function will be called
174
174
  * with the response from the upstream server.
175
175
  */
176
- continue(interceptor?: HttpResponseInterceptor): void
176
+ continue(interceptor?: HttpResponseInterceptor<TResponse>): void
177
177
  /**
178
178
  * Control the response to this request.
179
179
  * If a function is passed, the request will be sent outgoing, and the function will be called
@@ -181,7 +181,7 @@ export namespace CyHttpMessages {
181
181
  * If a `StaticResponse` is passed, it will be used as the response, and no request will be made
182
182
  * to the upstream server.
183
183
  */
184
- reply(interceptor?: StaticResponse | HttpResponseInterceptor): void
184
+ reply(interceptor?: StaticResponse | HttpResponseInterceptor<TResponse>): void
185
185
  /**
186
186
  * Shortcut to reply to the request with a body and optional headers.
187
187
  */
@@ -197,8 +197,8 @@ export namespace CyHttpMessages {
197
197
  redirect(location: string, statusCode?: number): void
198
198
  }
199
199
 
200
- export interface ResponseComplete {
201
- finalResBody?: BaseMessage['body']
200
+ export interface ResponseComplete<T = any> {
201
+ finalResBody?: BaseMessage<T>['body']
202
202
  }
203
203
 
204
204
  export interface NetworkError {
@@ -220,14 +220,14 @@ export type GlobPattern = string
220
220
  * request to the next handler (if there is one), otherwise the request will be passed to the next
221
221
  * handler synchronously.
222
222
  */
223
- export type HttpRequestInterceptor = (req: CyHttpMessages.IncomingHttpRequest) => void | Promise<void>
223
+ export type HttpRequestInterceptor<TRequest = any, TResponse = any> = (req: CyHttpMessages.IncomingHttpRequest<TRequest, TResponse>) => void | Promise<void>
224
224
 
225
225
  /**
226
226
  * Interceptor for an HTTP response. If a Promise is returned, it will be awaited before passing the
227
227
  * request to the next handler (if there is one), otherwise the request will be passed to the next
228
228
  * handler synchronously.
229
229
  */
230
- export type HttpResponseInterceptor = (res: CyHttpMessages.IncomingHttpResponse) => void | Promise<void>
230
+ export type HttpResponseInterceptor<T = any> = (res: CyHttpMessages.IncomingHttpResponse<T>) => void | Promise<void>
231
231
 
232
232
  /**
233
233
  * Matches a single number or any of an array of acceptable numbers.
@@ -248,44 +248,44 @@ export interface Subscription {
248
248
  skip?: boolean
249
249
  }
250
250
 
251
- interface RequestEvents {
251
+ interface RequestEvents<T> {
252
252
  /**
253
253
  * Emitted before `response` and before any `req.continue` handlers.
254
254
  * Modifications to `res` will be applied to the incoming response.
255
255
  * If a promise is returned from `cb`, it will be awaited before processing other event handlers.
256
256
  */
257
- on(eventName: 'before:response', cb: HttpResponseInterceptor): this
257
+ on(eventName: 'before:response', cb: HttpResponseInterceptor<T>): this
258
258
  /**
259
259
  * Emitted after `before:response` and after any `req.continue` handlers - before the response is sent to the browser.
260
260
  * Modifications to `res` will be applied to the incoming response.
261
261
  * If a promise is returned from `cb`, it will be awaited before processing other event handlers.
262
262
  */
263
- on(eventName: 'response', cb: HttpResponseInterceptor): this
263
+ on(eventName: 'response', cb: HttpResponseInterceptor<T>): this
264
264
  /**
265
265
  * Emitted once the response to a request has finished sending to the browser.
266
266
  * Modifications to `res` have no impact.
267
267
  * If a promise is returned from `cb`, it will be awaited before processing other event handlers.
268
268
  */
269
- on(eventName: 'after:response', cb: (res: CyHttpMessages.IncomingResponse) => void | Promise<void>): this
269
+ on(eventName: 'after:response', cb: (res: CyHttpMessages.IncomingResponse<T>) => void | Promise<void>): this
270
270
  }
271
271
 
272
272
  /**
273
273
  * Request/response cycle.
274
274
  */
275
- export interface Interception {
275
+ export interface Interception<TRequest = any, TResponse = any> {
276
276
  id: string
277
277
  /* @internal */
278
278
  browserRequestId?: string
279
279
  routeId: string
280
280
  /* @internal */
281
281
  setLogFlag: (flag: 'spied' | 'stubbed' | 'reqModified' | 'resModified') => void
282
- request: CyHttpMessages.IncomingRequest
282
+ request: CyHttpMessages.IncomingRequest<TRequest>
283
283
  /**
284
284
  * Was `cy.wait()` used to wait on this request?
285
285
  * @internal
286
286
  */
287
287
  requestWaited: boolean
288
- response?: CyHttpMessages.IncomingResponse
288
+ response?: CyHttpMessages.IncomingResponse<TResponse>
289
289
  /**
290
290
  * The error that occurred during this request.
291
291
  */
@@ -312,17 +312,17 @@ export type InterceptionState =
312
312
  'Complete' |
313
313
  'Errored'
314
314
 
315
- export interface Route {
315
+ export interface Route<TRequest = any, TResponse = any> {
316
316
  alias?: string
317
317
  log: any
318
318
  options: RouteMatcherOptions
319
- handler: RouteHandler
319
+ handler: RouteHandler<TRequest, TResponse>
320
320
  hitCount: number
321
- requests: { [key: string]: Interception }
321
+ requests: { [key: string]: Interception<TRequest, TResponse> }
322
322
  command: any
323
323
  }
324
324
 
325
- export interface RouteMap { [key: string]: Route }
325
+ export interface RouteMap<TRequest = any, TResponse = any> { [key: string]: Route<TRequest, TResponse> }
326
326
 
327
327
  /**
328
328
  * A `RouteMatcher` describes a filter for HTTP requests.
@@ -393,9 +393,9 @@ export interface RouteMatcherOptionsGeneric<S> {
393
393
  url?: S
394
394
  }
395
395
 
396
- export type RouteHandlerController = HttpRequestInterceptor
396
+ export type RouteHandlerController<TRequest = any, TResponse = any> = HttpRequestInterceptor<TRequest, TResponse>
397
397
 
398
- export type RouteHandler = string | StaticResponseWithOptions | RouteHandlerController | object
398
+ export type RouteHandler<TRequest = any, TResponse = any> = string | StaticResponseWithOptions | RouteHandlerController<TRequest, TResponse> | object
399
399
 
400
400
  export type InterceptOptions = {
401
401
  /**
@@ -510,7 +510,7 @@ declare global {
510
510
  * })
511
511
  * })
512
512
  */
513
- intercept(url: RouteMatcher, response?: RouteHandler): Chainable<null>
513
+ intercept<TRequest = any, TResponse = any>(url: RouteMatcher, response?: RouteHandler<TRequest, TResponse>): Chainable<null>
514
514
  /**
515
515
  * Use `cy.intercept()` to stub and intercept HTTP requests and responses.
516
516
  *
@@ -518,7 +518,7 @@ declare global {
518
518
  * @example
519
519
  * cy.intercept('GET', 'http://foo.com/fruits', ['apple', 'banana', 'cherry'])
520
520
  */
521
- intercept(method: Method, url: RouteMatcher, response?: RouteHandler): Chainable<null>
521
+ intercept<TRequest = any, TResponse = any>(method: Method, url: RouteMatcher, response?: RouteHandler<TRequest, TResponse>): Chainable<null>
522
522
  /**
523
523
  * Use `cy.intercept()` to stub and intercept HTTP requests and responses.
524
524
  *
@@ -529,7 +529,7 @@ declare global {
529
529
  *
530
530
  * @param mergeRouteMatcher Additional route matcher options to merge with `url`. Typically used for middleware.
531
531
  */
532
- intercept(url: StringMatcher, mergeRouteMatcher: Omit<RouteMatcherOptions, 'url'>, response: RouteHandler): Chainable<null>
532
+ intercept<TRequest = any, TResponse = any>(url: StringMatcher, mergeRouteMatcher: Omit<RouteMatcherOptions, 'url'>, response: RouteHandler<TRequest, TResponse>): Chainable<null>
533
533
  /**
534
534
  * Wait for a specific request to complete.
535
535
  *
@@ -548,7 +548,7 @@ declare global {
548
548
  })
549
549
  ```
550
550
  */
551
- wait(alias: string, options?: Partial<WaitOptions>): Chainable<Interception>
551
+ wait<TRequest = any, TResponse = any>(alias: string, options?: Partial<WaitOptions>): Chainable<Interception<TRequest, TResponse>>
552
552
  /**
553
553
  * Wait for list of requests to complete.
554
554
  *
@@ -568,7 +568,7 @@ declare global {
568
568
  })
569
569
  ```
570
570
  */
571
- wait(alias: string[], options?: Partial<WaitOptions>): Chainable<Interception[]>
571
+ wait(aliases: string[], options?: Partial<WaitOptions>): Chainable<Interception[]>
572
572
  }
573
573
  }
574
574
  }