UNPKG

@sap_oss/wdio-qmate-service

Version:

[![REUSE status](https://api.reuse.software/badge/github.com/SAP/wdio-qmate-service)](https://api.reuse.software/info/github.com/SAP/wdio-qmate-service)[![Node.js CI](https://github.com/SAP/wdio-qmate-service/actions/workflows/node.js.yml/badge.svg)](http

64 lines (63 loc) 3.7 kB
declare class DataExchangeUtil { /** * @function getFileAbsPath * @param {string} fileWithPath - file with relative or absolute file path * @return {string} the file with absolute file path * @example await getFileAbsPath("./data/myfolder/po.json"); */ getFileAbsPath(fileWithPath: string): string | undefined; /** * @function isReadable - checks if file is present and readable * @param {string} filename - file name with full path * @return {Boolean} - true if file is readable, false if file is not present or not readable */ isReadable(filename: string): Promise<boolean>; /** * @function readJson - reads JSON data from a file. This method has been added, since unlike fs-extra.readJson, this * one handles empty JSON files. It returns null object if file is empty. * @param {string} filename - file name with full path * @return {object} - the JSON data * @throws {*} - throws an error if file is not readable, or if data is not valid JSON */ readJson(filename: string): Promise<object | null>; /** * @function outputJson - writes JSON data into a file. This method has been added, since unlike fs-extra.outputJson, this * one writes an empty file if JSON data is null or if empty object. * fs-extra.outputJson is used internally, which will create the file and output directory if required. * @param {string} fileWithPath - file name with full path * @param {object} data - the JSON data * @param {object} options - options, e.g. {spaces: 2} to pretty print JSON * @throws {*} - throws an error if file is not writable */ outputJson(fileWithPath: string, data: object, options?: object): Promise<void>; /** * @function readData - read import data and assign the values to browser.params.import * if params is ["po"] then data read from file or folder will be assigned to browser.params.import.po * @param {string} fileOrDir - file or directory with full path * @param {string[]} params - the keys under which data should be stored */ readData(fileOrDir: string, params: string[], config: Record<string, any>): Promise<void>; /** * @function readFolder - read json files in specified folder and any subfolders under it * if params = ["test1", "purchaseRequisition"] then the data read from folder will be * assigned to browser.params.import.test1.purchaseRequisition * if file "data1.json" is present in the folder, then the data from this json file will go * under browser.params.import.test1.purchaseRequisition.data1, the file prefix is used as key * if subfolder "testsubfolder1" is encountered, then the file data will go under * browser.params.import.test1.purchaseRequisition.testsubfolder1, the subfolder name is used as key * @param {string} folder - folder with complete path * @param {string[]} params - the keys hierarchy under which data should be stored */ readFolder(folder: string, params: string[], config: Record<string, any>): Promise<void>; /** * @function readFile * reads json data in the specified file and assigns to browser.params.import * if params = ["test1", "purchaseRequisition"] then the data read from file will be * assigned to browser.params.import.test1.purchaseRequisition * @param {string} filename - file to be read, includes path * @param {string[]} params - the keys hierarchy under which data should be stored */ readFile(filename: string, params: string[], config: Record<string, any>): Promise<void>; } declare const _default: DataExchangeUtil; export default _default;