@sap_oss/wdio-qmate-service
Version:
[](https://api.reuse.software/info/github.com/SAP/wdio-qmate-service)[](http
79 lines • 3.86 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Component = void 0;
const path = __importStar(require("path"));
const fs_1 = __importDefault(require("fs"));
/**
* @class component
* @memberof util
* @description This class provides functions for writing component tests with qmate-proxy-service
*/
class Component {
constructor() {
this._entryPointFolderPath = "./entrypoints";
}
/**
* @function loadEntryPoint
* @memberOf util.component
* @description Will be called in component test scripts. Returns a previously stored entry point object for sharing information (like a draft id) between preparation and the actual component tests.
* @param {String} [folderPath="./entrypoints"] - Custom folder path where entry points are stored.
* @returns {Object} The data object of the stored entry point.
* @example const entryPoint = util.component.loadEntryPoint();
*/
async loadEntryPoint(folderPath = this._entryPointFolderPath) {
// Will be called in component scripts
const componentSpec = runtime.specs.filter((spec) => {
return !spec.includes("prep.");
})[0];
const componentSpecIdentifier = path.basename(componentSpec).replaceAll(".spec.js", "");
return await util.data.readDataFromFile(path.resolve(folderPath, `${componentSpecIdentifier}.entrypoint.json`));
}
/**
* @function storeEntryPoint
* @memberOf util.component
* @description Will be called in preparation scripts before component tests. Stores an entry point object for sharing information (like a draft id) between preparation and the actual component tests.
* @param {Object} data - The data object of the entry point to store.
* @param {String} [folderPath="./entrypoints"] - Custom folder path where entry points are stored.
* @example const entryPoint = util.component.storeEntryPoint({"draftId": "0123456789"});
*/
async storeEntryPoint(data, folderPath = this._entryPointFolderPath) {
// Will be called in preparation scripts
const componentSpec = runtime.specs.filter((spec) => {
return !spec.includes("prep.");
})[0];
const componentSpecIdentifier = path.basename(componentSpec).replaceAll(".spec.js", "");
if (!fs_1.default.existsSync(path.resolve(folderPath))) {
fs_1.default.mkdirSync(path.resolve(folderPath));
}
await util.data.writeDataToFile(path.resolve(folderPath, `${componentSpecIdentifier}.entrypoint.json`), data);
}
}
exports.Component = Component;
exports.default = new Component();
//# sourceMappingURL=component.js.map