jest-allure2-adapter
Version:
Allure 2 Adapter for jest
55 lines (54 loc) • 1.82 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AllureCurrent = void 0;
const allure_js_commons_1 = require("allure-js-commons");
const utils_1 = require("./utils");
class AllureCurrent {
constructor(runtime, runningExecutable) {
this.runtime = runtime;
this.runningExecutable = runningExecutable;
this.descriptionParts = [];
}
action(action) {
action(this.runningExecutable());
}
attachment(name, content, type = allure_js_commons_1.ContentType.JSON) {
const file = this.runtime.writeAttachment(utils_1.getContent(content, type), type);
this.action((current) => current.addAttachment(name, type, file));
}
addParameter(name, value) {
this.action((current) => current.addParameter(name, value));
return this;
}
addParameters(...params) {
params.forEach((p) => {
const value = typeof p[1] !== 'string' ? JSON.stringify(p[1]) : p[1];
this.action((current) => current.addParameter(p[0], value));
});
return this;
}
description(description) {
this.action((current) => (current.description = description));
return this;
}
descriptionHtml(description) {
this.action((current) => (current.descriptionHtml = description));
return this;
}
addDescription(description) {
this.descriptionParts.push(description);
}
initDescription() {
this.descriptionParts = [];
}
applyDescription() {
if (this.descriptionParts.length > 0) {
this.descriptionHtml(this.descriptionParts.join(''));
}
this.initDescription();
}
getDescription() {
return this.descriptionParts;
}
}
exports.AllureCurrent = AllureCurrent;