cypress
Advanced tools
Comparing version 13.10.0 to 13.11.0
{ | ||
"name": "cypress", | ||
"version": "13.10.0", | ||
"version": "13.11.0", | ||
"main": "index.js", | ||
@@ -137,4 +137,4 @@ "scripts": { | ||
"commitBranch": "develop", | ||
"commitSha": "374ceb20f95402a4f98d858d47307726dcc83102", | ||
"commitDate": "2024-05-21T18:35:43.000Z", | ||
"commitSha": "09c6876637d13686178ef934f988b757d04cf813", | ||
"commitDate": "2024-06-04T18:16:38.000Z", | ||
"stable": true | ||
@@ -141,0 +141,0 @@ }, |
// Copied from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/methods/index.d.ts | ||
type Method = | ||
| 'ACL' | ||
| 'BIND' | ||
| 'CHECKOUT' | ||
| 'CONNECT' | ||
| 'COPY' | ||
| 'DELETE' | ||
| 'GET' | ||
| 'HEAD' | ||
| 'LINK' | ||
| 'LOCK' | ||
| 'M-SEARCH' | ||
| 'MERGE' | ||
| 'MKACTIVITY' | ||
| 'MKCALENDAR' | ||
| 'MKCOL' | ||
| 'MOVE' | ||
| 'NOTIFY' | ||
| 'OPTIONS' | ||
| 'PATCH' | ||
| 'POST' | ||
| 'PROPFIND' | ||
| 'PROPPATCH' | ||
| 'PURGE' | ||
| 'PUT' | ||
| 'REBIND' | ||
| 'REPORT' | ||
| 'SEARCH' | ||
| 'SOURCE' | ||
| 'SUBSCRIBE' | ||
| 'TRACE' | ||
| 'UNBIND' | ||
| 'UNLINK' | ||
| 'UNLOCK' | ||
| 'UNSUBSCRIBE' | ||
| 'acl' | ||
| 'bind' | ||
| 'checkout' | ||
| 'connect' | ||
| 'copy' | ||
| 'delete' | ||
| 'get' | ||
| 'head' | ||
| 'link' | ||
| 'lock' | ||
| 'm-search' | ||
| 'merge' | ||
| 'mkactivity' | ||
| 'mkcalendar' | ||
| 'mkcol' | ||
| 'move' | ||
| 'notify' | ||
| 'options' | ||
| 'patch' | ||
| 'post' | ||
| 'propfind' | ||
| 'proppatch' | ||
| 'purge' | ||
| 'put' | ||
| 'rebind' | ||
| 'report' | ||
| 'search' | ||
| 'source' | ||
| 'subscribe' | ||
| 'trace' | ||
| 'unbind' | ||
| 'unlink' | ||
| 'unlock' | ||
| 'unsubscribe' | ||
| 'ACL' | ||
| 'BIND' | ||
| 'CHECKOUT' | ||
| 'CONNECT' | ||
| 'COPY' | ||
| 'DELETE' | ||
| 'GET' | ||
| 'HEAD' | ||
| 'LINK' | ||
| 'LOCK' | ||
| 'M-SEARCH' | ||
| 'MERGE' | ||
| 'MKACTIVITY' | ||
| 'MKCALENDAR' | ||
| 'MKCOL' | ||
| 'MOVE' | ||
| 'NOTIFY' | ||
| 'OPTIONS' | ||
| 'PATCH' | ||
| 'POST' | ||
| 'PROPFIND' | ||
| 'PROPPATCH' | ||
| 'PURGE' | ||
| 'PUT' | ||
| 'REBIND' | ||
| 'REPORT' | ||
| 'SEARCH' | ||
| 'SOURCE' | ||
| 'SUBSCRIBE' | ||
| 'TRACE' | ||
| 'UNBIND' | ||
| 'UNLINK' | ||
| 'UNLOCK' | ||
| 'UNSUBSCRIBE' | ||
| 'acl' | ||
| 'bind' | ||
| 'checkout' | ||
| 'connect' | ||
| 'copy' | ||
| 'delete' | ||
| 'get' | ||
| 'head' | ||
| 'link' | ||
| 'lock' | ||
| 'm-search' | ||
| 'merge' | ||
| 'mkactivity' | ||
| 'mkcalendar' | ||
| 'mkcol' | ||
| 'move' | ||
| 'notify' | ||
| 'options' | ||
| 'patch' | ||
| 'post' | ||
| 'propfind' | ||
| 'proppatch' | ||
| 'purge' | ||
| 'put' | ||
| 'rebind' | ||
| 'report' | ||
| 'search' | ||
| 'source' | ||
| 'subscribe' | ||
| 'trace' | ||
| 'unbind' | ||
| 'unlink' | ||
| 'unlock' | ||
| 'unsubscribe' | ||
@@ -75,3 +75,3 @@ export type ResourceType = 'document' | 'fetch' | 'xhr' | 'websocket' | 'stylesheet' | 'script' | 'image' | 'font' | 'cspviolationreport' | 'ping' | 'manifest' | 'other' | ||
export namespace CyHttpMessages { | ||
export interface BaseMessage { | ||
export interface BaseMessage<T = any> { | ||
/** | ||
@@ -82,3 +82,3 @@ * The body of the HTTP message. | ||
*/ | ||
body: any | ||
body: T | ||
/** | ||
@@ -90,3 +90,3 @@ * The headers of the HTTP message. | ||
export type IncomingResponse = BaseMessage & { | ||
export type IncomingResponse<T = any> = BaseMessage<T> & { | ||
/** | ||
@@ -110,3 +110,3 @@ * The HTTP status code of the response. | ||
export type IncomingHttpResponse = IncomingResponse & { | ||
export type IncomingHttpResponse<T = any> = IncomingResponse<T> & { | ||
/** | ||
@@ -125,10 +125,10 @@ * Continue the HTTP response, merging the supplied values with the real response. | ||
*/ | ||
setDelay: (delay: number) => IncomingHttpResponse | ||
setDelay: (delay: number) => IncomingHttpResponse<T> | ||
/** | ||
* Serve the response at `throttleKbps` kilobytes per second. | ||
*/ | ||
setThrottle: (throttleKbps: number) => IncomingHttpResponse | ||
setThrottle: (throttleKbps: number) => IncomingHttpResponse<T> | ||
} | ||
export type IncomingRequest = BaseMessage & { | ||
export type IncomingRequest<T = any> = BaseMessage<T> & { | ||
/** | ||
@@ -145,3 +145,3 @@ * Request HTTP method (GET, POST, ...). | ||
*/ | ||
query: Record<string, string|number> | ||
query: Record<string, string | number> | ||
/** | ||
@@ -172,3 +172,3 @@ * The HTTP version used in the request. Read only. | ||
export interface IncomingHttpRequest extends IncomingRequest, RequestEvents { | ||
export interface IncomingHttpRequest<TRequest = any, TResponse = any> extends IncomingRequest<TRequest>, RequestEvents<TResponse> { | ||
/** | ||
@@ -183,3 +183,3 @@ * Destroy the request and respond with a network error. | ||
*/ | ||
continue(interceptor?: HttpResponseInterceptor): void | ||
continue(interceptor?: HttpResponseInterceptor<TResponse>): void | ||
/** | ||
@@ -192,3 +192,3 @@ * Control the response to this request. | ||
*/ | ||
reply(interceptor?: StaticResponse | HttpResponseInterceptor): void | ||
reply(interceptor?: StaticResponse | HttpResponseInterceptor<TResponse>): void | ||
/** | ||
@@ -209,4 +209,4 @@ * Shortcut to reply to the request with a body and optional headers. | ||
export interface ResponseComplete { | ||
finalResBody?: BaseMessage['body'] | ||
export interface ResponseComplete<T = any> { | ||
finalResBody?: BaseMessage<T>['body'] | ||
} | ||
@@ -233,3 +233,3 @@ | ||
*/ | ||
export type HttpRequestInterceptor = (req: CyHttpMessages.IncomingHttpRequest) => void | Promise<void> | ||
export type HttpRequestInterceptor<TRequest = any, TResponse = any> = (req: CyHttpMessages.IncomingHttpRequest<TRequest, TResponse>) => void | Promise<void> | ||
@@ -241,3 +241,3 @@ /** | ||
*/ | ||
export type HttpResponseInterceptor = (res: CyHttpMessages.IncomingHttpResponse) => void | Promise<void> | ||
export type HttpResponseInterceptor<T = any> = (res: CyHttpMessages.IncomingHttpResponse<T>) => void | Promise<void> | ||
@@ -263,3 +263,3 @@ /** | ||
interface RequestEvents { | ||
interface RequestEvents<T> { | ||
/** | ||
@@ -270,3 +270,3 @@ * Emitted before `response` and before any `req.continue` handlers. | ||
*/ | ||
on(eventName: 'before:response', cb: HttpResponseInterceptor): this | ||
on(eventName: 'before:response', cb: HttpResponseInterceptor<T>): this | ||
/** | ||
@@ -277,3 +277,3 @@ * Emitted after `before:response` and after any `req.continue` handlers - before the response is sent to the browser. | ||
*/ | ||
on(eventName: 'response', cb: HttpResponseInterceptor): this | ||
on(eventName: 'response', cb: HttpResponseInterceptor<T>): this | ||
/** | ||
@@ -284,3 +284,3 @@ * Emitted once the response to a request has finished sending to the browser. | ||
*/ | ||
on(eventName: 'after:response', cb: (res: CyHttpMessages.IncomingResponse) => void | Promise<void>): this | ||
on(eventName: 'after:response', cb: (res: CyHttpMessages.IncomingResponse<T>) => void | Promise<void>): this | ||
} | ||
@@ -291,3 +291,3 @@ | ||
*/ | ||
export interface Interception { | ||
export interface Interception<TRequest = any, TResponse = any> { | ||
id: string | ||
@@ -299,3 +299,3 @@ /* @internal */ | ||
setLogFlag: (flag: 'spied' | 'stubbed' | 'reqModified' | 'resModified') => void | ||
request: CyHttpMessages.IncomingRequest | ||
request: CyHttpMessages.IncomingRequest<TRequest> | ||
/** | ||
@@ -306,3 +306,3 @@ * Was `cy.wait()` used to wait on this request? | ||
requestWaited: boolean | ||
response?: CyHttpMessages.IncomingResponse | ||
response?: CyHttpMessages.IncomingResponse<TResponse> | ||
/** | ||
@@ -334,13 +334,13 @@ * The error that occurred during this request. | ||
export interface Route { | ||
export interface Route<TRequest = any, TResponse = any> { | ||
alias?: string | ||
log: any | ||
options: RouteMatcherOptions | ||
handler: RouteHandler | ||
handler: RouteHandler<TRequest, TResponse> | ||
hitCount: number | ||
requests: { [key: string]: Interception } | ||
requests: { [key: string]: Interception<TRequest, TResponse> } | ||
command: any | ||
} | ||
export interface RouteMap { [key: string]: Route } | ||
export interface RouteMap<TRequest = any, TResponse = any> { [key: string]: Route<TRequest, TResponse> } | ||
@@ -416,5 +416,5 @@ /** | ||
export type RouteHandlerController = HttpRequestInterceptor | ||
export type RouteHandlerController<TRequest = any, TResponse = any> = HttpRequestInterceptor<TRequest, TResponse> | ||
export type RouteHandler = string | StaticResponseWithOptions | RouteHandlerController | object | ||
export type RouteHandler<TRequest = any, TResponse = any> = string | StaticResponseWithOptions | RouteHandlerController<TRequest, TResponse> | object | ||
@@ -534,3 +534,3 @@ export type InterceptOptions = { | ||
*/ | ||
intercept(url: RouteMatcher, response?: RouteHandler): Chainable<null> | ||
intercept<TRequest = any, TResponse = any>(url: RouteMatcher, response?: RouteHandler<TRequest, TResponse>): Chainable<null> | ||
/** | ||
@@ -543,3 +543,3 @@ * Use `cy.intercept()` to stub and intercept HTTP requests and responses. | ||
*/ | ||
intercept(method: Method, url: RouteMatcher, response?: RouteHandler): Chainable<null> | ||
intercept<TRequest = any, TResponse = any>(method: Method, url: RouteMatcher, response?: RouteHandler<TRequest, TResponse>): Chainable<null> | ||
/** | ||
@@ -555,3 +555,3 @@ * Use `cy.intercept()` to stub and intercept HTTP requests and responses. | ||
*/ | ||
intercept(url: StringMatcher, mergeRouteMatcher: Omit<RouteMatcherOptions, 'url'>, response: RouteHandler): Chainable<null> | ||
intercept<TRequest = any, TResponse = any>(url: StringMatcher, mergeRouteMatcher: Omit<RouteMatcherOptions, 'url'>, response: RouteHandler<TRequest, TResponse>): Chainable<null> | ||
/** | ||
@@ -575,3 +575,3 @@ * Wait for a specific request to complete. | ||
*/ | ||
wait(alias: string, options?: Partial<WaitOptions>): Chainable<Interception> | ||
wait<TRequest = any, TResponse = any>(alias: string, options?: Partial<WaitOptions>): Chainable<Interception<TRequest, TResponse>> | ||
/** | ||
@@ -596,5 +596,5 @@ * Wait for list of requests to complete. | ||
*/ | ||
wait(alias: string[], options?: Partial<WaitOptions>): Chainable<Interception[]> | ||
wait(aliases: string[], options?: Partial<WaitOptions>): Chainable<Interception[]> | ||
} | ||
} | ||
} |
7193297