@sap_oss/wdio-qmate-service
Version:
[](https://api.reuse.software/info/github.com/SAP/wdio-qmate-service)[](http
56 lines • 2.13 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = default_1;
const path = require("path");
const stats_1 = require("../stats/stats");
const dataExchangeCommands_1 = __importDefault(require("./utils/dataExchangeCommands"));
/**
* Gets executed once before all workers get launched.
* @param {Object} config wdio configuration object
* @param {Array.<Object>} capabilities list of capabilities details
*/
async function default_1(config, capabilities, callbackStatsUsageId) {
// Set the CONFIG_PATH environment variable to the directory of the config file
if (!process.env.CONFIG_PATH) {
process.env.CONFIG_PATH = path.dirname(config._[0]);
}
const specCounter = config.specs ? countNestedArrayElements(config.specs) : 0;
// Send usage requests
if (config.params && config.params.qmateStatsOptions) {
if (!config.params.qmateStatsOptions.optOut) {
try {
(0, stats_1.sendUsageRequests)(specCounter).then((res) => {
if (res != null) {
callbackStatsUsageId(res);
}
});
}
catch (error) {
// Intentionally left empty -> call only succeeds when done SAP internally
}
}
}
// Set Qmate custom timeouts
if (config.params && config.params.qmateCustomTimeout) {
process.env.QMATE_CUSTOM_TIMEOUT = config.params.qmateCustomTimeout;
process.env.LOAD_PROPERTY_TIMEOUT = config.params.loadPropertyTimeout;
}
// Create a temporary data folder
await dataExchangeCommands_1.default.createTmpDataFolder();
}
function countNestedArrayElements(arr) {
let count = 0;
for (const element of arr) {
if (Array.isArray(element)) {
count += countNestedArrayElements(element);
}
else {
count++;
}
}
return count;
}
//# sourceMappingURL=onPrepare.js.map