@sap_oss/wdio-qmate-service
Version:
[](https://api.reuse.software/info/github.com/SAP/wdio-qmate-service)[](http
155 lines (154 loc) • 11.2 kB
TypeScript
import { RequestMethodType } from "./types/mockserver.types";
/**
* @class mockserver
* @memberof ui5
*/
export declare class Mockserver {
private vlf;
private lib;
/**
* @function waitForUi5ApplicationLoad
* @memberOf ui5.mockserver
* @description Waits for the UI5 framework to load and makes sure XHR request finished und busy indicators are not visible anymore.
* @example await ui5.mockserver.waitForUi5ApplicationLoad(100);
*/
waitForUi5ApplicationLoad(): Promise<void>;
/**
* @function interactWithMockServer
* @memberOf ui5.mockserver
* @description Execute client script function to enable interaction with mockserver instance [you can write code in ui5 app context]
* @param {String} mockServerPath - The full path to your mockserver instance
* @param {String | Object} fnCallback - The client script function that you can use to interact with your mockserver instance.
* [Caution] The first and last parameter is reserved (1st param is the mockserver instance and last parameter the promise resolve function - done)
* @param {String} oParams - Additional parameters you would like to inject in your client script function
* @example await ui5.mockserver.interactWithMockServer("path/to/project/localService/main/mockserver", fnCallback, oParams);
*/
interactWithMockServer(mockServerPath: string, fnCallback: any, oParams: string): Promise<void>;
/**
* @function attachFunctionBefore
* @memberOf ui5.mockserver
* @description Attaches a callback function in mockserver attachBefore event to be executed
* @param {String} method - The attachAfter http method [GET or POST].
* @param {String} mockServerPath - The full path to your mockserver file [make sure you implemented getMockServer method so the mockserver instance can be consumed].
* @param {String | Object} fnBeforeCallback - The callback function to be used in the native attachBefore method as described (https://ui5.sap.com/#/api/sap.ui.core.ui5.mockserver%23methods/Summary)
* @param {Object} oParams - Additional parameters you would like to inject in your client script function
* @example await ui5.mockserver.attachFunctionBefore("GET", "path/to/project/localService/main/mockserver", fnBeforeCallback, oParams);
*/
attachFunctionBefore(method: RequestMethodType, mockServerPath: string, fnBeforeCallback: any, oParams: any): Promise<void>;
/**
* @function attachFunctionAfter
* @memberOf ui5.mockserver
* @description Attaches a callback function in mockserver attachAfter event to be executed
* @param {String} method - The attachAfter http method [GET or POST].
* @param {String} mockServerPath - The full path to your mockserver file [make sure you implemented getMockServer method so the mockserver instance can be consumed].
* @param {String|Object} fnAfterCallback - The callback function to be used in the native attachAfter method as described (https://ui5.sap.com/#/api/sap.ui.core.ui5.mockserver%23methods/Summary)
* @param {Object} oParams - Additional parameters you would like to inject in your client script function
* @example await ui5.mockserver.attachFunctionAfter("GET", "path/to/project/localService/main/mockserver", fnAfterCallback);
*/
attachFunctionAfter(method: RequestMethodType, mockServerPath: string, fnAfterCallback: any, oParams: any): Promise<void>;
/**
* @function addNewRequest
* @memberOf ui5.mockserver
* @description Adds new mock request
* @param {String} method - The http method [GET,POST..].
* @param {String} mockServerPath - The full path to your mockserver file [make sure you implemented getMockServer method in this file to return the mockserver instance].
* @param {String} urlPathRegex - The url path regex to filter the requests
* @param {String} responseJsonPath - The json object or the path to your json file to be used as response [use relative path from the html page started].
* @param {Integer} returnCode - The http response code to simulate for this mock request.
* @param {Boolean} isText - If true then content type is text/plain otherwise application/json.
* @param {String} responseMessages - Mocks the gw sap-message response messages [Don't forget to stringify your json before: JSON.stringify(msg)]
* @param {String} responseLocation - Mocks the location response messages header
* @example await ui5.mockserver.addNewRequest("GET","path/to/project/localService/main/mockserver", "*.Headers.*", "path/to/project/localService/main/mockdata/test.json", 200, true, JSON.stringify(msg));
*/
addNewRequest(method: RequestMethodType, mockServerPath: string, urlPathRegex: string, responseJsonPath: string, returnCode: number, isText: boolean, responseMessages: any, responseLocation: any): Promise<void>;
/**
* @function removeRequest
* @memberOf ui5.mockserver
* @description Removes request mock [Doesn't work currently - Mockserver bug]
* @param {String} method - The http method [GET,POST..].
* @param {String} mockServerPath - The full path to your mockserver file [make sure you implemented getMockServer method in this file to return the mockserver instance].
* @param {String} urlPathRegex - The url path regex to filter the requests
* @example await ui5.mockserver.removeRequest("GET","path/to/project/localService/main/mockserver", "*.Headers.*");
*/
removeRequest(method: RequestMethodType, mockServerPath: string, urlPathRegex: string): Promise<void>;
/**
* @function addOrOverrideRequest
* @memberOf ui5.mockserver
* @description Adds new or overrides an existing mock request
* @param {String} method - The http method [GET,POST..].
* @param {String} mockServerPath - The full path to your mockserver file [make sure you implemented getMockServer method in this file to return the mockserver instance].
* @param {String} urlPathRegex - The url path regex to filter the requests
* @param {String} responseJsonPath - The json object or the path to your json file to be used as response [use relative path from the html page started].
* @param {Integer} returnCode - The http response code to simulate for this mock request.
* @param {Boolean} isText - If true then content type is text/plain otherwise application/json.
* @param {String} responseMessages - Mocks the gw sap-message response messages [Don't forget to stringify your json before: JSON.stringify(msg)]
* @param {String} responseLocation - Mocks the location response messages header
* @example await ui5.mockserver.addOrOverrideRequest("GET","path/to/project/localService/main/mockserver", "*.Headers.*", "path/to/project/localService/main/mockdata/test.json", 200, true, JSON.stringify(msg));
*/
addOrOverrideRequest(method: RequestMethodType, mockServerPath: string, urlPathRegex: string, responseJsonPath: string, returnCode: number, isText: any, responseMessages: any, responseLocation: any): Promise<void>;
/**
* @function startMockServer
* @memberOf ui5.mockserver
* @description (Re-)Starts mock server instance
* @param {String} mockServerPath - The full path to your mockserver file [make sure you implemented getMockServer method in this file to return the mockserver instance].
* @example await ui5.mockserver.startMockServer("path/to/project/localService/main/mockserver");
*/
startMockServer(mockServerPath: string): Promise<void>;
/**
* @function initMockServer
* @memberOf ui5.mockserver
* @description Initializes the provide mockserver instance on the fly
* @param {String} mockServerPath - The full path to your mockserver file [make sure you implemented getMockServer method in this file to return the mockserver instance].
* @param {String} mockServerOptions - The mock server options
* @example await ui5.mockserver.initMockServer("path/to/project/localService/main/mockserver", mockServerOptions);
*/
initMockServer(mockServerPath: string, mockServerOptions: string): Promise<any>;
/**
* @function initApplication
* @memberOf ui5.mockserver
* @description Initializes the application [Used in the beggining of script, once the mockserver is fully initialized and request mocking is done]
* @param {String} mockServerPath - The full path to your mockserver file [make sure you implemented getMockServer method in this file to return the mockserver instance].
* @example await ui5.mockserver.initApplication("path/to/project/localService/main/mockserver");
*/
initApplication(mockServerPath: string): Promise<void>;
/**
* @function stopMockServer
* @memberOf ui5.mockserver
* @description Stops the mockserver instance
* @param {String} mockServerPath - The full path to your mockserver file [make sure you implemented getMockServer method in this file to return the mockserver instance].
* @example await ui5.mockserver.stopMockServer("path/to/project/localService/main/mockserver");
*/
stopMockServer(mockServerPath: string): Promise<any>;
/**
* @function loadMockDataFile
* @memberOf ui5.mockserver
* @description Loads a mock data file
* @param {String} filePath - The full path to your mockserver file [make sure you implemented getMockServer method in this file to return the mockserver instance].
* @param {Boolean} isText - If true then content type is text/plain otherwise application/json.
* @returns {String} The json object
* @example await ui5.mockserver.loadMockDataFile("path/to/project/mockData/myData.json", true);
*/
loadMockDataFile(filePath: string, isText: boolean): Promise<any>;
/**
* @function getEntitySetData
* @memberOf ui5.mockserver
* @description Retrieves entity data
* @param {String} mockServerPath - The full path to your mockserver file [make sure you implemented getMockServer method in this file to return the mockserver instance].
* @param {String} entitySetName - The entity set name
* @returns {Array} An array of json objects
* @example await ui5.mockserver.getEntitySetData("path/to/project/localService/main/mockserver", "Headers");
*/
getEntitySetData(mockServerPath: string, entitySetName: string): Promise<any>;
/**
* @function setEntitySetData
* @memberOf ui5.mockserver
* @description Override entity data entries
* @param {String} mockServerPath - The full path to your mockserver file [make sure you implemented getMockServer method in this file to return the mockserver instance].
* @param {String} entitySetName - The entity name
* @param {String} entries - The json object to be used as data to be inserted [use relative path from the html page started].
* @example await ui5.mockserver.setEntitySetData("path/to/project/localService/main/mockserver", "Headers", entries);
*/
setEntitySetData(mockServerPath: string, entitySetName: string, entries: string): Promise<any>;
}
declare const _default: Mockserver;
export default _default;