UNPKG

apidog-reporter-allure

Version:
116 lines (115 loc) 2.96 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _allureJsCommons = require("allure-js-commons"); var _utils = require("../utils"); const allureConfig = { resultsDir: 'allure-results' }; const allureAdapter = function () { const data = { allureConfig, allureRuntime: new _allureJsCommons.AllureRuntime(allureConfig), startGroup: function (groupName = 'standalone') { this.currentGroup = this.allureRuntime.startGroup(groupName); }, endGroup: function () { if (!this.currentGroup) { console.log("No group exists"); return; } this.currentGroup.endGroup(); this.currentGroup = undefined; }, startTest: function (testName, started) { if (this.currentTest) { console.log('Previous test was run'); this.currentTest.endTest(started); } if (!this.currentGroup) { console.log("No group exists"); this.startGroup(); } this.currentTest = this.currentGroup?.startTest(testName, started); }, endTest: function (end) { if (!this.currentTest) { console.log('Could not end test. No Test exists'); return; } this.currentTest.endTest(end); this.currentTest = undefined; }, startStep: function (stepName, start) { if (!this.currentTest) { console.log('Could not attach step. No test exists'); return; } if (this.currentStep) { this.currentStep = { step: this.currentStep.step.startStep(stepName, start), parent: this.currentStep }; } else { this.currentStep = { step: this.currentTest.startStep(stepName, start) }; } }, endStep: function (end) { if (!this.currentStep) { console.log('No step was running'); return; } this.currentStep.step.endStep(end); this.currentStep = this.currentStep.parent; }, stepStatus: function ({ status, message, trace, end }) { if (!this.currentStep) { console.log('No step was running'); return; } if (status) { this.currentStep.step.status = status; } if (message || trace) { this.currentStep.step.statusDetails = { message, trace }; } if (end) { this.endStep(end); } }, testStatus: function ({ message, trace }) { if (this.testStatusDetails) { return; } this.testStatusDetails = { message, trace }; if (!this.currentTest) { console.log('No test was running'); return; } if (message || trace) { this.currentTest.statusDetails = this.testStatusDetails; } } }; (0, _utils.joinMethods)(data); return data; }(); var _default = exports.default = allureAdapter;