allure-js-commons
Advanced tools
Comparing version 3.0.0-beta.1 to 3.0.0-beta.2
@@ -6,6 +6,8 @@ "use strict"; | ||
}); | ||
exports.tms = exports.testCaseId = exports.tags = exports.tag = exports.suite = exports.subSuite = exports.story = exports.step = exports.severity = exports.parentSuite = exports.parameter = exports.owner = exports.links = exports.link = exports.layer = exports.labels = exports.label = exports.issue = exports.historyId = exports.feature = exports.epic = exports.displayName = exports.descriptionHtml = exports.description = exports.attachment = exports.allureId = void 0; | ||
exports.tms = exports.testCaseId = exports.tags = exports.tag = exports.suite = exports.subSuite = exports.story = exports.step = exports.severity = exports.parentSuite = exports.parameter = exports.owner = exports.links = exports.link = exports.layer = exports.labels = exports.label = exports.issue = exports.historyId = exports.feature = exports.epic = exports.displayName = exports.descriptionHtml = exports.description = exports.attachmentPath = exports.attachment = exports.allureId = void 0; | ||
var _model = require("./model.js"); | ||
var _runtime = require("./sdk/runtime/runtime.js"); | ||
var _utils = require("./sdk/utils.js"); | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
var callRuntimeMethod = function callRuntimeMethod(method) { | ||
@@ -30,9 +32,2 @@ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
}); | ||
// const runtime = getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// if (!isPromise(runtime)) { | ||
// return (runtime as TestRuntime).labels({ name, value }); | ||
// } | ||
// | ||
// return (runtime as Promise<TestRuntime>).then((testRuntime) => testRuntime.labels({ name, value })); | ||
}; | ||
@@ -44,11 +39,5 @@ exports.label = label; | ||
} | ||
// const runtime = await getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// return runtime.labels(...labelsList); | ||
return callRuntimeMethod("labels", ...labelsList); | ||
}; | ||
var link = (url, type, name) => { | ||
// const runtime = await getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// return runtime.links({ url, type, name }); | ||
var link = (url, name, type) => { | ||
return callRuntimeMethod("links", { | ||
@@ -65,11 +54,5 @@ url, | ||
} | ||
// const runtime = await getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// return runtime.links(...linksList); | ||
return callRuntimeMethod("links", ...linksList); | ||
}; | ||
var parameter = (name, value, options) => { | ||
// const runtime = await getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// return runtime.parameter(name, value, options); | ||
return callRuntimeMethod("parameter", name, value, options); | ||
@@ -79,5 +62,2 @@ }; | ||
var description = markdown => { | ||
// const runtime = await getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// return runtime.description(markdown); | ||
return callRuntimeMethod("description", markdown); | ||
@@ -87,5 +67,2 @@ }; | ||
var descriptionHtml = html => { | ||
// const runtime = await getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// return runtime.descriptionHtml(html); | ||
return callRuntimeMethod("descriptionHtml", html); | ||
@@ -95,5 +72,2 @@ }; | ||
var displayName = name => { | ||
// const runtime = await getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// return runtime.displayName(name); | ||
return callRuntimeMethod("displayName", name); | ||
@@ -103,5 +77,2 @@ }; | ||
var historyId = value => { | ||
// const runtime = await getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// return runtime.historyId(value); | ||
return callRuntimeMethod("historyId", value); | ||
@@ -111,22 +82,24 @@ }; | ||
var testCaseId = value => { | ||
// const runtime = await getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// return runtime.testCaseId(value); | ||
return callRuntimeMethod("testCaseId", value); | ||
}; | ||
exports.testCaseId = testCaseId; | ||
var attachment = (name, content, type) => { | ||
// const runtime = await getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// return runtime.attachment(name, content, type); | ||
return callRuntimeMethod("attachment", name, content, type); | ||
var attachment = (name, content, options) => { | ||
var opts = typeof options === "string" ? { | ||
contentType: options | ||
} : options; | ||
return callRuntimeMethod("attachment", name, content, opts); | ||
}; | ||
exports.attachment = attachment; | ||
var attachmentPath = (name, path, options) => { | ||
var opts = typeof options === "string" ? { | ||
contentType: options | ||
} : options; | ||
return callRuntimeMethod("attachmentFromPath", name, path, opts); | ||
}; | ||
exports.attachmentPath = attachmentPath; | ||
var stepContext = () => ({ | ||
displayName: name => { | ||
// return runtime.stepDisplayName(name); | ||
return callRuntimeMethod("stepDisplayName", name); | ||
}, | ||
parameter: (name, value, mode) => { | ||
// return runtime.stepParameter(name, value, mode); | ||
return callRuntimeMethod("stepParameter", name, value, mode); | ||
@@ -136,12 +109,8 @@ } | ||
var step = (name, body) => { | ||
// throw new Error("Not implemented"); | ||
// const runtime = await getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// return runtime.step(name, () => body(stepContext(runtime))); | ||
return callRuntimeMethod("step", name, () => body(stepContext())); | ||
}; | ||
exports.step = step; | ||
var issue = (url, name) => link(url, _model.LinkType.ISSUE, name); | ||
var issue = (url, name) => link(url, name, _model.LinkType.ISSUE); | ||
exports.issue = issue; | ||
var tms = (url, name) => link(url, _model.LinkType.TMS, name); | ||
var tms = (url, name) => link(url, name, _model.LinkType.TMS); | ||
exports.tms = tms; | ||
@@ -174,5 +143,2 @@ var allureId = value => label(_model.LabelName.ALLURE_ID, value); | ||
} | ||
// const runtime = await getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// return runtime.labels(...tagsList.map((value) => ({ name: LabelName.TAG, value }))); | ||
return callRuntimeMethod("labels", ...tagsList.map(value => ({ | ||
@@ -179,0 +145,0 @@ name: _model.LabelName.TAG, |
@@ -59,3 +59,3 @@ "use strict"; | ||
get: function get() { | ||
return _MessageWriter.MessageReader; | ||
return _MessageReader.MessageReader; | ||
} | ||
@@ -135,3 +135,4 @@ }); | ||
var _MessageWriter = require("./writer/MessageWriter.js"); | ||
var _MessageReader = require("./writer/MessageReader.js"); | ||
var _labels = require("./utils/labels.js"); | ||
//# sourceMappingURL=index.js.map |
@@ -28,4 +28,4 @@ "use strict"; | ||
_defineProperty(this, "getExecutionItem", uuid => { | ||
var _ref, _this$fixturesResults, _this$fixturesResults2; | ||
return (_ref = (_this$fixturesResults = (_this$fixturesResults2 = this.fixturesResults.get(uuid)) === null || _this$fixturesResults2 === void 0 ? void 0 : _this$fixturesResults2.value) !== null && _this$fixturesResults !== void 0 ? _this$fixturesResults : this.testResults.get(uuid)) !== null && _ref !== void 0 ? _ref : this.stepResults.get(uuid); | ||
var _ref, _this$getFixture; | ||
return (_ref = (_this$getFixture = this.getFixture(uuid)) !== null && _this$getFixture !== void 0 ? _this$getFixture : this.getTest(uuid)) !== null && _ref !== void 0 ? _ref : this.getStep(uuid); | ||
}); | ||
@@ -32,0 +32,0 @@ // test results |
@@ -14,7 +14,6 @@ "use strict"; | ||
var _utils = require("./utils.js"); | ||
var wellKnownCommonWriters = _interopRequireWildcard(require("./writer/wellKnownCommonWriters.js")); | ||
var _attachments = require("./utils/attachments.js"); | ||
var _loader = require("./writer/loader.js"); | ||
var _excluded = ["links", "attachments", "displayName", "parameters", "labels"], | ||
_excluded2 = ["status", "stage", "stop"]; | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } | ||
@@ -469,26 +468,17 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; } | ||
}); | ||
_defineProperty(this, "buildAttachmentFileName", options => { | ||
var attachmentUuid = (0, _utils.randomUuid)(); | ||
var attachmentExtension = (0, _utils.typeToExtension)({ | ||
fileExtension: options.fileExtension, | ||
contentType: options.contentType | ||
}); | ||
return "".concat(attachmentUuid, "-attachment").concat(attachmentExtension); | ||
}); | ||
_defineProperty(this, "writeAttachment", (attachment, uuid) => { | ||
var targetUuid = this.contextProvider.getExecutingItem(uuid); | ||
if (!targetUuid) { | ||
this.logMissingStepRoot(uuid, "attach"); | ||
_defineProperty(this, "writeAttachment", (attachmentName, attachmentContent, options, uuid) => { | ||
var target = this.getCurrentExecutingItem(uuid); | ||
if (!target) { | ||
if (uuid) { | ||
// eslint-disable-next-line no-console | ||
console.error("No test or fixture ".concat(uuid, " to attach!")); | ||
} else { | ||
// eslint-disable-next-line no-console | ||
console.error("No current test or fixture to attach!"); | ||
} | ||
return; | ||
} | ||
var targetResult = this.state.getExecutionItem(targetUuid); | ||
if (!targetResult) { | ||
// eslint-disable-next-line no-console | ||
console.error("No test, fixture, or step ".concat(targetUuid, " to attach!")); | ||
return; | ||
} | ||
this.writeAttachmentForItem(attachment, targetResult); | ||
this.writeAttachmentForItem(attachmentName, attachmentContent, options, target); | ||
}); | ||
_defineProperty(this, "writeAttachmentFromPath", (attachmentName, attachmentPath, options, uuid) => { | ||
var _options$fileExtensio; | ||
var target = this.getCurrentExecutingItem(uuid); | ||
@@ -505,13 +495,3 @@ if (!target) { | ||
} | ||
var attachmentFilename = this.buildAttachmentFileName(_objectSpread(_objectSpread({}, options), {}, { | ||
fileExtension: (_options$fileExtensio = options.fileExtension) !== null && _options$fileExtensio !== void 0 ? _options$fileExtensio : (0, _path.extname)(attachmentPath) | ||
})); | ||
this.writer.writeAttachmentFromPath(attachmentPath, attachmentFilename); | ||
var rawAttachment = { | ||
name: attachmentName, | ||
source: attachmentFilename, | ||
type: options.contentType | ||
}; | ||
target.attachments.push(rawAttachment); | ||
return attachmentFilename; | ||
this.writeAttachmentForItem(attachmentName, attachmentPath, options, target); | ||
}); | ||
@@ -594,5 +574,8 @@ _defineProperty(this, "writeEnvironmentInfo", () => { | ||
return; | ||
case "raw_attachment": | ||
this.handleRawAttachmentMessage(message, targets); | ||
case "attachment_content": | ||
this.handleAttachmentContentMessage(message, targets); | ||
return; | ||
case "attachment_path": | ||
this.handleAttachmentPathMessage(message, targets); | ||
return; | ||
default: | ||
@@ -690,3 +673,3 @@ return message; | ||
}); | ||
_defineProperty(this, "handleRawAttachmentMessage", (message, _ref8) => { | ||
_defineProperty(this, "handleAttachmentContentMessage", (message, _ref8) => { | ||
var { | ||
@@ -696,13 +679,61 @@ root, | ||
} = _ref8; | ||
this.writeAttachmentForItem(message.data, step !== null && step !== void 0 ? step : root); | ||
var item = step !== null && step !== void 0 ? step : root; | ||
var { | ||
name, | ||
content, | ||
encoding, | ||
contentType, | ||
fileExtension, | ||
wrapInStep | ||
} = message.data; | ||
this.writeAttachmentForItem(name, Buffer.from(content, encoding), { | ||
contentType, | ||
fileExtension | ||
}, item, wrapInStep); | ||
}); | ||
_defineProperty(this, "writeAttachmentForItem", (attachment, item) => { | ||
var attachmentFilename = this.buildAttachmentFileName(attachment); | ||
this.writer.writeAttachment(attachmentFilename, attachment.content, attachment.encoding || "base64"); | ||
var rawAttachment = { | ||
name: attachment.name, | ||
source: attachmentFilename, | ||
type: attachment.contentType | ||
_defineProperty(this, "handleAttachmentPathMessage", (message, _ref9) => { | ||
var { | ||
root, | ||
step | ||
} = _ref9; | ||
var item = step !== null && step !== void 0 ? step : root; | ||
var { | ||
name, | ||
path, | ||
contentType, | ||
fileExtension, | ||
wrapInStep | ||
} = message.data; | ||
this.writeAttachmentForItem(name, path, { | ||
contentType, | ||
fileExtension | ||
}, item, wrapInStep); | ||
}); | ||
_defineProperty(this, "writeAttachmentForItem", function (attachmentName, attachmentContentOrPath, options, item) { | ||
var _options$fileExtensio; | ||
var wrapInStepAttachment = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; | ||
var isPath = typeof attachmentContentOrPath === "string"; | ||
var fileExtension = (_options$fileExtensio = options.fileExtension) !== null && _options$fileExtensio !== void 0 ? _options$fileExtensio : isPath ? (0, _path.extname)(attachmentContentOrPath) : undefined; | ||
var attachmentFileName = (0, _attachments.buildAttachmentFileName)({ | ||
contentType: options.contentType, | ||
fileExtension | ||
}); | ||
if (isPath) { | ||
_this.writer.writeAttachmentFromPath(attachmentFileName, attachmentContentOrPath); | ||
} else { | ||
_this.writer.writeAttachment(attachmentFileName, attachmentContentOrPath); | ||
} | ||
var attachment = { | ||
name: attachmentName, | ||
source: attachmentFileName, | ||
type: options.contentType | ||
}; | ||
item.attachments.push(rawAttachment); | ||
if (wrapInStepAttachment) { | ||
item.steps.push({ | ||
name: attachmentName, | ||
attachments: [attachment] | ||
}); | ||
} else { | ||
item.attachments.push(attachment); | ||
} | ||
}); | ||
@@ -748,6 +779,6 @@ _defineProperty(this, "startScopeWithUuid", function (uuid) { | ||
}); | ||
_defineProperty(this, "removeFixtureFromScope", (_ref9, wrappedFixture) => { | ||
_defineProperty(this, "removeFixtureFromScope", (_ref10, wrappedFixture) => { | ||
var { | ||
fixtures | ||
} = _ref9; | ||
} = _ref10; | ||
var fixtureIndex = fixtures.indexOf(wrappedFixture); | ||
@@ -802,7 +833,7 @@ if (fixtureIndex !== -1) { | ||
}); | ||
_defineProperty(this, "writeFixturesOfScope", _ref10 => { | ||
_defineProperty(this, "writeFixturesOfScope", _ref11 => { | ||
var { | ||
fixtures, | ||
tests | ||
} = _ref10; | ||
} = _ref11; | ||
var writtenFixtures = new Set(); | ||
@@ -858,6 +889,6 @@ if (tests.length) { | ||
// @ts-ignore | ||
var matcher = (_this$links = this.links) === null || _this$links === void 0 || (_this$links$find = _this$links.find) === null || _this$links$find === void 0 ? void 0 : _this$links$find.call(_this$links, _ref11 => { | ||
var matcher = (_this$links = this.links) === null || _this$links === void 0 || (_this$links$find = _this$links.find) === null || _this$links$find === void 0 ? void 0 : _this$links$find.call(_this$links, _ref12 => { | ||
var { | ||
type | ||
} = _ref11; | ||
} = _ref12; | ||
return type === link.type; | ||
@@ -899,3 +930,3 @@ }); | ||
}); | ||
this.writer = (0, _utils.resolveWriter)(this.getWellKnownWriters(), writer); | ||
this.writer = (0, _loader.resolveWriter)(writer); | ||
this.notifier = new _Notifier.Notifier({ | ||
@@ -912,11 +943,7 @@ listeners | ||
return _objectSpread(_objectSpread({}, (0, _factory.createTestResult)(uuid)), {}, { | ||
start: Date.now(), | ||
labels: (0, _utils.getGlobalLabels)() | ||
start: Date.now() | ||
}, (0, _utils.deepClone)(result)); | ||
} | ||
getWellKnownWriters() { | ||
return wellKnownCommonWriters; | ||
} | ||
} | ||
exports.ReporterRuntime = ReporterRuntime; | ||
//# sourceMappingURL=ReporterRuntime.js.map |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.writeAttachment = exports.typeToExtension = exports.stringifyProperties = exports.serialize = exports.resolveWriter = exports.readImageAsBase64 = exports.randomUuid = exports.parseProperties = exports.md5 = exports.getWorstStepResultStatusPriority = exports.getWorstStepResultStatus = exports.getTestResultTestCaseId = exports.getTestResultHistoryId = exports.getSuitesLabels = exports.getSuiteLabels = exports.getRelativePath = exports.getPackageLabelFromPath = exports.getGlobalLabels = exports.escapeRegExp = exports.ensureSuiteLabels = exports.deepClone = void 0; | ||
exports.stringifyProperties = exports.serialize = exports.readImageAsBase64 = exports.randomUuid = exports.parseProperties = exports.md5 = exports.getWorstStepResultStatusPriority = exports.getWorstStepResultStatus = exports.getTestResultTestCaseId = exports.getTestResultHistoryId = exports.getSuiteLabels = exports.getRelativePath = exports.getPackageLabelFromPath = exports.escapeRegExp = exports.ensureSuiteLabels = exports.deepClone = void 0; | ||
var _promises = require("fs/promises"); | ||
@@ -13,6 +13,4 @@ var _nodeCrypto = require("node:crypto"); | ||
var _nodeProcess = _interopRequireDefault(require("node:process")); | ||
var _process = require("process"); | ||
var _properties = _interopRequireDefault(require("properties")); | ||
var _model = require("../../model.js"); | ||
var _extensions = require("./extensions.js"); | ||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } | ||
@@ -29,12 +27,2 @@ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); } | ||
exports.md5 = md5; | ||
var writeAttachment = (uuid, options) => { | ||
if (typeof options === "string") { | ||
options = { | ||
contentType: options | ||
}; | ||
} | ||
var extension = typeToExtension(options); | ||
return "".concat(uuid, "-attachment").concat(extension); | ||
}; | ||
exports.writeAttachment = writeAttachment; | ||
var getTestResultHistoryId = result => { | ||
@@ -110,37 +98,2 @@ var _result$testCaseId; | ||
}(); | ||
var resolveWriter = (wellKnownWriters, value) => { | ||
if (typeof value === "string") { | ||
return createWriter(wellKnownWriters, value); | ||
} else if (value instanceof Array) { | ||
return createWriter(wellKnownWriters, value[0], value.slice(1)); | ||
} | ||
return value; | ||
}; | ||
exports.resolveWriter = resolveWriter; | ||
var createWriter = function createWriter(wellKnownWriters, nameOrPath) { | ||
var _getKnownWriterCtor; | ||
var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; | ||
// eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires | ||
var ctorOrInstance = (_getKnownWriterCtor = getKnownWriterCtor(wellKnownWriters, nameOrPath)) !== null && _getKnownWriterCtor !== void 0 ? _getKnownWriterCtor : requireWriterCtor(nameOrPath); | ||
return typeof ctorOrInstance === "function" ? new ctorOrInstance(...args) : ctorOrInstance; | ||
}; | ||
var getKnownWriterCtor = (wellKnownWriters, name) => wellKnownWriters[name]; | ||
var requireWriterCtor = modulePath => { | ||
// eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires | ||
return require(modulePath); | ||
}; | ||
var getGlobalLabels = () => { | ||
var _globalLabels; | ||
var ENV_NAME_PREFIX = "ALLURE_LABEL_"; | ||
var globalLabels; | ||
var initGlobalLabels = () => Object.keys(_process.env).filter(varname => varname.startsWith(ENV_NAME_PREFIX)).map(varname => { | ||
var _env$varname; | ||
return { | ||
name: varname.substring(ENV_NAME_PREFIX.length), | ||
value: (_env$varname = _process.env[varname]) !== null && _env$varname !== void 0 ? _env$varname : "" | ||
}; | ||
}).filter(l => l.name && l.value); | ||
return (_globalLabels = globalLabels) !== null && _globalLabels !== void 0 ? _globalLabels : globalLabels = initGlobalLabels(); | ||
}; | ||
exports.getGlobalLabels = getGlobalLabels; | ||
var getProjectRoot = (() => { | ||
@@ -188,9 +141,2 @@ var cachedProjectRoot = null; | ||
exports.deepClone = deepClone; | ||
var typeToExtension = options => { | ||
if (options.fileExtension) { | ||
return options.fileExtension.startsWith(".") ? options.fileExtension : ".".concat(options.fileExtension); | ||
} | ||
return _extensions.EXTENSIONS_BY_TYPE[options.contentType] || ""; | ||
}; | ||
exports.typeToExtension = typeToExtension; | ||
var serialize = val => { | ||
@@ -233,3 +179,2 @@ if (typeof val === "object" && !(val instanceof Map || val instanceof Set)) { | ||
exports.getSuiteLabels = getSuiteLabels; | ||
var getSuitesLabels = exports.getSuitesLabels = getSuiteLabels; | ||
var suiteLabelNames = [_model.LabelName.PARENT_SUITE, _model.LabelName.SUITE, _model.LabelName.SUB_SUITE]; | ||
@@ -236,0 +181,0 @@ var ensureSuiteLabels = (test, defaultSuites) => { |
@@ -11,3 +11,3 @@ "use strict"; | ||
var writeJson = (path, data) => { | ||
(0, _nodeFs.writeFileSync)(path, JSON.stringify(data), "utf8"); | ||
(0, _nodeFs.writeFileSync)(path, JSON.stringify(data), "utf-8"); | ||
}; | ||
@@ -19,7 +19,6 @@ class FileSystemWriter { | ||
writeAttachment(distFileName, content) { | ||
var encoding = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "utf-8"; | ||
var path = this.buildPath(distFileName); | ||
(0, _nodeFs.writeFileSync)(path, content, encoding); | ||
(0, _nodeFs.writeFileSync)(path, content, "utf-8"); | ||
} | ||
writeAttachmentFromPath(from, distFileName) { | ||
writeAttachmentFromPath(distFileName, from) { | ||
var to = this.buildPath(distFileName); | ||
@@ -48,7 +47,5 @@ (0, _nodeFs.copyFileSync)(from, to); | ||
buildPath(name) { | ||
if (!(0, _nodeFs.existsSync)(this.config.resultsDir)) { | ||
(0, _nodeFs.mkdirSync)(this.config.resultsDir, { | ||
recursive: true | ||
}); | ||
} | ||
(0, _nodeFs.mkdirSync)(this.config.resultsDir, { | ||
recursive: true | ||
}); | ||
return (0, _nodePath.join)(this.config.resultsDir, name); | ||
@@ -55,0 +52,0 @@ } |
@@ -28,46 +28,13 @@ "use strict"; | ||
} | ||
writeAttachmentFromPath(fromFilePath, distFileName) { | ||
this.attachments[distFileName] = (0, _fs.readFileSync)(fromFilePath); | ||
writeAttachmentFromPath(distFileName, from) { | ||
this.attachments[distFileName] = (0, _fs.readFileSync)(from); | ||
} | ||
writeCategoriesDefinitions(categories) { | ||
if (this.categories) { | ||
// eslint-disable-next-line no-console | ||
console.warn("overwriting existing categories"); | ||
} | ||
this.categories = categories; | ||
} | ||
writeEnvironmentInfo(envInfo) { | ||
if (this.envInfo) { | ||
// eslint-disable-next-line no-console | ||
console.warn("overwriting existing environment info"); | ||
} | ||
this.envInfo = envInfo; | ||
} | ||
reset() { | ||
this.groups = []; | ||
this.tests = []; | ||
this.attachments = {}; | ||
} | ||
getMaybeTestByName(name) { | ||
return this.tests.find(t => t.name === name); | ||
} | ||
getTestByName(name) { | ||
var res = this.getMaybeTestByName(name); | ||
if (!res) { | ||
throw new Error("Test not found: ".concat(name)); | ||
} | ||
return res; | ||
} | ||
getMaybeGroupByName(name) { | ||
return this.groups.find(g => g.name === name); | ||
} | ||
getGroupByName(name) { | ||
var res = this.getMaybeGroupByName(name); | ||
if (!res) { | ||
throw new Error("Group not found: ".concat(name)); | ||
} | ||
return res; | ||
} | ||
} | ||
exports.InMemoryWriter = InMemoryWriter; | ||
//# sourceMappingURL=InMemoryWriter.js.map |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.MessageWriter = exports.MessageReader = void 0; | ||
exports.MessageWriter = void 0; | ||
var _fs = require("fs"); | ||
@@ -12,5 +12,2 @@ var _process = _interopRequireDefault(require("process")); | ||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } | ||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } | ||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } | ||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } | ||
class MessageWriter { | ||
@@ -34,9 +31,8 @@ constructor(bus) { | ||
writeJson(path, type, data) { | ||
this.sendData(path, type, Buffer.from(JSON.stringify(data))); | ||
this.sendData(path, type, Buffer.from(JSON.stringify(data), "utf-8")); | ||
} | ||
writeAttachment(distFileName, content) { | ||
var encoding = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "utf-8"; | ||
this.sendData(distFileName, "attachment", typeof content === "string" ? Buffer.from(content, encoding) : content); | ||
this.sendData(distFileName, "attachment", content); | ||
} | ||
writeAttachmentFromPath(from, distFileName) { | ||
writeAttachmentFromPath(distFileName, from) { | ||
this.sendData(distFileName, "attachment", (0, _fs.readFileSync)(from)); | ||
@@ -48,3 +44,3 @@ } | ||
}).toString(); | ||
this.sendData("environment.properties", "misc", Buffer.from(text)); | ||
this.sendData("environment.properties", "misc", Buffer.from(text, "utf-8")); | ||
} | ||
@@ -62,47 +58,2 @@ writeCategoriesDefinitions(categories) { | ||
exports.MessageWriter = MessageWriter; | ||
var parseJsonResult = data => { | ||
return JSON.parse(Buffer.from(data, "base64").toString("utf8")); | ||
}; | ||
class MessageReader { | ||
constructor() { | ||
_defineProperty(this, "results", { | ||
tests: [], | ||
groups: [], | ||
attachments: {} | ||
}); | ||
_defineProperty(this, "handleMessage", jsonMessage => { | ||
var { | ||
path, | ||
type = "undefined", | ||
data | ||
} = JSON.parse(jsonMessage); | ||
switch (type) { | ||
case "container": | ||
this.results.groups.push(parseJsonResult(data)); | ||
return; | ||
case "result": | ||
this.results.tests.push(parseJsonResult(data)); | ||
return; | ||
case "attachment": | ||
this.results.attachments[path] = data; | ||
return; | ||
case "misc": | ||
switch (path) { | ||
case "environment.properties": | ||
this.results.envInfo = (0, _utils.parseProperties)(Buffer.from(data, "base64").toString()); | ||
break; | ||
case "categories.json": | ||
this.results.categories = parseJsonResult(data); | ||
break; | ||
default: | ||
break; | ||
} | ||
return; | ||
default: | ||
return; | ||
} | ||
}); | ||
} | ||
} | ||
exports.MessageReader = MessageReader; | ||
//# sourceMappingURL=MessageWriter.js.map |
@@ -145,12 +145,15 @@ "use strict"; | ||
} | ||
attachment(name, content, type) { | ||
attachment(name, content, options) { | ||
var _this11 = this; | ||
return _asyncToGenerator(function* () { | ||
var bufferContent = typeof content === "string" ? Buffer.from(content, options.encoding) : content; | ||
yield _this11.sendMessage({ | ||
type: "raw_attachment", | ||
type: "attachment_content", | ||
data: { | ||
name, | ||
content: Buffer.from(content).toString("base64"), | ||
contentType: type, | ||
encoding: "base64" | ||
content: bufferContent.toString("base64"), | ||
encoding: "base64", | ||
contentType: options.contentType, | ||
fileExtension: options.fileExtension, | ||
wrapInStep: true | ||
} | ||
@@ -160,6 +163,21 @@ }); | ||
} | ||
step(name, body) { | ||
attachmentFromPath(name, path, options) { | ||
var _this12 = this; | ||
return _asyncToGenerator(function* () { | ||
yield _this12.sendMessage({ | ||
type: "attachment_path", | ||
data: { | ||
name, | ||
path, | ||
contentType: options.contentType, | ||
fileExtension: options.fileExtension, | ||
wrapInStep: true | ||
} | ||
}); | ||
})(); | ||
} | ||
step(name, body) { | ||
var _this13 = this; | ||
return _asyncToGenerator(function* () { | ||
yield _this13.sendMessage({ | ||
type: "step_start", | ||
@@ -173,3 +191,3 @@ data: { | ||
var result = yield body(); | ||
yield _this12.sendMessage({ | ||
yield _this13.sendMessage({ | ||
type: "step_stop", | ||
@@ -188,3 +206,3 @@ data: { | ||
} = err; | ||
yield _this12.sendMessage({ | ||
yield _this13.sendMessage({ | ||
type: "step_stop", | ||
@@ -206,5 +224,5 @@ data: { | ||
stepDisplayName(name) { | ||
var _this13 = this; | ||
var _this14 = this; | ||
return _asyncToGenerator(function* () { | ||
yield _this13.sendMessage({ | ||
yield _this14.sendMessage({ | ||
type: "step_metadata", | ||
@@ -218,5 +236,5 @@ data: { | ||
stepParameter(name, value, mode) { | ||
var _this14 = this; | ||
var _this15 = this; | ||
return _asyncToGenerator(function* () { | ||
yield _this14.sendMessage({ | ||
yield _this15.sendMessage({ | ||
type: "step_metadata", | ||
@@ -223,0 +241,0 @@ data: { |
@@ -16,3 +16,3 @@ "use strict"; | ||
} | ||
description() { | ||
attachmentFromPath() { | ||
var _this2 = this; | ||
@@ -23,3 +23,3 @@ return _asyncToGenerator(function* () { | ||
} | ||
descriptionHtml() { | ||
description() { | ||
var _this3 = this; | ||
@@ -30,3 +30,3 @@ return _asyncToGenerator(function* () { | ||
} | ||
displayName() { | ||
descriptionHtml() { | ||
var _this4 = this; | ||
@@ -37,3 +37,3 @@ return _asyncToGenerator(function* () { | ||
} | ||
historyId() { | ||
displayName() { | ||
var _this5 = this; | ||
@@ -44,3 +44,3 @@ return _asyncToGenerator(function* () { | ||
} | ||
labels() { | ||
historyId() { | ||
var _this6 = this; | ||
@@ -51,3 +51,3 @@ return _asyncToGenerator(function* () { | ||
} | ||
links() { | ||
labels() { | ||
var _this7 = this; | ||
@@ -58,3 +58,3 @@ return _asyncToGenerator(function* () { | ||
} | ||
parameter() { | ||
links() { | ||
var _this8 = this; | ||
@@ -65,16 +65,16 @@ return _asyncToGenerator(function* () { | ||
} | ||
step(name, body) { | ||
parameter() { | ||
var _this9 = this; | ||
return _asyncToGenerator(function* () { | ||
yield _this9.warning(); | ||
return body(); | ||
})(); | ||
} | ||
stepDisplayName() { | ||
step(name, body) { | ||
var _this10 = this; | ||
return _asyncToGenerator(function* () { | ||
yield _this10.warning(); | ||
return body(); | ||
})(); | ||
} | ||
stepParameter() { | ||
stepDisplayName() { | ||
var _this11 = this; | ||
@@ -85,3 +85,3 @@ return _asyncToGenerator(function* () { | ||
} | ||
testCaseId() { | ||
stepParameter() { | ||
var _this12 = this; | ||
@@ -92,2 +92,8 @@ return _asyncToGenerator(function* () { | ||
} | ||
testCaseId() { | ||
var _this13 = this; | ||
return _asyncToGenerator(function* () { | ||
yield _this13.warning(); | ||
})(); | ||
} | ||
@@ -94,0 +100,0 @@ // eslint-disable-next-line @typescript-eslint/require-await |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.stripAnsi = exports.isPromise = exports.isAnyStepFailed = exports.isAllStepsEnded = exports.hasStepMessage = exports.hasLabel = exports.getUnfinishedStepsMessages = exports.getStepsMessagesPair = exports.getStatusFromError = exports.getMessageAndTraceFromError = exports.extractMetadataFromString = exports.ansiRegex = exports.allureLabelRegexpGlobal = exports.allureLabelRegexp = exports.allureIdRegexpGlobal = exports.allureIdRegexp = void 0; | ||
exports.stripAnsi = exports.isPromise = exports.isAnyStepFailed = exports.isAllStepsEnded = exports.hasStepMessage = exports.hasLabel = exports.getUnfinishedStepsMessages = exports.getStepsMessagesPair = exports.getStatusFromError = exports.getMessageAndTraceFromError = exports.extractMetadataFromString = exports.allureLabelRegexpGlobal = exports.allureLabelRegexp = exports.allureIdRegexpGlobal = exports.allureIdRegexp = void 0; | ||
var _model = require("../model.js"); | ||
@@ -33,3 +33,3 @@ function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(e, r) { return new BabelRegExp(e, void 0, r); }; var e = RegExp.prototype, r = new WeakMap(); function BabelRegExp(e, t, p) { var o = RegExp(e, t); return r.set(o, p || r.get(e)), _setPrototypeOf(o, BabelRegExp.prototype); } function buildGroups(e, t) { var p = r.get(t); return Object.keys(p).reduce(function (r, t) { var o = p[t]; if ("number" == typeof o) r[t] = e[o];else { for (var i = 0; void 0 === e[o[i]] && i + 1 < o.length;) i++; r[t] = e[o[i]]; } return r; }, Object.create(null)); } return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (r) { var t = e.exec.call(this, r); if (t) { t.groups = buildGroups(t, this); var p = t.indices; p && (p.groups = buildGroups(p, this)); } return t; }, BabelRegExp.prototype[Symbol.replace] = function (t, p) { if ("string" == typeof p) { var o = r.get(this); return e[Symbol.replace].call(this, t, p.replace(/\$<([^>]+)>/g, function (e, r) { var t = o[r]; return "$" + (Array.isArray(t) ? t.join("$") : t); })); } if ("function" == typeof p) { var i = this; return e[Symbol.replace].call(this, t, function () { var e = arguments; return "object" != typeof e[e.length - 1] && (e = [].slice.call(e)).push(buildGroups(e, i)), p.apply(this, e); }); } return e[Symbol.replace].call(this, t, p); }, _wrapRegExp.apply(this, arguments); } | ||
exports.getStatusFromError = getStatusFromError; | ||
var ansiRegex = exports.ansiRegex = function ansiRegex() { | ||
var ansiRegex = function ansiRegex() { | ||
var { | ||
@@ -46,5 +46,2 @@ onlyFirst = false | ||
var stripAnsi = str => { | ||
if (typeof str !== "string") { | ||
throw new TypeError("Expected a `string`, got `".concat(typeof str, "`")); | ||
} | ||
var regex = ansiRegex(); | ||
@@ -51,0 +48,0 @@ return str.replace(regex, ""); |
import { LabelName, LinkType } from "./model.js"; | ||
import { getGlobalTestRuntimeWithAutoconfig } from "./sdk/runtime/runtime.js"; | ||
import { isPromise } from "./sdk/utils.js"; | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
var callRuntimeMethod = function callRuntimeMethod(method) { | ||
@@ -23,9 +26,2 @@ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
}); | ||
// const runtime = getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// if (!isPromise(runtime)) { | ||
// return (runtime as TestRuntime).labels({ name, value }); | ||
// } | ||
// | ||
// return (runtime as Promise<TestRuntime>).then((testRuntime) => testRuntime.labels({ name, value })); | ||
}; | ||
@@ -36,11 +32,5 @@ export var labels = function labels() { | ||
} | ||
// const runtime = await getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// return runtime.labels(...labelsList); | ||
return callRuntimeMethod("labels", ...labelsList); | ||
}; | ||
export var link = (url, type, name) => { | ||
// const runtime = await getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// return runtime.links({ url, type, name }); | ||
export var link = (url, name, type) => { | ||
return callRuntimeMethod("links", { | ||
@@ -56,56 +46,39 @@ url, | ||
} | ||
// const runtime = await getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// return runtime.links(...linksList); | ||
return callRuntimeMethod("links", ...linksList); | ||
}; | ||
export var parameter = (name, value, options) => { | ||
// const runtime = await getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// return runtime.parameter(name, value, options); | ||
return callRuntimeMethod("parameter", name, value, options); | ||
}; | ||
export var description = markdown => { | ||
// const runtime = await getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// return runtime.description(markdown); | ||
return callRuntimeMethod("description", markdown); | ||
}; | ||
export var descriptionHtml = html => { | ||
// const runtime = await getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// return runtime.descriptionHtml(html); | ||
return callRuntimeMethod("descriptionHtml", html); | ||
}; | ||
export var displayName = name => { | ||
// const runtime = await getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// return runtime.displayName(name); | ||
return callRuntimeMethod("displayName", name); | ||
}; | ||
export var historyId = value => { | ||
// const runtime = await getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// return runtime.historyId(value); | ||
return callRuntimeMethod("historyId", value); | ||
}; | ||
export var testCaseId = value => { | ||
// const runtime = await getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// return runtime.testCaseId(value); | ||
return callRuntimeMethod("testCaseId", value); | ||
}; | ||
export var attachment = (name, content, type) => { | ||
// const runtime = await getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// return runtime.attachment(name, content, type); | ||
return callRuntimeMethod("attachment", name, content, type); | ||
export var attachment = (name, content, options) => { | ||
var opts = typeof options === "string" ? { | ||
contentType: options | ||
} : options; | ||
return callRuntimeMethod("attachment", name, content, opts); | ||
}; | ||
export var attachmentPath = (name, path, options) => { | ||
var opts = typeof options === "string" ? { | ||
contentType: options | ||
} : options; | ||
return callRuntimeMethod("attachmentFromPath", name, path, opts); | ||
}; | ||
var stepContext = () => ({ | ||
displayName: name => { | ||
// return runtime.stepDisplayName(name); | ||
return callRuntimeMethod("stepDisplayName", name); | ||
}, | ||
parameter: (name, value, mode) => { | ||
// return runtime.stepParameter(name, value, mode); | ||
return callRuntimeMethod("stepParameter", name, value, mode); | ||
@@ -115,10 +88,6 @@ } | ||
export var step = (name, body) => { | ||
// throw new Error("Not implemented"); | ||
// const runtime = await getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// return runtime.step(name, () => body(stepContext(runtime))); | ||
return callRuntimeMethod("step", name, () => body(stepContext())); | ||
}; | ||
export var issue = (url, name) => link(url, LinkType.ISSUE, name); | ||
export var tms = (url, name) => link(url, LinkType.TMS, name); | ||
export var issue = (url, name) => link(url, name, LinkType.ISSUE); | ||
export var tms = (url, name) => link(url, name, LinkType.TMS); | ||
export var allureId = value => label(LabelName.ALLURE_ID, value); | ||
@@ -139,5 +108,2 @@ export var epic = name => label(LabelName.EPIC, name); | ||
} | ||
// const runtime = await getGlobalTestRuntimeWithAutoconfig(); | ||
// | ||
// return runtime.labels(...tagsList.map((value) => ({ name: LabelName.TAG, value }))); | ||
return callRuntimeMethod("labels", ...tagsList.map(value => ({ | ||
@@ -144,0 +110,0 @@ name: LabelName.TAG, |
@@ -9,4 +9,5 @@ export { ALLURE_METADATA_CONTENT_TYPE, ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE, ALLURE_SKIPPED_BY_TEST_PLAN_LABEL } from "./types.js"; | ||
export { FileSystemWriter } from "./writer/FileSystemWriter.js"; | ||
export { MessageWriter, MessageReader } from "./writer/MessageWriter.js"; | ||
export { MessageWriter } from "./writer/MessageWriter.js"; | ||
export { MessageReader } from "./writer/MessageReader.js"; | ||
export { getEnvironmentLabels, getHostLabel, getThreadLabel } from "./utils/labels.js"; | ||
//# sourceMappingURL=index.js.map |
@@ -22,4 +22,4 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } | ||
_defineProperty(this, "getExecutionItem", uuid => { | ||
var _ref, _this$fixturesResults, _this$fixturesResults2; | ||
return (_ref = (_this$fixturesResults = (_this$fixturesResults2 = this.fixturesResults.get(uuid)) === null || _this$fixturesResults2 === void 0 ? void 0 : _this$fixturesResults2.value) !== null && _this$fixturesResults !== void 0 ? _this$fixturesResults : this.testResults.get(uuid)) !== null && _ref !== void 0 ? _ref : this.stepResults.get(uuid); | ||
var _ref, _this$getFixture; | ||
return (_ref = (_this$getFixture = this.getFixture(uuid)) !== null && _this$getFixture !== void 0 ? _this$getFixture : this.getTest(uuid)) !== null && _ref !== void 0 ? _ref : this.getStep(uuid); | ||
}); | ||
@@ -26,0 +26,0 @@ // test results |
@@ -17,5 +17,6 @@ var _excluded = ["links", "attachments", "displayName", "parameters", "labels"], | ||
import { createFixtureResult, createStepResult, createTestResult } from "./factory.js"; | ||
import { deepClone, getGlobalLabels, randomUuid, typeToExtension } from "./utils.js"; | ||
import { getTestResultHistoryId, getTestResultTestCaseId, resolveWriter } from "./utils.js"; | ||
import * as wellKnownCommonWriters from "./writer/wellKnownCommonWriters.js"; | ||
import { deepClone, randomUuid } from "./utils.js"; | ||
import { getTestResultHistoryId, getTestResultTestCaseId } from "./utils.js"; | ||
import { buildAttachmentFileName } from "./utils/attachments.js"; | ||
import { resolveWriter } from "./writer/loader.js"; | ||
export class ReporterRuntime { | ||
@@ -463,26 +464,17 @@ constructor(_ref) { | ||
}); | ||
_defineProperty(this, "buildAttachmentFileName", options => { | ||
var attachmentUuid = randomUuid(); | ||
var attachmentExtension = typeToExtension({ | ||
fileExtension: options.fileExtension, | ||
contentType: options.contentType | ||
}); | ||
return "".concat(attachmentUuid, "-attachment").concat(attachmentExtension); | ||
}); | ||
_defineProperty(this, "writeAttachment", (attachment, uuid) => { | ||
var targetUuid = this.contextProvider.getExecutingItem(uuid); | ||
if (!targetUuid) { | ||
this.logMissingStepRoot(uuid, "attach"); | ||
_defineProperty(this, "writeAttachment", (attachmentName, attachmentContent, options, uuid) => { | ||
var target = this.getCurrentExecutingItem(uuid); | ||
if (!target) { | ||
if (uuid) { | ||
// eslint-disable-next-line no-console | ||
console.error("No test or fixture ".concat(uuid, " to attach!")); | ||
} else { | ||
// eslint-disable-next-line no-console | ||
console.error("No current test or fixture to attach!"); | ||
} | ||
return; | ||
} | ||
var targetResult = this.state.getExecutionItem(targetUuid); | ||
if (!targetResult) { | ||
// eslint-disable-next-line no-console | ||
console.error("No test, fixture, or step ".concat(targetUuid, " to attach!")); | ||
return; | ||
} | ||
this.writeAttachmentForItem(attachment, targetResult); | ||
this.writeAttachmentForItem(attachmentName, attachmentContent, options, target); | ||
}); | ||
_defineProperty(this, "writeAttachmentFromPath", (attachmentName, attachmentPath, options, uuid) => { | ||
var _options$fileExtensio; | ||
var target = this.getCurrentExecutingItem(uuid); | ||
@@ -499,13 +491,3 @@ if (!target) { | ||
} | ||
var attachmentFilename = this.buildAttachmentFileName(_objectSpread(_objectSpread({}, options), {}, { | ||
fileExtension: (_options$fileExtensio = options.fileExtension) !== null && _options$fileExtensio !== void 0 ? _options$fileExtensio : extname(attachmentPath) | ||
})); | ||
this.writer.writeAttachmentFromPath(attachmentPath, attachmentFilename); | ||
var rawAttachment = { | ||
name: attachmentName, | ||
source: attachmentFilename, | ||
type: options.contentType | ||
}; | ||
target.attachments.push(rawAttachment); | ||
return attachmentFilename; | ||
this.writeAttachmentForItem(attachmentName, attachmentPath, options, target); | ||
}); | ||
@@ -588,5 +570,8 @@ _defineProperty(this, "writeEnvironmentInfo", () => { | ||
return; | ||
case "raw_attachment": | ||
this.handleRawAttachmentMessage(message, targets); | ||
case "attachment_content": | ||
this.handleAttachmentContentMessage(message, targets); | ||
return; | ||
case "attachment_path": | ||
this.handleAttachmentPathMessage(message, targets); | ||
return; | ||
default: | ||
@@ -684,3 +669,3 @@ return message; | ||
}); | ||
_defineProperty(this, "handleRawAttachmentMessage", (message, _ref8) => { | ||
_defineProperty(this, "handleAttachmentContentMessage", (message, _ref8) => { | ||
var { | ||
@@ -690,13 +675,61 @@ root, | ||
} = _ref8; | ||
this.writeAttachmentForItem(message.data, step !== null && step !== void 0 ? step : root); | ||
var item = step !== null && step !== void 0 ? step : root; | ||
var { | ||
name, | ||
content, | ||
encoding, | ||
contentType, | ||
fileExtension, | ||
wrapInStep | ||
} = message.data; | ||
this.writeAttachmentForItem(name, Buffer.from(content, encoding), { | ||
contentType, | ||
fileExtension | ||
}, item, wrapInStep); | ||
}); | ||
_defineProperty(this, "writeAttachmentForItem", (attachment, item) => { | ||
var attachmentFilename = this.buildAttachmentFileName(attachment); | ||
this.writer.writeAttachment(attachmentFilename, attachment.content, attachment.encoding || "base64"); | ||
var rawAttachment = { | ||
name: attachment.name, | ||
source: attachmentFilename, | ||
type: attachment.contentType | ||
_defineProperty(this, "handleAttachmentPathMessage", (message, _ref9) => { | ||
var { | ||
root, | ||
step | ||
} = _ref9; | ||
var item = step !== null && step !== void 0 ? step : root; | ||
var { | ||
name, | ||
path, | ||
contentType, | ||
fileExtension, | ||
wrapInStep | ||
} = message.data; | ||
this.writeAttachmentForItem(name, path, { | ||
contentType, | ||
fileExtension | ||
}, item, wrapInStep); | ||
}); | ||
_defineProperty(this, "writeAttachmentForItem", function (attachmentName, attachmentContentOrPath, options, item) { | ||
var _options$fileExtensio; | ||
var wrapInStepAttachment = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; | ||
var isPath = typeof attachmentContentOrPath === "string"; | ||
var fileExtension = (_options$fileExtensio = options.fileExtension) !== null && _options$fileExtensio !== void 0 ? _options$fileExtensio : isPath ? extname(attachmentContentOrPath) : undefined; | ||
var attachmentFileName = buildAttachmentFileName({ | ||
contentType: options.contentType, | ||
fileExtension | ||
}); | ||
if (isPath) { | ||
_this.writer.writeAttachmentFromPath(attachmentFileName, attachmentContentOrPath); | ||
} else { | ||
_this.writer.writeAttachment(attachmentFileName, attachmentContentOrPath); | ||
} | ||
var attachment = { | ||
name: attachmentName, | ||
source: attachmentFileName, | ||
type: options.contentType | ||
}; | ||
item.attachments.push(rawAttachment); | ||
if (wrapInStepAttachment) { | ||
item.steps.push({ | ||
name: attachmentName, | ||
attachments: [attachment] | ||
}); | ||
} else { | ||
item.attachments.push(attachment); | ||
} | ||
}); | ||
@@ -742,6 +775,6 @@ _defineProperty(this, "startScopeWithUuid", function (uuid) { | ||
}); | ||
_defineProperty(this, "removeFixtureFromScope", (_ref9, wrappedFixture) => { | ||
_defineProperty(this, "removeFixtureFromScope", (_ref10, wrappedFixture) => { | ||
var { | ||
fixtures | ||
} = _ref9; | ||
} = _ref10; | ||
var fixtureIndex = fixtures.indexOf(wrappedFixture); | ||
@@ -796,7 +829,7 @@ if (fixtureIndex !== -1) { | ||
}); | ||
_defineProperty(this, "writeFixturesOfScope", _ref10 => { | ||
_defineProperty(this, "writeFixturesOfScope", _ref11 => { | ||
var { | ||
fixtures, | ||
tests | ||
} = _ref10; | ||
} = _ref11; | ||
var writtenFixtures = new Set(); | ||
@@ -852,6 +885,6 @@ if (tests.length) { | ||
// @ts-ignore | ||
var matcher = (_this$links = this.links) === null || _this$links === void 0 || (_this$links$find = _this$links.find) === null || _this$links$find === void 0 ? void 0 : _this$links$find.call(_this$links, _ref11 => { | ||
var matcher = (_this$links = this.links) === null || _this$links === void 0 || (_this$links$find = _this$links.find) === null || _this$links$find === void 0 ? void 0 : _this$links$find.call(_this$links, _ref12 => { | ||
var { | ||
type | ||
} = _ref11; | ||
} = _ref12; | ||
return type === link.type; | ||
@@ -893,3 +926,3 @@ }); | ||
}); | ||
this.writer = resolveWriter(this.getWellKnownWriters(), writer); | ||
this.writer = resolveWriter(writer); | ||
this.notifier = new Notifier({ | ||
@@ -906,10 +939,6 @@ listeners | ||
return _objectSpread(_objectSpread({}, createTestResult(uuid)), {}, { | ||
start: Date.now(), | ||
labels: getGlobalLabels() | ||
start: Date.now() | ||
}, deepClone(result)); | ||
} | ||
getWellKnownWriters() { | ||
return wellKnownCommonWriters; | ||
} | ||
} | ||
//# sourceMappingURL=ReporterRuntime.js.map |
@@ -8,6 +8,4 @@ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); } | ||
import process from "node:process"; | ||
import { env } from "process"; | ||
import properties from "properties"; | ||
import { LabelName, StatusByPriority } from "../../model.js"; | ||
import { EXTENSIONS_BY_TYPE } from "./extensions.js"; | ||
export var randomUuid = () => { | ||
@@ -19,11 +17,2 @@ return randomUUID(); | ||
}; | ||
export var writeAttachment = (uuid, options) => { | ||
if (typeof options === "string") { | ||
options = { | ||
contentType: options | ||
}; | ||
} | ||
var extension = typeToExtension(options); | ||
return "".concat(uuid, "-attachment").concat(extension); | ||
}; | ||
export var getTestResultHistoryId = result => { | ||
@@ -95,35 +84,2 @@ var _result$testCaseId; | ||
}(); | ||
export var resolveWriter = (wellKnownWriters, value) => { | ||
if (typeof value === "string") { | ||
return createWriter(wellKnownWriters, value); | ||
} else if (value instanceof Array) { | ||
return createWriter(wellKnownWriters, value[0], value.slice(1)); | ||
} | ||
return value; | ||
}; | ||
var createWriter = function createWriter(wellKnownWriters, nameOrPath) { | ||
var _getKnownWriterCtor; | ||
var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; | ||
// eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires | ||
var ctorOrInstance = (_getKnownWriterCtor = getKnownWriterCtor(wellKnownWriters, nameOrPath)) !== null && _getKnownWriterCtor !== void 0 ? _getKnownWriterCtor : requireWriterCtor(nameOrPath); | ||
return typeof ctorOrInstance === "function" ? new ctorOrInstance(...args) : ctorOrInstance; | ||
}; | ||
var getKnownWriterCtor = (wellKnownWriters, name) => wellKnownWriters[name]; | ||
var requireWriterCtor = modulePath => { | ||
// eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires | ||
return require(modulePath); | ||
}; | ||
export var getGlobalLabels = () => { | ||
var _globalLabels; | ||
var ENV_NAME_PREFIX = "ALLURE_LABEL_"; | ||
var globalLabels; | ||
var initGlobalLabels = () => Object.keys(env).filter(varname => varname.startsWith(ENV_NAME_PREFIX)).map(varname => { | ||
var _env$varname; | ||
return { | ||
name: varname.substring(ENV_NAME_PREFIX.length), | ||
value: (_env$varname = env[varname]) !== null && _env$varname !== void 0 ? _env$varname : "" | ||
}; | ||
}).filter(l => l.name && l.value); | ||
return (_globalLabels = globalLabels) !== null && _globalLabels !== void 0 ? _globalLabels : globalLabels = initGlobalLabels(); | ||
}; | ||
var getProjectRoot = (() => { | ||
@@ -168,8 +124,2 @@ var cachedProjectRoot = null; | ||
export var deepClone = obj => JSON.parse(JSON.stringify(obj)); | ||
export var typeToExtension = options => { | ||
if (options.fileExtension) { | ||
return options.fileExtension.startsWith(".") ? options.fileExtension : ".".concat(options.fileExtension); | ||
} | ||
return EXTENSIONS_BY_TYPE[options.contentType] || ""; | ||
}; | ||
export var serialize = val => { | ||
@@ -210,3 +160,2 @@ if (typeof val === "object" && !(val instanceof Map || val instanceof Set)) { | ||
}; | ||
export var getSuitesLabels = getSuiteLabels; | ||
var suiteLabelNames = [LabelName.PARENT_SUITE, LabelName.SUITE, LabelName.SUB_SUITE]; | ||
@@ -213,0 +162,0 @@ export var ensureSuiteLabels = (test, defaultSuites) => { |
@@ -1,6 +0,6 @@ | ||
import { copyFileSync, existsSync, mkdirSync, writeFileSync } from "node:fs"; | ||
import { copyFileSync, mkdirSync, writeFileSync } from "node:fs"; | ||
import { join } from "node:path"; | ||
import { stringifyProperties } from "../utils.js"; | ||
var writeJson = (path, data) => { | ||
writeFileSync(path, JSON.stringify(data), "utf8"); | ||
writeFileSync(path, JSON.stringify(data), "utf-8"); | ||
}; | ||
@@ -12,7 +12,6 @@ export class FileSystemWriter { | ||
writeAttachment(distFileName, content) { | ||
var encoding = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "utf-8"; | ||
var path = this.buildPath(distFileName); | ||
writeFileSync(path, content, encoding); | ||
writeFileSync(path, content, "utf-8"); | ||
} | ||
writeAttachmentFromPath(from, distFileName) { | ||
writeAttachmentFromPath(distFileName, from) { | ||
var to = this.buildPath(distFileName); | ||
@@ -41,7 +40,5 @@ copyFileSync(from, to); | ||
buildPath(name) { | ||
if (!existsSync(this.config.resultsDir)) { | ||
mkdirSync(this.config.resultsDir, { | ||
recursive: true | ||
}); | ||
} | ||
mkdirSync(this.config.resultsDir, { | ||
recursive: true | ||
}); | ||
return join(this.config.resultsDir, name); | ||
@@ -48,0 +45,0 @@ } |
@@ -22,45 +22,12 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } | ||
} | ||
writeAttachmentFromPath(fromFilePath, distFileName) { | ||
this.attachments[distFileName] = readFileSync(fromFilePath); | ||
writeAttachmentFromPath(distFileName, from) { | ||
this.attachments[distFileName] = readFileSync(from); | ||
} | ||
writeCategoriesDefinitions(categories) { | ||
if (this.categories) { | ||
// eslint-disable-next-line no-console | ||
console.warn("overwriting existing categories"); | ||
} | ||
this.categories = categories; | ||
} | ||
writeEnvironmentInfo(envInfo) { | ||
if (this.envInfo) { | ||
// eslint-disable-next-line no-console | ||
console.warn("overwriting existing environment info"); | ||
} | ||
this.envInfo = envInfo; | ||
} | ||
reset() { | ||
this.groups = []; | ||
this.tests = []; | ||
this.attachments = {}; | ||
} | ||
getMaybeTestByName(name) { | ||
return this.tests.find(t => t.name === name); | ||
} | ||
getTestByName(name) { | ||
var res = this.getMaybeTestByName(name); | ||
if (!res) { | ||
throw new Error("Test not found: ".concat(name)); | ||
} | ||
return res; | ||
} | ||
getMaybeGroupByName(name) { | ||
return this.groups.find(g => g.name === name); | ||
} | ||
getGroupByName(name) { | ||
var res = this.getMaybeGroupByName(name); | ||
if (!res) { | ||
throw new Error("Group not found: ".concat(name)); | ||
} | ||
return res; | ||
} | ||
} | ||
//# sourceMappingURL=InMemoryWriter.js.map |
@@ -1,7 +0,4 @@ | ||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } | ||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } | ||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } | ||
import { readFileSync } from "fs"; | ||
import process from "process"; | ||
import { parseProperties, stringifyProperties } from "../utils.js"; | ||
import { stringifyProperties } from "../utils.js"; | ||
export class MessageWriter { | ||
@@ -25,9 +22,8 @@ constructor(bus) { | ||
writeJson(path, type, data) { | ||
this.sendData(path, type, Buffer.from(JSON.stringify(data))); | ||
this.sendData(path, type, Buffer.from(JSON.stringify(data), "utf-8")); | ||
} | ||
writeAttachment(distFileName, content) { | ||
var encoding = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "utf-8"; | ||
this.sendData(distFileName, "attachment", typeof content === "string" ? Buffer.from(content, encoding) : content); | ||
this.sendData(distFileName, "attachment", content); | ||
} | ||
writeAttachmentFromPath(from, distFileName) { | ||
writeAttachmentFromPath(distFileName, from) { | ||
this.sendData(distFileName, "attachment", readFileSync(from)); | ||
@@ -39,3 +35,3 @@ } | ||
}).toString(); | ||
this.sendData("environment.properties", "misc", Buffer.from(text)); | ||
this.sendData("environment.properties", "misc", Buffer.from(text, "utf-8")); | ||
} | ||
@@ -52,46 +48,2 @@ writeCategoriesDefinitions(categories) { | ||
} | ||
var parseJsonResult = data => { | ||
return JSON.parse(Buffer.from(data, "base64").toString("utf8")); | ||
}; | ||
export class MessageReader { | ||
constructor() { | ||
_defineProperty(this, "results", { | ||
tests: [], | ||
groups: [], | ||
attachments: {} | ||
}); | ||
_defineProperty(this, "handleMessage", jsonMessage => { | ||
var { | ||
path, | ||
type = "undefined", | ||
data | ||
} = JSON.parse(jsonMessage); | ||
switch (type) { | ||
case "container": | ||
this.results.groups.push(parseJsonResult(data)); | ||
return; | ||
case "result": | ||
this.results.tests.push(parseJsonResult(data)); | ||
return; | ||
case "attachment": | ||
this.results.attachments[path] = data; | ||
return; | ||
case "misc": | ||
switch (path) { | ||
case "environment.properties": | ||
this.results.envInfo = parseProperties(Buffer.from(data, "base64").toString()); | ||
break; | ||
case "categories.json": | ||
this.results.categories = parseJsonResult(data); | ||
break; | ||
default: | ||
break; | ||
} | ||
return; | ||
default: | ||
return; | ||
} | ||
}); | ||
} | ||
} | ||
//# sourceMappingURL=MessageWriter.js.map |
@@ -139,12 +139,15 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } | ||
} | ||
attachment(name, content, type) { | ||
attachment(name, content, options) { | ||
var _this11 = this; | ||
return _asyncToGenerator(function* () { | ||
var bufferContent = typeof content === "string" ? Buffer.from(content, options.encoding) : content; | ||
yield _this11.sendMessage({ | ||
type: "raw_attachment", | ||
type: "attachment_content", | ||
data: { | ||
name, | ||
content: Buffer.from(content).toString("base64"), | ||
contentType: type, | ||
encoding: "base64" | ||
content: bufferContent.toString("base64"), | ||
encoding: "base64", | ||
contentType: options.contentType, | ||
fileExtension: options.fileExtension, | ||
wrapInStep: true | ||
} | ||
@@ -154,6 +157,21 @@ }); | ||
} | ||
step(name, body) { | ||
attachmentFromPath(name, path, options) { | ||
var _this12 = this; | ||
return _asyncToGenerator(function* () { | ||
yield _this12.sendMessage({ | ||
type: "attachment_path", | ||
data: { | ||
name, | ||
path, | ||
contentType: options.contentType, | ||
fileExtension: options.fileExtension, | ||
wrapInStep: true | ||
} | ||
}); | ||
})(); | ||
} | ||
step(name, body) { | ||
var _this13 = this; | ||
return _asyncToGenerator(function* () { | ||
yield _this13.sendMessage({ | ||
type: "step_start", | ||
@@ -167,3 +185,3 @@ data: { | ||
var result = yield body(); | ||
yield _this12.sendMessage({ | ||
yield _this13.sendMessage({ | ||
type: "step_stop", | ||
@@ -182,3 +200,3 @@ data: { | ||
} = err; | ||
yield _this12.sendMessage({ | ||
yield _this13.sendMessage({ | ||
type: "step_stop", | ||
@@ -200,5 +218,5 @@ data: { | ||
stepDisplayName(name) { | ||
var _this13 = this; | ||
var _this14 = this; | ||
return _asyncToGenerator(function* () { | ||
yield _this13.sendMessage({ | ||
yield _this14.sendMessage({ | ||
type: "step_metadata", | ||
@@ -212,5 +230,5 @@ data: { | ||
stepParameter(name, value, mode) { | ||
var _this14 = this; | ||
var _this15 = this; | ||
return _asyncToGenerator(function* () { | ||
yield _this14.sendMessage({ | ||
yield _this15.sendMessage({ | ||
type: "step_metadata", | ||
@@ -217,0 +235,0 @@ data: { |
@@ -10,3 +10,3 @@ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); } | ||
} | ||
description() { | ||
attachmentFromPath() { | ||
var _this2 = this; | ||
@@ -17,3 +17,3 @@ return _asyncToGenerator(function* () { | ||
} | ||
descriptionHtml() { | ||
description() { | ||
var _this3 = this; | ||
@@ -24,3 +24,3 @@ return _asyncToGenerator(function* () { | ||
} | ||
displayName() { | ||
descriptionHtml() { | ||
var _this4 = this; | ||
@@ -31,3 +31,3 @@ return _asyncToGenerator(function* () { | ||
} | ||
historyId() { | ||
displayName() { | ||
var _this5 = this; | ||
@@ -38,3 +38,3 @@ return _asyncToGenerator(function* () { | ||
} | ||
labels() { | ||
historyId() { | ||
var _this6 = this; | ||
@@ -45,3 +45,3 @@ return _asyncToGenerator(function* () { | ||
} | ||
links() { | ||
labels() { | ||
var _this7 = this; | ||
@@ -52,3 +52,3 @@ return _asyncToGenerator(function* () { | ||
} | ||
parameter() { | ||
links() { | ||
var _this8 = this; | ||
@@ -59,16 +59,16 @@ return _asyncToGenerator(function* () { | ||
} | ||
step(name, body) { | ||
parameter() { | ||
var _this9 = this; | ||
return _asyncToGenerator(function* () { | ||
yield _this9.warning(); | ||
return body(); | ||
})(); | ||
} | ||
stepDisplayName() { | ||
step(name, body) { | ||
var _this10 = this; | ||
return _asyncToGenerator(function* () { | ||
yield _this10.warning(); | ||
return body(); | ||
})(); | ||
} | ||
stepParameter() { | ||
stepDisplayName() { | ||
var _this11 = this; | ||
@@ -79,3 +79,3 @@ return _asyncToGenerator(function* () { | ||
} | ||
testCaseId() { | ||
stepParameter() { | ||
var _this12 = this; | ||
@@ -86,2 +86,8 @@ return _asyncToGenerator(function* () { | ||
} | ||
testCaseId() { | ||
var _this13 = this; | ||
return _asyncToGenerator(function* () { | ||
yield _this13.warning(); | ||
})(); | ||
} | ||
@@ -88,0 +94,0 @@ // eslint-disable-next-line @typescript-eslint/require-await |
@@ -25,3 +25,3 @@ function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(e, r) { return new BabelRegExp(e, void 0, r); }; var e = RegExp.prototype, r = new WeakMap(); function BabelRegExp(e, t, p) { var o = RegExp(e, t); return r.set(o, p || r.get(e)), _setPrototypeOf(o, BabelRegExp.prototype); } function buildGroups(e, t) { var p = r.get(t); return Object.keys(p).reduce(function (r, t) { var o = p[t]; if ("number" == typeof o) r[t] = e[o];else { for (var i = 0; void 0 === e[o[i]] && i + 1 < o.length;) i++; r[t] = e[o[i]]; } return r; }, Object.create(null)); } return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (r) { var t = e.exec.call(this, r); if (t) { t.groups = buildGroups(t, this); var p = t.indices; p && (p.groups = buildGroups(p, this)); } return t; }, BabelRegExp.prototype[Symbol.replace] = function (t, p) { if ("string" == typeof p) { var o = r.get(this); return e[Symbol.replace].call(this, t, p.replace(/\$<([^>]+)>/g, function (e, r) { var t = o[r]; return "$" + (Array.isArray(t) ? t.join("$") : t); })); } if ("function" == typeof p) { var i = this; return e[Symbol.replace].call(this, t, function () { var e = arguments; return "object" != typeof e[e.length - 1] && (e = [].slice.call(e)).push(buildGroups(e, i)), p.apply(this, e); }); } return e[Symbol.replace].call(this, t, p); }, _wrapRegExp.apply(this, arguments); } | ||
*/ | ||
export var ansiRegex = function ansiRegex() { | ||
var ansiRegex = function ansiRegex() { | ||
var { | ||
@@ -38,5 +38,2 @@ onlyFirst = false | ||
export var stripAnsi = str => { | ||
if (typeof str !== "string") { | ||
throw new TypeError("Expected a `string`, got `".concat(typeof str, "`")); | ||
} | ||
var regex = ansiRegex(); | ||
@@ -43,0 +40,0 @@ return str.replace(regex, ""); |
/// <reference types="node" /> | ||
import type { ContentType, Label, Link, ParameterMode, ParameterOptions } from "./model.js"; | ||
import type { ContentType } from "./model.js"; | ||
import { type AttachmentOptions, type Label, type Link, type ParameterMode, type ParameterOptions } from "./model.js"; | ||
import { LabelName, LinkType } from "./model.js"; | ||
export declare const label: (name: LabelName | string, value: string) => any; | ||
export declare const labels: (...labelsList: Label[]) => any; | ||
export declare const link: (url: string, type?: LinkType | string, name?: string) => any; | ||
export declare const links: (...linksList: Link[]) => any; | ||
export declare const parameter: (name: string, value: string, options?: ParameterOptions) => any; | ||
export declare const description: (markdown: string) => any; | ||
export declare const descriptionHtml: (html: string) => any; | ||
export declare const displayName: (name: string) => any; | ||
export declare const historyId: (value: string) => any; | ||
export declare const testCaseId: (value: string) => any; | ||
export declare const attachment: (name: string, content: Buffer | string, type: ContentType | string) => any; | ||
export declare const label: (name: LabelName | string, value: string) => PromiseLike<void>; | ||
export declare const labels: (...labelsList: Label[]) => PromiseLike<void>; | ||
export declare const link: (url: string, name?: string, type?: LinkType | string) => PromiseLike<void>; | ||
export declare const links: (...linksList: Link[]) => PromiseLike<void>; | ||
export declare const parameter: (name: string, value: string, options?: ParameterOptions) => PromiseLike<void>; | ||
export declare const description: (markdown: string) => PromiseLike<void>; | ||
export declare const descriptionHtml: (html: string) => PromiseLike<void>; | ||
export declare const displayName: (name: string) => PromiseLike<void>; | ||
export declare const historyId: (value: string) => PromiseLike<void>; | ||
export declare const testCaseId: (value: string) => PromiseLike<void>; | ||
export declare const attachment: (name: string, content: Buffer | string, options: ContentType | string | AttachmentOptions) => PromiseLike<void>; | ||
export declare const attachmentPath: (name: string, path: string, options: ContentType | string | Omit<AttachmentOptions, "encoding">) => PromiseLike<void>; | ||
export type StepContext = { | ||
@@ -19,16 +21,16 @@ displayName: (name: string) => void | PromiseLike<void>; | ||
}; | ||
export declare const step: <T = void>(name: string, body: (context: StepContext) => T | PromiseLike<T>) => any; | ||
export declare const issue: (url: string, name?: string) => any; | ||
export declare const tms: (url: string, name?: string) => any; | ||
export declare const allureId: (value: string) => any; | ||
export declare const epic: (name: string) => any; | ||
export declare const feature: (name: string) => any; | ||
export declare const story: (name: string) => any; | ||
export declare const suite: (name: string) => any; | ||
export declare const parentSuite: (name: string) => any; | ||
export declare const subSuite: (name: string) => any; | ||
export declare const owner: (name: string) => any; | ||
export declare const severity: (name: string) => any; | ||
export declare const layer: (name: string) => any; | ||
export declare const tag: (name: string) => any; | ||
export declare const tags: (...tagsList: string[]) => any; | ||
export declare const step: <T = void>(name: string, body: (context: StepContext) => T | PromiseLike<T>) => PromiseLike<void>; | ||
export declare const issue: (url: string, name?: string) => PromiseLike<void>; | ||
export declare const tms: (url: string, name?: string) => PromiseLike<void>; | ||
export declare const allureId: (value: string) => PromiseLike<void>; | ||
export declare const epic: (name: string) => PromiseLike<void>; | ||
export declare const feature: (name: string) => PromiseLike<void>; | ||
export declare const story: (name: string) => PromiseLike<void>; | ||
export declare const suite: (name: string) => PromiseLike<void>; | ||
export declare const parentSuite: (name: string) => PromiseLike<void>; | ||
export declare const subSuite: (name: string) => PromiseLike<void>; | ||
export declare const owner: (name: string) => PromiseLike<void>; | ||
export declare const severity: (name: string) => PromiseLike<void>; | ||
export declare const layer: (name: string) => PromiseLike<void>; | ||
export declare const tag: (name: string) => PromiseLike<void>; | ||
export declare const tags: (...tagsList: string[]) => PromiseLike<void>; |
export { label, labels, link, links, parameter, description, descriptionHtml, displayName, historyId, testCaseId, attachment, step, issue, tms, allureId, epic, feature, story, suite, parentSuite, subSuite, owner, severity, layer, tag, tags, } from "./facade.js"; | ||
export type { StepContext } from "./facade.js"; | ||
export type { Attachment, FixtureResult, ImageDiffAttachment, Label, Link, Parameter, ParameterMode, ParameterOptions, StatusDetails, StepResult, TestOrStepResult, TestResult, TestResultContainer, } from "./model.js"; | ||
export type { Attachment, AttachmentOptions, FixtureResult, ImageDiffAttachment, Label, Link, Parameter, ParameterMode, ParameterOptions, StatusDetails, StepResult, TestOrStepResult, TestResult, TestResultContainer, } from "./model.js"; | ||
export { ContentType, LinkType, LabelName, Severity, Stage, Status, StatusByPriority } from "./model.js"; |
@@ -0,4 +1,5 @@ | ||
/// <reference types="node" /> | ||
export interface Attachment { | ||
name: string; | ||
type: string; | ||
type?: string; | ||
source: string; | ||
@@ -8,3 +9,3 @@ } | ||
contentType: ContentType | string; | ||
encoding?: string; | ||
encoding?: BufferEncoding; | ||
fileExtension?: string; | ||
@@ -82,2 +83,5 @@ } | ||
ALLURE_ID = "ALLURE_ID", | ||
/** | ||
* @deprecated please use ALLURE_ID instead | ||
*/ | ||
AS_ID = "ALLURE_ID", | ||
@@ -84,0 +88,0 @@ SUITE = "suite", |
@@ -1,2 +0,2 @@ | ||
export type { AllureResults, Category, EnvironmentInfo, ExecutorInfo, ExtensionMessage, Messages, RawAttachment, RuntimeMessage, RuntimeMetadataMessage, RuntimeRawAttachmentMessage, RuntimeStartStepMessage, RuntimeStepMetadataMessage, RuntimeStopStepMessage, TestPlanV1Test, TestPlanV1, } from "./types.js"; | ||
export type { AllureResults, Category, EnvironmentInfo, ExecutorInfo, ExtensionMessage, Messages, RuntimeMessage, RuntimeMetadataMessage, RuntimeAttachmentContentMessage, RuntimeStartStepMessage, RuntimeStepMetadataMessage, RuntimeStopStepMessage, TestPlanV1Test, TestPlanV1, } from "./types.js"; | ||
export { getStatusFromError, getMessageAndTraceFromError, extractMetadataFromString, isAllStepsEnded, isAnyStepFailed, getUnfinishedStepsMessages, hasStepMessage, isPromise, hasLabel, stripAnsi, } from "./utils.js"; |
import type { AllureContext, AllureContextHolder, AllureContextProvider } from "./types.js"; | ||
/** | ||
* Provides the set of methods to access and update the context. | ||
* Successor classes are responsible for persisting and accessing the context. | ||
*/ | ||
export declare abstract class AllureContextProviderBase<TContext extends AllureContext, THolder extends AllureContextHolder<TContext>> implements AllureContextProvider { | ||
/** | ||
* Gets the holder that contains the current value of the context. | ||
*/ | ||
protected abstract load: () => THolder; | ||
/** | ||
* Persist the changes applied to the context since it was last time persisted. | ||
*/ | ||
protected abstract store: (holder: THolder) => void; | ||
@@ -5,0 +15,0 @@ getScope: () => string | null; |
import { AllureContextProviderBase } from "./AllureContextProviderBase.js"; | ||
import type { AllureContext, AllureContextHolder } from "./types.js"; | ||
/** | ||
* Allure context that stores its data in mutable class fields. | ||
* Unsafe from the cuncurrency standpoint. | ||
*/ | ||
export declare class MutableAllureContext implements AllureContext { | ||
@@ -14,2 +18,7 @@ readonly scopeStack: string[]; | ||
} | ||
/** | ||
* Implements transitioning between context values by mutating the context | ||
* object. | ||
* Unsafe from the cuncurrency standpoint. | ||
*/ | ||
export declare class MutableAllureContextHolder implements AllureContextHolder<MutableAllureContext> { | ||
@@ -30,2 +39,6 @@ private readonly context; | ||
} | ||
/** | ||
* Stores the context in a class field. That's a simple but not async-safe way of | ||
* manipulating the context. | ||
*/ | ||
export declare class StaticContextProvider<TContext extends AllureContext, THolder extends AllureContextHolder<TContext>> extends AllureContextProviderBase<TContext, THolder> { | ||
@@ -36,3 +49,7 @@ private readonly holderSingleton; | ||
protected store: (holder: THolder) => void; | ||
/** | ||
* Wraps a context holder singleton in the static context provider. | ||
* @param holderSingleton The singleton to wrap. | ||
*/ | ||
static wrap: <TContext_1 extends AllureContext, THolder_1 extends AllureContextHolder<TContext_1>>(holderSingleton: THolder_1) => StaticContextProvider<TContext_1, THolder_1>; | ||
} |
@@ -0,1 +1,4 @@ | ||
/** | ||
* Represents a snapshot of the Allure state at some particular moment during the run. | ||
*/ | ||
export type AllureContext = { | ||
@@ -7,2 +10,5 @@ getScope: () => string | null; | ||
}; | ||
/** | ||
* Implements the transitions from one snapshot to another. | ||
*/ | ||
export type AllureContextHolder<TContext extends AllureContext> = { | ||
@@ -20,2 +26,5 @@ get: () => TContext; | ||
}; | ||
/** | ||
* Provides the set of methods to access and update the context. | ||
*/ | ||
export type AllureContextProvider = { | ||
@@ -22,0 +31,0 @@ getScope: () => string | null; |
@@ -10,3 +10,4 @@ export type * from "./types.js"; | ||
export { FileSystemWriter } from "./writer/FileSystemWriter.js"; | ||
export { MessageWriter, MessageReader } from "./writer/MessageWriter.js"; | ||
export { MessageWriter } from "./writer/MessageWriter.js"; | ||
export { MessageReader } from "./writer/MessageReader.js"; | ||
export { getEnvironmentLabels, getHostLabel, getThreadLabel } from "./utils/labels.js"; |
@@ -13,3 +13,3 @@ import type { FixtureResult, StepResult, TestResult } from "../../model.js"; | ||
getStep: (uuid: string) => StepResult | undefined; | ||
getExecutionItem: (uuid: string) => StepResult | undefined; | ||
getExecutionItem: (uuid: string) => FixtureResult | TestResult | StepResult | undefined; | ||
setTestResult: (uuid: string, result: TestResult) => void; | ||
@@ -16,0 +16,0 @@ deleteTestResult: (uuid: string) => void; |
@@ -0,24 +1,86 @@ | ||
/// <reference types="node" /> | ||
import type { AttachmentOptions, FixtureResult, StepResult, TestResult } from "../../model.js"; | ||
import type { Category, EnvironmentInfo, Messages, RawAttachment, RuntimeMessage } from "../types.js"; | ||
import type { Config, FixtureType, TestScope, WellKnownWriters, Writer } from "./types.js"; | ||
import type { Category, EnvironmentInfo, Messages, RuntimeMessage } from "../types.js"; | ||
import type { Config, FixtureType, TestScope, Writer } from "./types.js"; | ||
type StartScopeOpts = { | ||
/** | ||
* If set to `true`, a manual scope will be created. A manual scope doesn't affect | ||
* the context. Therefore, tests and fixtures aren't linked to it | ||
* automatically. | ||
* | ||
* Use `linkFixtures`, `updateScope`, or test and fixture start options to fill | ||
* such scope with tests and fixtures. | ||
*/ | ||
manual?: boolean; | ||
/** | ||
* If set to the UUID of an existing scope, the new scope will be created as its | ||
* sub-scope. | ||
* | ||
* Has an effect only if `manual` is `true`. | ||
*/ | ||
parent?: string; | ||
}; | ||
type StartFixtureOpts = { | ||
/** | ||
* The UUID of the scope that should be associated with the fixture. Defaults to the current | ||
* scope of the context. | ||
* | ||
* If set to `null`, the fixture won't be attached to any scope (except the | ||
* dedicated one in case `dedicatedScope` is `true`). | ||
*/ | ||
scope?: string | null; | ||
/** | ||
* If set to `true`, an extra scope will be created to hold the fixture result. | ||
* The scope gets the same UUID as the fixture result and isn't pushed into | ||
* the context. | ||
* | ||
* The scope denoted by the `scope` option will serve as the parent. | ||
*/ | ||
dedicatedScope?: boolean; | ||
/** | ||
* The UUIDs of tests affected by the fixture. Those tests will be associated | ||
* with the fixture's scope. | ||
* | ||
* If the `scope` option is set to `null`, implicitly sets `dedicatedScope` to `true`. | ||
*/ | ||
tests?: string[]; | ||
}; | ||
type StartTestOpts = { | ||
/** | ||
* The UUID of a scope the test should be associated with. Defaults to the current one. | ||
* | ||
* If set to `null`, the test won't be associated with any scope (except the | ||
* dedicated one in case the `dedicatedScope` option is `true`). | ||
*/ | ||
scope?: string | null; | ||
/** | ||
* If set to `true`, an extra scope will be created with the same UUID as the | ||
* test result. The test will be attached to that scope. | ||
* | ||
* The scope denoted by the `scope` option will serve as the parent. | ||
*/ | ||
dedicatedScope?: boolean; | ||
}; | ||
type StopOpts = { | ||
/** | ||
* The test's or fixture's stop time. Defaults to `Date.now()`. | ||
*/ | ||
stop?: number; | ||
/** | ||
* The UUID of a test or fixture to stop. | ||
*/ | ||
uuid?: string; | ||
}; | ||
type LinkFixturesOpts = { | ||
/** | ||
* The UUIDs of fixtures to associate with the scope or tests. | ||
*/ | ||
fixtures?: readonly string[]; | ||
/** | ||
* The UUID of a scope to associate with the fixture or tests. | ||
*/ | ||
scope?: string; | ||
/** | ||
* The UUIDs of tests to associate with the fixture or scope. | ||
*/ | ||
tests?: readonly string[]; | ||
@@ -47,23 +109,112 @@ }; | ||
getCurrentStep: (root?: string) => StepResult | undefined; | ||
getCurrentExecutingItem: (root?: string) => StepResult | undefined; | ||
getCurrentExecutingItem: (root?: string) => FixtureResult | TestResult | StepResult | undefined; | ||
getCurrentScope: () => TestScope | undefined; | ||
/** | ||
* Creates a new scope. The scope is pushed into the context unless the `manual` | ||
* option is set to `true`. | ||
* | ||
* @param opts | ||
* @returns | ||
*/ | ||
startScope: (opts?: StartScopeOpts) => string; | ||
updateScope: (updateFunc: (scope: TestScope) => void, uuid?: string) => void; | ||
/** | ||
* Removes a scope from the context. Use `writeScope` to emit its fixtures on disk then. | ||
* | ||
* If you just want to write the current stop, you may omit the call to this method and | ||
* call `writeScope` with no uuid. | ||
* | ||
* @param uuid The UUID of the scope. If not provided, the current scope will be stopped. | ||
* | ||
* @returns The UUID of the scope that has been stopped. | ||
*/ | ||
stopScope: (uuid?: string) => string | undefined; | ||
/** | ||
* Writes all fixtures of a scope on disk. | ||
* | ||
* @param uuid The UUID of the scope. If not provided, the current scope will | ||
* be written and removed from the context. Don't call `stopScope` in that case. | ||
*/ | ||
writeScope: (uuid?: string) => void; | ||
/** | ||
* Creates a new fixture result and puts it in the context as the current one. | ||
* | ||
* Use the `scope` parameter to control the fixture's scope. Use `updateScope` | ||
* or `linkFixtures` to associate fixtures with tests that can't be linked | ||
* automatically. | ||
* | ||
* Use `stopFixture` once the fixture is completed. | ||
* | ||
* Use `writeScope` or `writeFixture` to emit fixtures on disk. | ||
* | ||
* @param type The type of the fixture. It's either `"before"` or `"after"`. | ||
* @param fixtureResult The fixture result data. | ||
* @param scope | ||
* @param dedicatedScope | ||
* @param tests | ||
* @returns The UUID of the new fixture. | ||
*/ | ||
startFixture: (type: FixtureType, fixtureResult: Partial<FixtureResult>, { scope, dedicatedScope, tests }?: StartFixtureOpts) => `${string}-${string}-${string}-${string}-${string}` | undefined; | ||
updateFixture: (updateFunc: (result: FixtureResult) => void, uuid?: string) => void; | ||
/** | ||
* Stops a fixture and removes it from the context. The fixture result will persist in | ||
* the storage until it's written on disk with `writeScope` or `writeFixture`. | ||
* | ||
* @returns The UUID of the stopped fixture. | ||
*/ | ||
stopFixture: ({ uuid, stop }?: StopOpts) => string | undefined; | ||
/** | ||
* Use to associate fixtures, scopes, and tests with each other. | ||
* | ||
* At least two arguments must be provided. | ||
*/ | ||
linkFixtures: ({ fixtures, scope, tests }: LinkFixturesOpts) => void; | ||
/** | ||
* Emits a fixture on disk. Calls `stopFixture` prior to that in case the fixture | ||
* hasn't been stopped yet. Use this method if you want to manage fixtures manually. | ||
* Otherwise, use `writeScope`. | ||
* | ||
* If called without parameters, implicitly calls `stopFixture`. Make sure you don't call | ||
* `stopFixture` by yourself in that case. | ||
* | ||
* The method has no effect if the fixture isn't associated with at least one test. | ||
* | ||
* @param uuid The UUID of the fixture. If not provided, the current fixture will | ||
* be stopped and emitted. Don't call `stopFixture` in that case. | ||
*/ | ||
writeFixture: (uuid?: string) => void; | ||
startTest: (result: Partial<TestResult>, { scope, dedicatedScope }?: StartTestOpts) => string; | ||
/** | ||
* Updates test result by uuid | ||
* @example | ||
* ```ts | ||
* runtime.update(uuid, (result) => { | ||
* // change the result directly, you don't need to return anything | ||
* result.name = "foo"; | ||
* }); | ||
* ``` | ||
* @param updateFunc - a function that updates the test result; the result is passed as a single argument and should be mutated to apply the changes | ||
* @param uuid - test result uuid | ||
*/ | ||
updateTest: (updateFunc: (result: TestResult) => void, uuid?: string) => void; | ||
stopTest: ({ uuid, stop }?: StopOpts) => void; | ||
/** | ||
* Writes a test result on disk and removes it from the storage and the context. | ||
* @param uuid The UUID of the test. If not set, the current test result is written. | ||
*/ | ||
writeTest: (uuid?: string) => void; | ||
/** | ||
* Starts a new step and pushes it into the context. | ||
* | ||
* @param result Data to be put into the step result object. | ||
* @param uuid The UUID of a test or fixture to attach the step to. If not set, the UUID of the current fixture is used. | ||
* If no fixture is running, the UUID of the current test is used. | ||
* | ||
* @returns The UUID of the step. | ||
*/ | ||
startStep: (result: Partial<StepResult>, uuid?: string) => `${string}-${string}-${string}-${string}-${string}` | undefined; | ||
updateStep: (updateFunc: (stepResult: StepResult) => void, uuid?: string) => void; | ||
stopStep: ({ uuid, stop }?: StopOpts) => void; | ||
buildAttachmentFileName: (options: AttachmentOptions) => string; | ||
writeAttachment: (attachment: RawAttachment, uuid?: string) => void; | ||
writeAttachmentFromPath: (attachmentName: string, attachmentPath: string, options: AttachmentOptions, uuid?: string) => string | undefined; | ||
writeAttachment: (attachmentName: string, attachmentContent: Buffer, options: AttachmentOptions, uuid?: string) => void; | ||
writeAttachmentFromPath: (attachmentName: string, attachmentPath: string, options: AttachmentOptions, uuid?: string) => void; | ||
writeEnvironmentInfo: () => void; | ||
@@ -73,3 +224,2 @@ writeCategoriesDefinitions: () => void; | ||
protected createTestResult(result: Partial<TestResult>): TestResult; | ||
protected getWellKnownWriters(): WellKnownWriters; | ||
private handleBuiltInMessage; | ||
@@ -80,4 +230,5 @@ private handleMetadataMessage; | ||
private handleStepStopMessage; | ||
private handleRawAttachmentMessage; | ||
writeAttachmentForItem: (attachment: RawAttachment, item: StepResult | TestResult | FixtureResult) => void; | ||
private handleAttachmentContentMessage; | ||
private handleAttachmentPathMessage; | ||
private writeAttachmentForItem; | ||
private startScopeWithUuid; | ||
@@ -84,0 +235,0 @@ private resolveScope; |
@@ -61,4 +61,4 @@ /// <reference types="node" /> | ||
writeGroup(result: TestResultContainer): void; | ||
writeAttachment(distFileName: string, content: Buffer | string, encoding?: BufferEncoding): void; | ||
writeAttachmentFromPath(from: string, distFileName: string): void; | ||
writeAttachment(distFileName: string, content: Buffer): void; | ||
writeAttachmentFromPath(distFileName: string, from: string): void; | ||
writeEnvironmentInfo(info: EnvironmentInfo): void; | ||
@@ -65,0 +65,0 @@ writeCategoriesDefinitions(categories: Category[]): void; |
/// <reference path="../../../../src/types/properties.d.ts" /> | ||
import properties from "properties"; | ||
import type { AttachmentOptions, ContentType, Status, StepResult, TestResult } from "../../model.js"; | ||
import type { Status, StepResult, TestResult } from "../../model.js"; | ||
import type { Label } from "../../model.js"; | ||
import type { WellKnownWriters, Writer, WriterDescriptor } from "./types.js"; | ||
export declare const randomUuid: () => `${string}-${string}-${string}-${string}-${string}`; | ||
export declare const md5: (str: string) => string; | ||
export declare const writeAttachment: (uuid: string, options: ContentType | string | AttachmentOptions) => string; | ||
export declare const getTestResultHistoryId: (result: TestResult) => string; | ||
@@ -14,11 +12,7 @@ export declare const getTestResultTestCaseId: (result: TestResult) => string | undefined; | ||
export declare const readImageAsBase64: (filePath: string) => Promise<string | undefined>; | ||
export declare const resolveWriter: (wellKnownWriters: WellKnownWriters, value: Writer | WriterDescriptor) => Writer; | ||
export declare const getGlobalLabels: () => Label[]; | ||
export declare const getRelativePath: (filepath: string) => string; | ||
export declare const getPackageLabelFromPath: (filepath: string) => Label; | ||
export declare const deepClone: <T>(obj: T) => T; | ||
export declare const typeToExtension: (options: AttachmentOptions) => string; | ||
export declare const serialize: (val: unknown) => string; | ||
export declare const getSuiteLabels: (suites: readonly string[]) => Label[]; | ||
export declare const getSuitesLabels: (suites: readonly string[]) => Label[]; | ||
export declare const ensureSuiteLabels: (test: Partial<TestResult>, defaultSuites: readonly string[]) => void; | ||
@@ -25,0 +19,0 @@ export declare const escapeRegExp: (value: string) => string; |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import type { PathLike } from "node:fs"; | ||
import type { TestResult, TestResultContainer } from "../../../model.js"; | ||
@@ -12,4 +10,4 @@ import type { Category, EnvironmentInfo } from "../../types.js"; | ||
}); | ||
writeAttachment(distFileName: string, content: Buffer | string, encoding?: BufferEncoding): void; | ||
writeAttachmentFromPath(from: PathLike, distFileName: string): void; | ||
writeAttachment(distFileName: string, content: Buffer): void; | ||
writeAttachmentFromPath(distFileName: string, from: string): void; | ||
writeEnvironmentInfo(info: EnvironmentInfo): void; | ||
@@ -16,0 +14,0 @@ writeCategoriesDefinitions(categories: Category[]): void; |
@@ -8,3 +8,3 @@ /// <reference types="node" /> | ||
tests: TestResult[]; | ||
attachments: Record<string, Buffer | string>; | ||
attachments: Record<string, Buffer>; | ||
categories?: Category[]; | ||
@@ -14,11 +14,6 @@ envInfo?: Record<string, string | undefined>; | ||
writeResult(result: TestResult): void; | ||
writeAttachment(distFileName: string, content: Buffer | string): void; | ||
writeAttachmentFromPath(fromFilePath: string, distFileName: string): void; | ||
writeAttachment(distFileName: string, content: Buffer): void; | ||
writeAttachmentFromPath(distFileName: string, from: string): void; | ||
writeCategoriesDefinitions(categories: Category[]): void; | ||
writeEnvironmentInfo(envInfo: EnvironmentInfo): void; | ||
reset(): void; | ||
getMaybeTestByName(name: string): TestResult | undefined; | ||
getTestByName(name: string): TestResult; | ||
getMaybeGroupByName(name: string): TestResultContainer | undefined; | ||
getGroupByName(name: string): TestResultContainer; | ||
} |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import type { PathLike } from "fs"; | ||
import type { EventEmitter } from "node:events"; | ||
import type { TestResult, TestResultContainer } from "../../../model.js"; | ||
import type { AllureResults, Category, EnvironmentInfo } from "../../types.js"; | ||
import type { Category, EnvironmentInfo } from "../../types.js"; | ||
import type { Writer } from "../types.js"; | ||
@@ -14,4 +12,4 @@ export declare class MessageWriter implements Writer { | ||
private writeJson; | ||
writeAttachment(distFileName: string, content: Buffer | string, encoding?: BufferEncoding): void; | ||
writeAttachmentFromPath(from: PathLike, distFileName: string): void; | ||
writeAttachment(distFileName: string, content: Buffer): void; | ||
writeAttachmentFromPath(distFileName: string, from: string): void; | ||
writeEnvironmentInfo(info: EnvironmentInfo): void; | ||
@@ -22,5 +20,1 @@ writeCategoriesDefinitions(categories: Category[]): void; | ||
} | ||
export declare class MessageReader { | ||
readonly results: AllureResults; | ||
handleMessage: (jsonMessage: string) => void; | ||
} |
/// <reference types="node" /> | ||
import type { ContentType, Label, LabelName, Link, LinkType, ParameterMode, ParameterOptions } from "../../model.js"; | ||
import type { AttachmentOptions, Label, LabelName, Link, LinkType, ParameterMode, ParameterOptions } from "../../model.js"; | ||
import type { RuntimeMessage } from "../types.js"; | ||
@@ -16,3 +16,4 @@ import type { TestRuntime } from "./types.js"; | ||
testCaseId(value: string): Promise<void>; | ||
attachment(name: string, content: Buffer | string, type: string | ContentType): Promise<void>; | ||
attachment(name: string, content: Buffer | string, options: AttachmentOptions): Promise<void>; | ||
attachmentFromPath(name: string, path: string, options: AttachmentOptions): Promise<void>; | ||
step<T = void>(name: string, body: () => T | PromiseLike<T>): Promise<T>; | ||
@@ -19,0 +20,0 @@ stepDisplayName(name: string): Promise<void>; |
import type { TestRuntime } from "./types.js"; | ||
export declare class NoopTestRuntime implements TestRuntime { | ||
attachment(): Promise<void>; | ||
attachmentFromPath(): Promise<void>; | ||
description(): Promise<void>; | ||
@@ -17,2 +18,2 @@ descriptionHtml(): Promise<void>; | ||
} | ||
export declare const noopRuntime: NoopTestRuntime; | ||
export declare const noopRuntime: TestRuntime; |
/// <reference types="node" /> | ||
import type { ContentType, Label, Link, ParameterMode, ParameterOptions } from "../../model.js"; | ||
import type { AttachmentOptions, Label, Link, ParameterMode, ParameterOptions } from "../../model.js"; | ||
export interface TestRuntime { | ||
@@ -12,3 +12,4 @@ labels: (...labels: Label[]) => PromiseLike<void>; | ||
testCaseId: (value: string) => PromiseLike<void>; | ||
attachment: (name: string, content: Buffer | string, type: ContentType | string) => PromiseLike<void>; | ||
attachment: (name: string, content: Buffer | string, options: AttachmentOptions) => PromiseLike<void>; | ||
attachmentFromPath: (name: string, path: string, options: Omit<AttachmentOptions, "encoding">) => PromiseLike<void>; | ||
step: <T = void>(name: string, body: () => T | PromiseLike<T>) => PromiseLike<T>; | ||
@@ -15,0 +16,0 @@ stepDisplayName: (name: string) => PromiseLike<void>; |
/// <reference types="node" /> | ||
import type { Attachment, AttachmentOptions, Label, Link, Parameter, Stage, Status, StatusDetails, TestResult, TestResultContainer } from "../model.js"; | ||
export interface RawAttachment extends AttachmentOptions { | ||
name: string; | ||
content: Buffer | string; | ||
} | ||
import type { Attachment, Label, Link, Parameter, Stage, Status, StatusDetails, TestResult, TestResultContainer } from "../model.js"; | ||
type RuntimeMessageBase<T extends string> = { | ||
@@ -44,6 +40,22 @@ type: T; | ||
}; | ||
export type RuntimeRawAttachmentMessage = RuntimeMessageBase<"raw_attachment"> & { | ||
data: RawAttachment; | ||
export type RuntimeAttachmentContentMessage = RuntimeMessageBase<"attachment_content"> & { | ||
data: { | ||
name: string; | ||
content: string; | ||
encoding: BufferEncoding; | ||
contentType: string; | ||
fileExtension?: string; | ||
wrapInStep?: boolean; | ||
}; | ||
}; | ||
export type RuntimeMessage = RuntimeMetadataMessage | RuntimeStartStepMessage | RuntimeStepMetadataMessage | RuntimeStopStepMessage | RuntimeRawAttachmentMessage; | ||
export type RuntimeAttachmentPathMessage = RuntimeMessageBase<"attachment_path"> & { | ||
data: { | ||
name: string; | ||
path: string; | ||
contentType: string; | ||
fileExtension?: string; | ||
wrapInStep?: boolean; | ||
}; | ||
}; | ||
export type RuntimeMessage = RuntimeMetadataMessage | RuntimeStartStepMessage | RuntimeStepMetadataMessage | RuntimeStopStepMessage | RuntimeAttachmentContentMessage | RuntimeAttachmentPathMessage; | ||
export type ExtensionMessage<T extends string> = T extends MessageTypes<RuntimeMessage> ? never : RuntimeMessageBase<T>; | ||
@@ -50,0 +62,0 @@ export type Messages<T> = T extends RuntimeMessage | ExtensionMessage<infer _> ? T : never; |
@@ -5,5 +5,5 @@ import type { FixtureResult, Label, StatusDetails, StepResult, TestResult } from "../model.js"; | ||
export declare const getStatusFromError: (error: Error) => Status; | ||
export declare const ansiRegex: ({ onlyFirst }?: { | ||
onlyFirst?: boolean | undefined; | ||
}) => RegExp; | ||
/** | ||
* https://github.com/chalk/strip-ansi | ||
*/ | ||
export declare const stripAnsi: (str: string) => string; | ||
@@ -10,0 +10,0 @@ export declare const getMessageAndTraceFromError: (error: Error | { |
{ | ||
"name": "allure-js-commons", | ||
"version": "3.0.0-beta.1", | ||
"version": "3.0.0-beta.2", | ||
"description": "Allure JS Commons", | ||
@@ -54,3 +54,3 @@ "homepage": "https://allurereport.org/", | ||
"compile:cjs": "babel --config-file ./babel.cjs.json ./src --out-dir ./dist/cjs --extensions '.ts' --source-maps", | ||
"compile:types": "tsc --project ./tsconfig.json --emitDeclarationOnly --declarationDir ./dist/types", | ||
"compile:types": "tsc", | ||
"compile:fixup": "node ./scripts/fixup.mjs", | ||
@@ -57,0 +57,0 @@ "lint": "eslint ./src ./test --ext .ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
168
8339
2
829264