apidog-reporter-allure
Version:
An adapter for apidog proving reports in allure format
60 lines (59 loc) • 1.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
exports.findTestCase = findTestCase;
exports.isFolder = isFolder;
var _files = require("../files");
function isFolder(node) {
return !node.hasOwnProperty('id');
}
const apidogData = function () {
console.log('Parsing apidog model');
const result = (0, _files.loadJson)('apidogExport.json');
if (!result) {
console.log('Could not parse apidog data');
}
return result;
}();
function getTestPath(node, name, folderName, path) {
const basePath = folderName ? path ? [...path, folderName] : [folderName] : [];
if (!folderName || basePath.includes(folderName)) {
const testCase = node.items.find(node => node.name === name);
if (testCase) {
return {
...testCase,
path: basePath
};
}
}
for (const child of node.children) {
const testCase = getTestPath(child, name, folderName, basePath);
if (testCase) {
return testCase;
}
}
return undefined;
}
function findTestCase(name, folderName) {
if (apidogData) {
for (const node of apidogData.apiTestCaseCollection) {
if (isFolder(node)) {
const path = getTestPath(node, name, folderName);
if (path) {
return path;
}
continue;
}
if (node.name === name) {
return {
...node,
path: []
};
}
}
}
return undefined;
}
var _default = exports.default = apidogData;