cumulocity-cypress
Version:
Cypress commands for Cumulocity IoT
38 lines (37 loc) • 1.29 kB
TypeScript
declare global {
namespace Cypress {
interface Chainable {
/**
* Retry a request for a given number of max retries and delay. When test function
* `testFn` returns `true` stop retrying and continue.
*
* Use `retries` to pass number of retries and `retryDelay` to pass delay in milliseconds.
*
* @example
* cy.retryRequest(
* {
* method: "GET",
* url: "/service/apama-oeeapp/mon/ping",
* retries: Cypress.env("livenessRetries") || 5,
* retryDelay: Cypress.env("livenessRetryTimeout") || 10000,
* },
* (response) => {
* return response.status === 200;
* }
* );
*/
retryRequest<T = any>(options: C8yRequestOptions, testFn: (response: any) => boolean): Chainable<Response<T>>;
}
interface Cypress {
cy: {
addCommand: (cmd: any) => void;
};
}
}
type RetryOptions = {
retries: number;
retryDelay: number;
};
type C8yRequestOptions = Partial<Cypress.RequestOptions> & RetryOptions;
}
export {};