///
import { WebsocketListener } from "./src/websocketListener";
import { CallStackWebsocket, IWSMatcher, WaitUntilActionOptions, WriteStatsOptions } from "./WebsocketInterceptor.types";
declare global {
namespace Cypress {
interface Chainable {
/**
* Destroy the Websocket Interceptor
*/
destroyWsInterceptor(): void;
/**
* Recreate the Websocket Interceptor
*/
recreateWsInterceptor(): void;
/**
* Get an instance of the Websocket Interceptor
*
* @returns An instance of the Websocket Interceptor
*/
wsInterceptor(): Chainable;
/**
* Get the last call matching the provided route matcher.
*
* @param matcher A matcher
* @returns The last call information or `undefined` if none matches.
*/
wsInterceptorLastRequest(matcher?: IWSMatcher): Chainable;
/**
* Get the statistics for all requests matching the provided matcher since the beginning
* of the current test.
*
* @param matcher A matcher
* @returns It returns all requests matching the provided matcher with detailed information.
* If none match, it returns an empty array.
*/
wsInterceptorStats(matcher?: IWSMatcher): Chainable;
/**
* Write the logged requests' information (or those filtered by the provided matcher) to a file
*
* @example cy.wsInterceptorStatsToLog("./out") => the output file will be "./out/[Description] It.stats.json"
* @example cy.wsInterceptorStatsToLog("./out", { fileName: "file_name" }) => the output file will be "./out/file_name.stats.json"
* @example cy.wsInterceptorStatsToLog("./out", { matcher: { protocols: "soap" } }) => write only "soap" requests to the output file
* @example cy.wsInterceptorStatsToLog("./out", { matcher: { url: "my-url" } }) => write only requests to my-url to the output file
* @example cy.wsInterceptorStatsToLog("./out", { mapper: (entry) => ({ url: entry.url }) }) => map the output that will be written to the output file
*
* @param outputDir A path for the output directory
* @param options Options
*/
wsInterceptorStatsToLog(outputDir: string, options?: WriteStatsOptions & Partial): Chainable;
/**
* Reset the the Websocket Interceptor's watch
*/
wsResetInterceptorWatch: VoidFunction;
/**
* Wait until a websocket action occurs
*
* @param options Action options
* @param errorMessage An error message when the maximum waiting time is reached
*/
waitUntilWebsocketAction(options?: WaitUntilActionOptions, errorMessage?: string): Cypress.Chainable;
/**
* Wait until a websocket action occurs
*
* @param matcher A matcher
* @param errorMessage An error message when the maximum waiting time is reached
*/
waitUntilWebsocketAction(matcher?: IWSMatcher | IWSMatcher[], errorMessage?: string): Cypress.Chainable;
/**
* Wait until a websocket action occurs
*
* @param matcher A matcher
* @param options Action options
* @param errorMessage An error message when the maximum waiting time is reached
*/
waitUntilWebsocketAction(matcher?: IWSMatcher | IWSMatcher[], options?: WaitUntilActionOptions, errorMessage?: string): Cypress.Chainable;
}
}
}
export declare class WebsocketInterceptor {
private _callStack;
private _skip;
constructor(websocketListener: WebsocketListener);
/**
* Returns a copy of all logged requests since the WebSocket Interceptor was created
* (the Websocket Interceptor is created in `beforeEach`)
*/
get callStack(): CallStackWebsocket[];
private filterItemsByMatcher;
/**
* Get the last call matching the provided route matcher.
*
* @param matcher A matcher
* @returns The last call information or `undefined` if none matches.
*/
getLastRequest(matcher?: IWSMatcher): CallStackWebsocket | undefined;
/**
* Get the statistics for all requests matching the provided matcher since the beginning
* of the current test.
*
* @param matcher A matcher
* @returns It returns all requests matching the provided matcher with detailed information.
* If none match, it returns an empty array.
*/
getStats(matcher?: IWSMatcher): CallStackWebsocket[];
private isThereActionMatch;
/**
* Reset the the Websocket Interceptor's watch
*/
resetWatch(): void;
/**
* Wait until a websocket action occurs
*
* @param options Action options
* @param errorMessage An error message when the maximum waiting time is reached
*/
waitUntilWebsocketAction(options?: WaitUntilActionOptions, errorMessage?: string): Cypress.Chainable;
/**
* Wait until a websocket action occurs
*
* @param matcher A matcher
* @param errorMessage An error message when the maximum waiting time is reached
*/
waitUntilWebsocketAction(matcher?: IWSMatcher | IWSMatcher[], errorMessage?: string): Cypress.Chainable;
/**
* Wait until a websocket action occurs
*
* @param matcher A matcher
* @param options Action options
* @param errorMessage An error message when the maximum waiting time is reached
*/
waitUntilWebsocketAction(matcher?: IWSMatcher | IWSMatcher[], options?: WaitUntilActionOptions, errorMessage?: string): Cypress.Chainable;
private waitUntilWebsocketAction_isMatcher;
private waitUntilWebsocketAction_isOption;
private waitUntilWebsocketAction_withWait;
/**
* Write the logged requests' information (or those filtered by the provided matcher) to a file
*
* @example writeStatsToLog("./out") => the output file will be "./out/Description - It.stats.json"
* @example writeStatsToLog("./out", { fileName: "file_name" }) => the output file will be "./out/file_name.stats.json"
* @example writeStatsToLog("./out", { matcher: { protocols: "soap" } }) => write only "soap" requests to the output file
* @example writeStatsToLog("./out", { matcher: { url: "my-url" } }) => write only requests to my-url to the output file
* @example writeStatsToLog("./out", { mapper: (entry) => ({ url: entry.url }) }) => map the output that will be written to the output file
*
* @param outputDir A path for the output directory
* @param options Options
*/
writeStatsToLog(outputDir: string, options?: WriteStatsOptions & Partial): Cypress.Chainable;
}