cumulocity-cypress
Version:
Cypress commands for Cumulocity IoT
90 lines (89 loc) • 3.59 kB
TypeScript
import { C8yPact, C8yPactID, C8yPactMode, C8yPactRecordingMode } from "../../shared/c8ypact";
declare global {
namespace Cypress {
interface Cypress {
c8yctrl: CypressC8yCtrl;
}
}
/**
* C8yCtrl interface. Contains all functions and properties to interact with c8yctrl
* http proxy and API.
*/
interface CypressC8yCtrl {
/**
* The current pact object used by c8yctrl. This is set by the setCurrent function
* and reset by the resetCurrent function.
*/
get current(): C8yPact | null;
/**
* Returns the current pact mode of the c8yctrl server. This is set by the
* environment variable C8YCTRL_MODE or the default value "disabled".
* @returns The current pact mode.
*/
mode: () => C8yPactMode;
/**
* Returns the current recording mode. This is set by the environment variable
* C8YCTRL_RECORDING_MODE or the default value "append".
* @returns The current recording mode.
*/
recordingMode: () => C8yPactRecordingMode;
/**
* Checks if the c8yctrl server is enabled or configured for current test.
* This is true if the plugin is loaded and the environment variable
* C8YCTRL_MODE is configured.
* @returns True if using the c8yctrl server is enabled, false otherwise.
*/
isEnabled: () => boolean;
/**
* Checks if the c8yctrl server is enabled. This is true if the mode is set to
* "record", or "recording".
* @returns True if the c8yctrl server is enabled, false otherwise.
*/
isRecordingEnabled: () => boolean;
/**
* Checks if the mocking is enabled. This is true if the mode is set to
* "mock" or "apply" and the c8yctrl server is enabled.
* @returns True if mocking is enabled, false otherwise.
*/
isMockingEnabled: () => boolean;
/**
* Sets the current test in the c8yctrl server. This will also set the
* Cypress.c8yctrl.current property to the C8yPact object of the current test.
* @param options The options to set the current test.
* @returns The response object of the c8yctrl API call to set the current test.
*/
setCurrent: (options: {
id?: C8yPactID;
title?: string | string[];
clear?: boolean;
mode?: C8yPactMode;
recordingMode?: C8yPactRecordingMode;
}) => Cypress.Chainable<C8yCtrlCurrentResponse | null>;
/**
* Resets the current test in the c8yctrl server. This will also reset the
* Cypress.c8yctrl.current property to null.
* @returns The response object of the c8yctrl API call to reset the current test.
*/
resetCurrent: () => Cypress.Chainable<C8yCtrlCurrentResponse | null>;
/**
* Gets the URL of the c8yctrl server. This could be from the environment variable
* C8YCTRL_URL or the baseUrl from the Cypress config.
* @returns The URL of the c8yctrl server. If the URL is not set, it returns null.
*/
url: () => string | null;
/**
* Use debugLog to enable logging of debug information to the Cypress debug log.
*/
debugLog: boolean;
}
}
export type C8yCtrlCurrentResponse = {
status: number;
headers: any;
body: any;
statusText: string;
ok: boolean;
redirected: boolean;
type: string;
url: string;
};