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

87 lines 4.15 kB
"use strict"; 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 () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __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 { _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