@wdio/allure-reporter
Version:
A WebdriverIO reporter plugin to create Allure Test Reports
230 lines (226 loc) • 7.09 kB
JavaScript
const __importMetaUrl = require('url').pathToFileURL(__filename).href;
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/common/api.ts
var api_exports = {};
__export(api_exports, {
addAllureId: () => addAllureId,
addArgument: () => addArgument,
addAttachment: () => addAttachment,
addDescription: () => addDescription,
addEnvironment: () => addEnvironment,
addEpic: () => addEpic,
addFeature: () => addFeature,
addHistoryId: () => addHistoryId,
addIssue: () => addIssue,
addLabel: () => addLabel,
addLink: () => addLink,
addOwner: () => addOwner,
addParentSuite: () => addParentSuite,
addSeverity: () => addSeverity,
addStep: () => addStep,
addStory: () => addStory,
addSubSuite: () => addSubSuite,
addSuite: () => addSuite,
addTag: () => addTag,
addTestCaseId: () => addTestCaseId,
addTestId: () => addTestId,
default: () => api_default,
endStep: () => endStep,
startStep: () => startStep,
step: () => step
});
module.exports = __toCommonJS(api_exports);
var import_allure_js_commons = require("allure-js-commons");
// src/constants.ts
var events = {
runtimeMessage: "allure:runtimeMessage",
addTestInfo: "allure:addTestInfo",
startStep: "allure:startStep",
endStep: "allure:endStep",
addLabel: "allure:addLabel",
addLink: "allure:addLink",
addFeature: "allure:addFeature",
addStory: "allure:addStory",
addEpic: "allure:addEpic",
addSuite: "allure:addSuite",
addSubSuite: "allure:addSubSuite",
addParentSuite: "allure:addParentSuite",
addOwner: "allure:addOwner",
addSeverity: "allure:addSeverity",
addTag: "allure:addTag",
addIssue: "allure:addIssue",
addAllureId: "allure:addAllureId",
addTestId: "allure:addTestId",
addDescription: "allure:addDescription",
addAttachment: "allure:addAttachment",
addStep: "allure:addStep",
addArgument: "allure:addArgument",
addAllureStep: "allure:addAllureStep"
};
// src/common/api.ts
var tellReporter = (event, msg = {}) => {
process.emit(event, msg);
};
function addLabel(name, value) {
(0, import_allure_js_commons.label)(name, value);
}
async function addLink(url, name, type) {
await (0, import_allure_js_commons.link)(url, name, type);
}
async function addAllureId(id) {
await (0, import_allure_js_commons.allureId)(id);
}
async function addFeature(featureName) {
await (0, import_allure_js_commons.feature)(featureName);
}
async function addSeverity(value) {
await (0, import_allure_js_commons.severity)(value);
}
async function addIssue(id) {
await (0, import_allure_js_commons.issue)(id);
}
async function addTestId(testId) {
await (0, import_allure_js_commons.tms)(testId);
}
async function addStory(storyName) {
await (0, import_allure_js_commons.story)(storyName);
}
async function addSuite(suiteName) {
await (0, import_allure_js_commons.suite)(suiteName);
}
async function addParentSuite(suiteName) {
await (0, import_allure_js_commons.parentSuite)(suiteName);
}
async function addSubSuite(suiteName) {
await (0, import_allure_js_commons.subSuite)(suiteName);
}
async function addEpic(epicName) {
await (0, import_allure_js_commons.epic)(epicName);
}
async function addOwner(ownerName) {
await (0, import_allure_js_commons.owner)(ownerName);
}
async function addTag(tagName) {
await (0, import_allure_js_commons.tag)(tagName);
}
async function addEnvironment(name, value) {
console.warn("\u26A0\uFE0F addEnvironment is deprecated and has no longer any functionality. Use reportedEnvironmentVars in wdio config instead. Read more in https://webdriver.io/docs/allure-reporter.");
}
async function addDescription(descriptionText, descriptionType) {
if (descriptionType === "html") {
await (0, import_allure_js_commons.descriptionHtml)(descriptionText);
return;
}
await (0, import_allure_js_commons.description)(descriptionText);
}
async function addAttachment(name, content, type) {
if (content instanceof Buffer) {
await (0, import_allure_js_commons.attachment)(name, content, type);
return;
}
const contentString = typeof content === "string" ? content : JSON.stringify(content);
await (0, import_allure_js_commons.attachment)(name, contentString, type);
}
async function addArgument(name, value) {
await (0, import_allure_js_commons.parameter)(name, value);
}
async function addHistoryId(id) {
await (0, import_allure_js_commons.historyId)(id);
}
async function addTestCaseId(id) {
await (0, import_allure_js_commons.testCaseId)(id);
}
async function startStep(title) {
tellReporter(events.startStep, title);
}
async function endStep(status = import_allure_js_commons.Status.PASSED) {
if (!Object.values(import_allure_js_commons.Status).includes(status)) {
throw new Error(`Step status must be ${Object.values(import_allure_js_commons.Status).join(" or ")}. You tried to set "${status}"`);
}
tellReporter(events.endStep, status);
}
async function addStep(title, attachment = void 0, status = import_allure_js_commons.Status.PASSED) {
if (!Object.values(import_allure_js_commons.Status).includes(status)) {
throw new Error(`Step status must be ${Object.values(import_allure_js_commons.Status).join(" or ")}. You tried to set "${status}"`);
}
tellReporter(events.startStep, title);
if (attachment?.content) {
await (0, import_allure_js_commons.attachment)(
attachment.name || "Attachment",
Buffer.from(attachment.content, "utf8"),
attachment.type || import_allure_js_commons.ContentType.TEXT
);
}
tellReporter(events.endStep, status);
}
async function step(name, body) {
return (0, import_allure_js_commons.step)(name, body);
}
var api_default = {
addLabel,
addLink,
addAllureId,
addFeature,
addSeverity,
addIssue,
addTestId,
addStory,
addSuite,
addParentSuite,
addSubSuite,
addEpic,
addOwner,
addTag,
addEnvironment,
addDescription,
addAttachment,
startStep,
endStep,
addStep,
addArgument,
step
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
addAllureId,
addArgument,
addAttachment,
addDescription,
addEnvironment,
addEpic,
addFeature,
addHistoryId,
addIssue,
addLabel,
addLink,
addOwner,
addParentSuite,
addSeverity,
addStep,
addStory,
addSubSuite,
addSuite,
addTag,
addTestCaseId,
addTestId,
endStep,
startStep,
step
});