allure-playwright
Advanced tools
Comparing version 3.0.0-beta.3 to 3.0.0-beta.4
@@ -31,4 +31,4 @@ "use strict"; | ||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } | ||
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; } | ||
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; } | ||
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; } | ||
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); } | ||
@@ -69,2 +69,3 @@ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; } | ||
_defineProperty(this, "allureResultsUuids", new Map()); | ||
_defineProperty(this, "attachmentSteps", new Map()); | ||
this.options = _objectSpread({ | ||
@@ -96,2 +97,3 @@ suiteTitle: true, | ||
testsWithSelectors.forEach(function (test) { | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion | ||
if (!/#/.test(test.selector)) { | ||
@@ -105,3 +107,5 @@ v2ReporterTests.push(test); | ||
// we need to cut off column because playwright works only with line number | ||
var v2SelectorsArgs = v2ReporterTests.map(function (test) { | ||
var v2SelectorsArgs = v2ReporterTests | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion | ||
.map(function (test) { | ||
return test.selector.replace(/:\d+$/, ""); | ||
@@ -116,2 +120,3 @@ }).map(function (selector) { | ||
// we can filter tests only by absolute path, so we need to cut off test name | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion | ||
.map(function (test) { | ||
@@ -146,3 +151,3 @@ return test.selector.split("#")[0]; | ||
value: function onBegin(suite) { | ||
var writer = this.options.testMode ? new _reporter.MessageWriter() : new _reporter.FileSystemWriter({ | ||
var writer = _nodeProcess["default"].env.ALLURE_TEST_MODE ? new _reporter.MessageWriter() : new _reporter.FileSystemWriter({ | ||
resultsDir: this.options.resultsDir || "./allure-results" | ||
@@ -207,15 +212,18 @@ }); | ||
value: function onStepBegin(test, _result, step) { | ||
if (!this.options.detail && step.category !== "test.step") { | ||
var testUuid = this.allureResultsUuids.get(test.id); | ||
if (step.category === "attach") { | ||
var _this$allureRuntime, _this$attachmentSteps; | ||
var currentStep = (_this$allureRuntime = this.allureRuntime) === null || _this$allureRuntime === void 0 ? void 0 : _this$allureRuntime.currentStep(testUuid); | ||
this.attachmentSteps.set(testUuid, [].concat(_toConsumableArray((_this$attachmentSteps = this.attachmentSteps.get(testUuid)) !== null && _this$attachmentSteps !== void 0 ? _this$attachmentSteps : []), [currentStep])); | ||
return; | ||
} | ||
// ignore attach steps since attachments are already in the report | ||
if (step.category === "attach") { | ||
// TODO fix the details disable, e.g. only ignore pw:api steps | ||
if (!this.options.detail && step.category !== "test.step") { | ||
return; | ||
} | ||
var testUuid = this.allureResultsUuids.get(test.id); | ||
this.allureRuntime.startStep({ | ||
this.allureRuntime.startStep(testUuid, undefined, { | ||
name: step.title.substring(0, stepAttachPrefixLength), | ||
start: step.startTime.getTime() | ||
}, testUuid); | ||
}); | ||
} | ||
@@ -234,3 +242,7 @@ }, { | ||
var testUuid = this.allureResultsUuids.get(test.id); | ||
this.allureRuntime.updateStep(function (stepResult) { | ||
var currentStep = this.allureRuntime.currentStep(testUuid); | ||
if (!currentStep) { | ||
return; | ||
} | ||
this.allureRuntime.updateStep(currentStep, function (stepResult) { | ||
stepResult.status = step.error ? _allureJsCommons.Status.FAILED : _allureJsCommons.Status.PASSED; | ||
@@ -241,6 +253,4 @@ stepResult.stage = _allureJsCommons.Stage.FINISHED; | ||
} | ||
}, testUuid); | ||
this.allureRuntime.stopStep({ | ||
uuid: testUuid | ||
}); | ||
this.allureRuntime.stopStep(currentStep, step.startTime.getTime() + step.duration); | ||
} | ||
@@ -251,4 +261,5 @@ }, { | ||
var _onTestEnd = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(test, result) { | ||
var _this = this; | ||
var testUuid, threadId, thread, error, _test$parent$titlePat, _test$parent$titlePat2, projectSuiteTitle, fileSuiteTitle, suiteTitles, _iterator, _step, attachment; | ||
var _this = this, | ||
_this$attachmentSteps2; | ||
var testUuid, threadId, thread, error, _test$parent$titlePat, _test$parent$titlePat2, projectSuiteTitle, fileSuiteTitle, suiteTitles, attachmentSteps, i, attachment, attachmentStep; | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
@@ -262,3 +273,3 @@ while (1) switch (_context.prev = _context.next) { | ||
_test$parent$titlePat = test.parent.titlePath(), _test$parent$titlePat2 = _toArray(_test$parent$titlePat), projectSuiteTitle = _test$parent$titlePat2[1], fileSuiteTitle = _test$parent$titlePat2[2], suiteTitles = _test$parent$titlePat2.slice(3); | ||
this.allureRuntime.updateTest(function (testResult) { | ||
this.allureRuntime.updateTest(testUuid, function (testResult) { | ||
testResult.labels.push({ | ||
@@ -295,38 +306,28 @@ name: _allureJsCommons.LabelName.HOST, | ||
testResult.stage = _allureJsCommons.Stage.FINISHED; | ||
}, testUuid); | ||
_iterator = _createForOfIteratorHelper(result.attachments); | ||
_context.prev = 7; | ||
_iterator.s(); | ||
case 9: | ||
if ((_step = _iterator.n()).done) { | ||
_context.next = 15; | ||
}); | ||
attachmentSteps = (_this$attachmentSteps2 = this.attachmentSteps.get(testUuid)) !== null && _this$attachmentSteps2 !== void 0 ? _this$attachmentSteps2 : []; | ||
i = 0; | ||
case 8: | ||
if (!(i < result.attachments.length)) { | ||
_context.next = 16; | ||
break; | ||
} | ||
attachment = _step.value; | ||
attachment = result.attachments[i]; | ||
attachmentStep = attachmentSteps.length > i ? attachmentSteps[i] : undefined; | ||
_context.next = 13; | ||
return this.processAttachment(test.id, attachment); | ||
return this.processAttachment(testUuid, attachmentStep, attachment); | ||
case 13: | ||
_context.next = 9; | ||
i++; | ||
_context.next = 8; | ||
break; | ||
case 15: | ||
_context.next = 20; | ||
break; | ||
case 17: | ||
_context.prev = 17; | ||
_context.t0 = _context["catch"](7); | ||
_iterator.e(_context.t0); | ||
case 20: | ||
_context.prev = 20; | ||
_iterator.f(); | ||
return _context.finish(20); | ||
case 23: | ||
case 16: | ||
if (result.stdout.length > 0) { | ||
this.allureRuntime.writeAttachment("stdout", Buffer.from((0, _sdk.stripAnsi)(result.stdout.join("")), "utf-8"), { | ||
this.allureRuntime.writeAttachment(testUuid, undefined, "stdout", Buffer.from((0, _sdk.stripAnsi)(result.stdout.join("")), "utf-8"), { | ||
contentType: _allureJsCommons.ContentType.TEXT | ||
}, testUuid); | ||
}); | ||
} | ||
if (result.stderr.length > 0) { | ||
this.allureRuntime.writeAttachment("stderr", Buffer.from((0, _sdk.stripAnsi)(result.stderr.join("")), "utf-8"), { | ||
this.allureRuntime.writeAttachment(testUuid, undefined, "stderr", Buffer.from((0, _sdk.stripAnsi)(result.stderr.join("")), "utf-8"), { | ||
contentType: _allureJsCommons.ContentType.TEXT | ||
}, testUuid); | ||
}); | ||
} | ||
@@ -336,3 +337,3 @@ | ||
// in next iterations we need to implement the logic for every javascript integration | ||
this.allureRuntime.updateTest(function (testResult) { | ||
this.allureRuntime.updateTest(testUuid, function (testResult) { | ||
var mappedLabels = testResult.labels.reduce(function (acc, label) { | ||
@@ -353,12 +354,10 @@ if (!acc[label.name]) { | ||
testResult.labels = newLabels; | ||
}, testUuid); | ||
this.allureRuntime.stopTest({ | ||
uuid: testUuid | ||
}); | ||
this.allureRuntime.stopTest(testUuid, result.startTime.getTime() + result.duration); | ||
this.allureRuntime.writeTest(testUuid); | ||
case 28: | ||
case 21: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, _callee, this, [[7, 17, 20, 23]]); | ||
}, _callee, this); | ||
})); | ||
@@ -375,3 +374,3 @@ function onTestEnd(_x, _x2) { | ||
var _this2 = this; | ||
var unprocessedCases, _iterator2, _step2, testCase; | ||
var unprocessedCases, _iterator, _step, testCase; | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
@@ -385,11 +384,11 @@ while (1) switch (_context2.prev = _context2.next) { | ||
}); | ||
_iterator2 = _createForOfIteratorHelper(unprocessedCases); | ||
_iterator = _createForOfIteratorHelper(unprocessedCases); | ||
_context2.prev = 2; | ||
_iterator2.s(); | ||
_iterator.s(); | ||
case 4: | ||
if ((_step2 = _iterator2.n()).done) { | ||
if ((_step = _iterator.n()).done) { | ||
_context2.next = 11; | ||
break; | ||
} | ||
testCase = _step2.value; | ||
testCase = _step.value; | ||
this.onTestBegin(testCase); | ||
@@ -419,6 +418,6 @@ _context2.next = 9; | ||
_context2.t0 = _context2["catch"](2); | ||
_iterator2.e(_context2.t0); | ||
_iterator.e(_context2.t0); | ||
case 16: | ||
_context2.prev = 16; | ||
_iterator2.f(); | ||
_iterator.f(); | ||
return _context2.finish(16); | ||
@@ -467,78 +466,84 @@ case 19: | ||
value: function () { | ||
var _processAttachment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(testId, attachment) { | ||
var testUuid, allureRuntimeMessage, message, pathWithoutEnd, actualBase64, expectedBase64, diffBase64, diffName; | ||
var _processAttachment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(testUuid, attachmentStepUuid, attachment) { | ||
var allureRuntimeMessage, message, parentUuid, pathWithoutEnd, actualBase64, expectedBase64, diffBase64, diffName; | ||
return _regeneratorRuntime().wrap(function _callee4$(_context4) { | ||
while (1) switch (_context4.prev = _context4.next) { | ||
case 0: | ||
testUuid = this.allureResultsUuids.get(testId); | ||
if (!(!attachment.body && !attachment.path)) { | ||
_context4.next = 3; | ||
_context4.next = 2; | ||
break; | ||
} | ||
return _context4.abrupt("return"); | ||
case 3: | ||
case 2: | ||
allureRuntimeMessage = attachment.contentType === _reporter.ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE; | ||
if (!(allureRuntimeMessage && !attachment.body)) { | ||
_context4.next = 6; | ||
_context4.next = 5; | ||
break; | ||
} | ||
return _context4.abrupt("return"); | ||
case 6: | ||
case 5: | ||
if (!allureRuntimeMessage) { | ||
_context4.next = 10; | ||
_context4.next = 9; | ||
break; | ||
} | ||
message = JSON.parse(attachment.body.toString()); // TODO: make possible to pass single message and list of them | ||
this.allureRuntime.applyRuntimeMessages([message], { | ||
testUuid: testUuid | ||
}); | ||
message = JSON.parse(attachment.body.toString()); // TODO fix step metadata messages | ||
this.allureRuntime.applyRuntimeMessages(testUuid, [message]); | ||
return _context4.abrupt("return"); | ||
case 10: | ||
case 9: | ||
parentUuid = this.allureRuntime.startStep(testUuid, attachmentStepUuid, { | ||
name: attachment.name | ||
}); // only stop if step is created. Step may not be created only if test with specified uuid doesn't exists. | ||
// usually, missing test by uuid means we should completely skip result processing; | ||
// the later operations are safe and will only produce console warnings | ||
if (parentUuid) { | ||
this.allureRuntime.stopStep(parentUuid, undefined); | ||
} | ||
if (!attachment.body) { | ||
_context4.next = 14; | ||
_context4.next = 15; | ||
break; | ||
} | ||
this.allureRuntime.writeAttachment(attachment.name, attachment.body, { | ||
this.allureRuntime.writeAttachment(testUuid, parentUuid, attachment.name, attachment.body, { | ||
contentType: attachment.contentType | ||
}, testUuid); | ||
_context4.next = 19; | ||
}); | ||
_context4.next = 20; | ||
break; | ||
case 14: | ||
case 15: | ||
if ((0, _nodeFs.existsSync)(attachment.path)) { | ||
_context4.next = 18; | ||
_context4.next = 19; | ||
break; | ||
} | ||
return _context4.abrupt("return"); | ||
case 18: | ||
this.allureRuntime.writeAttachmentFromPath(attachment.name, attachment.path, { | ||
case 19: | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion | ||
this.allureRuntime.writeAttachment(testUuid, parentUuid, attachment.name, attachment.path, { | ||
contentType: attachment.contentType | ||
}, testUuid); | ||
case 19: | ||
}); | ||
case 20: | ||
if (attachment.name.match(diffEndRegexp)) { | ||
_context4.next = 21; | ||
_context4.next = 22; | ||
break; | ||
} | ||
return _context4.abrupt("return"); | ||
case 21: | ||
case 22: | ||
pathWithoutEnd = attachment.path.replace(diffEndRegexp, ""); | ||
if (!this.processedDiffs.includes(pathWithoutEnd)) { | ||
_context4.next = 24; | ||
_context4.next = 25; | ||
break; | ||
} | ||
return _context4.abrupt("return"); | ||
case 24: | ||
_context4.next = 26; | ||
case 25: | ||
_context4.next = 27; | ||
return (0, _reporter.readImageAsBase64)("".concat(pathWithoutEnd, "-actual.png")); | ||
case 26: | ||
case 27: | ||
actualBase64 = _context4.sent; | ||
_context4.next = 29; | ||
_context4.next = 30; | ||
return (0, _reporter.readImageAsBase64)("".concat(pathWithoutEnd, "-expected.png")); | ||
case 29: | ||
case 30: | ||
expectedBase64 = _context4.sent; | ||
_context4.next = 32; | ||
_context4.next = 33; | ||
return (0, _reporter.readImageAsBase64)("".concat(pathWithoutEnd, "-diff.png")); | ||
case 32: | ||
case 33: | ||
diffBase64 = _context4.sent; | ||
diffName = attachment.name.replace(diffEndRegexp, ""); | ||
this.allureRuntime.writeAttachment(diffName, Buffer.from(JSON.stringify({ | ||
this.allureRuntime.writeAttachment(testUuid, undefined, diffName, Buffer.from(JSON.stringify({ | ||
expected: expectedBase64, | ||
@@ -551,5 +556,5 @@ actual: actualBase64, | ||
fileExtension: ".imagediff" | ||
}, testUuid); | ||
}); | ||
this.processedDiffs.push(pathWithoutEnd); | ||
case 36: | ||
case 37: | ||
case "end": | ||
@@ -560,3 +565,3 @@ return _context4.stop(); | ||
})); | ||
function processAttachment(_x3, _x4) { | ||
function processAttachment(_x3, _x4, _x5) { | ||
return _processAttachment.apply(this, arguments); | ||
@@ -563,0 +568,0 @@ } |
@@ -34,5 +34,5 @@ "use strict"; | ||
return _createClass(AllurePlaywrightTestRuntime, [{ | ||
key: "sendMessage", | ||
key: "step", | ||
value: function () { | ||
var _sendMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(message) { | ||
var _step = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(name, body) { | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
@@ -42,7 +42,8 @@ while (1) switch (_context.prev = _context.next) { | ||
_context.next = 2; | ||
return _test["default"].info().attach("allure-metadata.json", { | ||
contentType: _reporter.ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE, | ||
body: Buffer.from(JSON.stringify(message), "utf8") | ||
return _test["default"].step(name, function () { | ||
return Promise.resolve(body()); | ||
}); | ||
case 2: | ||
return _context.abrupt("return", _context.sent); | ||
case 3: | ||
case "end": | ||
@@ -53,3 +54,72 @@ return _context.stop(); | ||
})); | ||
function sendMessage(_x) { | ||
function step(_x, _x2) { | ||
return _step.apply(this, arguments); | ||
} | ||
return step; | ||
}() | ||
}, { | ||
key: "attachment", | ||
value: function () { | ||
var _attachment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(name, content, options) { | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) switch (_context2.prev = _context2.next) { | ||
case 0: | ||
_context2.next = 2; | ||
return _test["default"].info().attach(name, { | ||
body: content, | ||
contentType: options.contentType | ||
}); | ||
case 2: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
}, _callee2); | ||
})); | ||
function attachment(_x3, _x4, _x5) { | ||
return _attachment.apply(this, arguments); | ||
} | ||
return attachment; | ||
}() | ||
}, { | ||
key: "attachmentFromPath", | ||
value: function () { | ||
var _attachmentFromPath = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(name, path, options) { | ||
return _regeneratorRuntime().wrap(function _callee3$(_context3) { | ||
while (1) switch (_context3.prev = _context3.next) { | ||
case 0: | ||
_context3.next = 2; | ||
return _test["default"].info().attach(name, { | ||
path: path, | ||
contentType: options.contentType | ||
}); | ||
case 2: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
}, _callee3); | ||
})); | ||
function attachmentFromPath(_x6, _x7, _x8) { | ||
return _attachmentFromPath.apply(this, arguments); | ||
} | ||
return attachmentFromPath; | ||
}() | ||
}, { | ||
key: "sendMessage", | ||
value: function () { | ||
var _sendMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(message) { | ||
return _regeneratorRuntime().wrap(function _callee4$(_context4) { | ||
while (1) switch (_context4.prev = _context4.next) { | ||
case 0: | ||
_context4.next = 2; | ||
return _test["default"].info().attach("Allure Metadata (".concat(message.type, ")"), { | ||
contentType: _reporter.ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE, | ||
body: Buffer.from(JSON.stringify(message), "utf8") | ||
}); | ||
case 2: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
}, _callee4); | ||
})); | ||
function sendMessage(_x9) { | ||
return _sendMessage.apply(this, arguments); | ||
@@ -56,0 +126,0 @@ } |
@@ -13,4 +13,6 @@ "use strict"; | ||
} | ||
return testPlan.tests.map(function (testInfo) { | ||
var pattern = testInfo.selector.replace("#", " "); | ||
return testPlan.tests.flatMap(function (testInfo) { | ||
return testInfo.selector ? [testInfo.selector] : []; | ||
}).map(function (selector) { | ||
var pattern = selector.replace("#", " "); | ||
return new RegExp("\\s".concat((0, _reporter.escapeRegExp)(pattern), "$")); | ||
@@ -17,0 +19,0 @@ }); |
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } | ||
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; } | ||
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; } | ||
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; } | ||
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); } | ||
@@ -49,2 +49,3 @@ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; } | ||
_defineProperty(this, "allureResultsUuids", new Map()); | ||
_defineProperty(this, "attachmentSteps", new Map()); | ||
this.options = _objectSpread({ | ||
@@ -76,2 +77,3 @@ suiteTitle: true, | ||
testsWithSelectors.forEach(function (test) { | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion | ||
if (!/#/.test(test.selector)) { | ||
@@ -85,3 +87,5 @@ v2ReporterTests.push(test); | ||
// we need to cut off column because playwright works only with line number | ||
var v2SelectorsArgs = v2ReporterTests.map(function (test) { | ||
var v2SelectorsArgs = v2ReporterTests | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion | ||
.map(function (test) { | ||
return test.selector.replace(/:\d+$/, ""); | ||
@@ -96,2 +100,3 @@ }).map(function (selector) { | ||
// we can filter tests only by absolute path, so we need to cut off test name | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion | ||
.map(function (test) { | ||
@@ -126,3 +131,3 @@ return test.selector.split("#")[0]; | ||
value: function onBegin(suite) { | ||
var writer = this.options.testMode ? new MessageWriter() : new FileSystemWriter({ | ||
var writer = process.env.ALLURE_TEST_MODE ? new MessageWriter() : new FileSystemWriter({ | ||
resultsDir: this.options.resultsDir || "./allure-results" | ||
@@ -187,15 +192,18 @@ }); | ||
value: function onStepBegin(test, _result, step) { | ||
if (!this.options.detail && step.category !== "test.step") { | ||
var testUuid = this.allureResultsUuids.get(test.id); | ||
if (step.category === "attach") { | ||
var _this$allureRuntime, _this$attachmentSteps; | ||
var currentStep = (_this$allureRuntime = this.allureRuntime) === null || _this$allureRuntime === void 0 ? void 0 : _this$allureRuntime.currentStep(testUuid); | ||
this.attachmentSteps.set(testUuid, [].concat(_toConsumableArray((_this$attachmentSteps = this.attachmentSteps.get(testUuid)) !== null && _this$attachmentSteps !== void 0 ? _this$attachmentSteps : []), [currentStep])); | ||
return; | ||
} | ||
// ignore attach steps since attachments are already in the report | ||
if (step.category === "attach") { | ||
// TODO fix the details disable, e.g. only ignore pw:api steps | ||
if (!this.options.detail && step.category !== "test.step") { | ||
return; | ||
} | ||
var testUuid = this.allureResultsUuids.get(test.id); | ||
this.allureRuntime.startStep({ | ||
this.allureRuntime.startStep(testUuid, undefined, { | ||
name: step.title.substring(0, stepAttachPrefixLength), | ||
start: step.startTime.getTime() | ||
}, testUuid); | ||
}); | ||
} | ||
@@ -214,3 +222,7 @@ }, { | ||
var testUuid = this.allureResultsUuids.get(test.id); | ||
this.allureRuntime.updateStep(function (stepResult) { | ||
var currentStep = this.allureRuntime.currentStep(testUuid); | ||
if (!currentStep) { | ||
return; | ||
} | ||
this.allureRuntime.updateStep(currentStep, function (stepResult) { | ||
stepResult.status = step.error ? Status.FAILED : Status.PASSED; | ||
@@ -221,6 +233,4 @@ stepResult.stage = Stage.FINISHED; | ||
} | ||
}, testUuid); | ||
this.allureRuntime.stopStep({ | ||
uuid: testUuid | ||
}); | ||
this.allureRuntime.stopStep(currentStep, step.startTime.getTime() + step.duration); | ||
} | ||
@@ -231,4 +241,5 @@ }, { | ||
var _onTestEnd = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(test, result) { | ||
var _this = this; | ||
var testUuid, threadId, thread, error, _test$parent$titlePat, _test$parent$titlePat2, projectSuiteTitle, fileSuiteTitle, suiteTitles, _iterator, _step, attachment; | ||
var _this = this, | ||
_this$attachmentSteps2; | ||
var testUuid, threadId, thread, error, _test$parent$titlePat, _test$parent$titlePat2, projectSuiteTitle, fileSuiteTitle, suiteTitles, attachmentSteps, i, attachment, attachmentStep; | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
@@ -242,3 +253,3 @@ while (1) switch (_context.prev = _context.next) { | ||
_test$parent$titlePat = test.parent.titlePath(), _test$parent$titlePat2 = _toArray(_test$parent$titlePat), projectSuiteTitle = _test$parent$titlePat2[1], fileSuiteTitle = _test$parent$titlePat2[2], suiteTitles = _test$parent$titlePat2.slice(3); | ||
this.allureRuntime.updateTest(function (testResult) { | ||
this.allureRuntime.updateTest(testUuid, function (testResult) { | ||
testResult.labels.push({ | ||
@@ -275,38 +286,28 @@ name: LabelName.HOST, | ||
testResult.stage = Stage.FINISHED; | ||
}, testUuid); | ||
_iterator = _createForOfIteratorHelper(result.attachments); | ||
_context.prev = 7; | ||
_iterator.s(); | ||
case 9: | ||
if ((_step = _iterator.n()).done) { | ||
_context.next = 15; | ||
}); | ||
attachmentSteps = (_this$attachmentSteps2 = this.attachmentSteps.get(testUuid)) !== null && _this$attachmentSteps2 !== void 0 ? _this$attachmentSteps2 : []; | ||
i = 0; | ||
case 8: | ||
if (!(i < result.attachments.length)) { | ||
_context.next = 16; | ||
break; | ||
} | ||
attachment = _step.value; | ||
attachment = result.attachments[i]; | ||
attachmentStep = attachmentSteps.length > i ? attachmentSteps[i] : undefined; | ||
_context.next = 13; | ||
return this.processAttachment(test.id, attachment); | ||
return this.processAttachment(testUuid, attachmentStep, attachment); | ||
case 13: | ||
_context.next = 9; | ||
i++; | ||
_context.next = 8; | ||
break; | ||
case 15: | ||
_context.next = 20; | ||
break; | ||
case 17: | ||
_context.prev = 17; | ||
_context.t0 = _context["catch"](7); | ||
_iterator.e(_context.t0); | ||
case 20: | ||
_context.prev = 20; | ||
_iterator.f(); | ||
return _context.finish(20); | ||
case 23: | ||
case 16: | ||
if (result.stdout.length > 0) { | ||
this.allureRuntime.writeAttachment("stdout", Buffer.from(stripAnsi(result.stdout.join("")), "utf-8"), { | ||
this.allureRuntime.writeAttachment(testUuid, undefined, "stdout", Buffer.from(stripAnsi(result.stdout.join("")), "utf-8"), { | ||
contentType: ContentType.TEXT | ||
}, testUuid); | ||
}); | ||
} | ||
if (result.stderr.length > 0) { | ||
this.allureRuntime.writeAttachment("stderr", Buffer.from(stripAnsi(result.stderr.join("")), "utf-8"), { | ||
this.allureRuntime.writeAttachment(testUuid, undefined, "stderr", Buffer.from(stripAnsi(result.stderr.join("")), "utf-8"), { | ||
contentType: ContentType.TEXT | ||
}, testUuid); | ||
}); | ||
} | ||
@@ -316,3 +317,3 @@ | ||
// in next iterations we need to implement the logic for every javascript integration | ||
this.allureRuntime.updateTest(function (testResult) { | ||
this.allureRuntime.updateTest(testUuid, function (testResult) { | ||
var mappedLabels = testResult.labels.reduce(function (acc, label) { | ||
@@ -333,12 +334,10 @@ if (!acc[label.name]) { | ||
testResult.labels = newLabels; | ||
}, testUuid); | ||
this.allureRuntime.stopTest({ | ||
uuid: testUuid | ||
}); | ||
this.allureRuntime.stopTest(testUuid, result.startTime.getTime() + result.duration); | ||
this.allureRuntime.writeTest(testUuid); | ||
case 28: | ||
case 21: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, _callee, this, [[7, 17, 20, 23]]); | ||
}, _callee, this); | ||
})); | ||
@@ -355,3 +354,3 @@ function onTestEnd(_x, _x2) { | ||
var _this2 = this; | ||
var unprocessedCases, _iterator2, _step2, testCase; | ||
var unprocessedCases, _iterator, _step, testCase; | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
@@ -365,11 +364,11 @@ while (1) switch (_context2.prev = _context2.next) { | ||
}); | ||
_iterator2 = _createForOfIteratorHelper(unprocessedCases); | ||
_iterator = _createForOfIteratorHelper(unprocessedCases); | ||
_context2.prev = 2; | ||
_iterator2.s(); | ||
_iterator.s(); | ||
case 4: | ||
if ((_step2 = _iterator2.n()).done) { | ||
if ((_step = _iterator.n()).done) { | ||
_context2.next = 11; | ||
break; | ||
} | ||
testCase = _step2.value; | ||
testCase = _step.value; | ||
this.onTestBegin(testCase); | ||
@@ -399,6 +398,6 @@ _context2.next = 9; | ||
_context2.t0 = _context2["catch"](2); | ||
_iterator2.e(_context2.t0); | ||
_iterator.e(_context2.t0); | ||
case 16: | ||
_context2.prev = 16; | ||
_iterator2.f(); | ||
_iterator.f(); | ||
return _context2.finish(16); | ||
@@ -447,78 +446,84 @@ case 19: | ||
value: function () { | ||
var _processAttachment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(testId, attachment) { | ||
var testUuid, allureRuntimeMessage, message, pathWithoutEnd, actualBase64, expectedBase64, diffBase64, diffName; | ||
var _processAttachment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(testUuid, attachmentStepUuid, attachment) { | ||
var allureRuntimeMessage, message, parentUuid, pathWithoutEnd, actualBase64, expectedBase64, diffBase64, diffName; | ||
return _regeneratorRuntime().wrap(function _callee4$(_context4) { | ||
while (1) switch (_context4.prev = _context4.next) { | ||
case 0: | ||
testUuid = this.allureResultsUuids.get(testId); | ||
if (!(!attachment.body && !attachment.path)) { | ||
_context4.next = 3; | ||
_context4.next = 2; | ||
break; | ||
} | ||
return _context4.abrupt("return"); | ||
case 3: | ||
case 2: | ||
allureRuntimeMessage = attachment.contentType === ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE; | ||
if (!(allureRuntimeMessage && !attachment.body)) { | ||
_context4.next = 6; | ||
_context4.next = 5; | ||
break; | ||
} | ||
return _context4.abrupt("return"); | ||
case 6: | ||
case 5: | ||
if (!allureRuntimeMessage) { | ||
_context4.next = 10; | ||
_context4.next = 9; | ||
break; | ||
} | ||
message = JSON.parse(attachment.body.toString()); // TODO: make possible to pass single message and list of them | ||
this.allureRuntime.applyRuntimeMessages([message], { | ||
testUuid: testUuid | ||
}); | ||
message = JSON.parse(attachment.body.toString()); // TODO fix step metadata messages | ||
this.allureRuntime.applyRuntimeMessages(testUuid, [message]); | ||
return _context4.abrupt("return"); | ||
case 10: | ||
case 9: | ||
parentUuid = this.allureRuntime.startStep(testUuid, attachmentStepUuid, { | ||
name: attachment.name | ||
}); // only stop if step is created. Step may not be created only if test with specified uuid doesn't exists. | ||
// usually, missing test by uuid means we should completely skip result processing; | ||
// the later operations are safe and will only produce console warnings | ||
if (parentUuid) { | ||
this.allureRuntime.stopStep(parentUuid, undefined); | ||
} | ||
if (!attachment.body) { | ||
_context4.next = 14; | ||
_context4.next = 15; | ||
break; | ||
} | ||
this.allureRuntime.writeAttachment(attachment.name, attachment.body, { | ||
this.allureRuntime.writeAttachment(testUuid, parentUuid, attachment.name, attachment.body, { | ||
contentType: attachment.contentType | ||
}, testUuid); | ||
_context4.next = 19; | ||
}); | ||
_context4.next = 20; | ||
break; | ||
case 14: | ||
case 15: | ||
if (existsSync(attachment.path)) { | ||
_context4.next = 18; | ||
_context4.next = 19; | ||
break; | ||
} | ||
return _context4.abrupt("return"); | ||
case 18: | ||
this.allureRuntime.writeAttachmentFromPath(attachment.name, attachment.path, { | ||
case 19: | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion | ||
this.allureRuntime.writeAttachment(testUuid, parentUuid, attachment.name, attachment.path, { | ||
contentType: attachment.contentType | ||
}, testUuid); | ||
case 19: | ||
}); | ||
case 20: | ||
if (attachment.name.match(diffEndRegexp)) { | ||
_context4.next = 21; | ||
_context4.next = 22; | ||
break; | ||
} | ||
return _context4.abrupt("return"); | ||
case 21: | ||
case 22: | ||
pathWithoutEnd = attachment.path.replace(diffEndRegexp, ""); | ||
if (!this.processedDiffs.includes(pathWithoutEnd)) { | ||
_context4.next = 24; | ||
_context4.next = 25; | ||
break; | ||
} | ||
return _context4.abrupt("return"); | ||
case 24: | ||
_context4.next = 26; | ||
case 25: | ||
_context4.next = 27; | ||
return readImageAsBase64("".concat(pathWithoutEnd, "-actual.png")); | ||
case 26: | ||
case 27: | ||
actualBase64 = _context4.sent; | ||
_context4.next = 29; | ||
_context4.next = 30; | ||
return readImageAsBase64("".concat(pathWithoutEnd, "-expected.png")); | ||
case 29: | ||
case 30: | ||
expectedBase64 = _context4.sent; | ||
_context4.next = 32; | ||
_context4.next = 33; | ||
return readImageAsBase64("".concat(pathWithoutEnd, "-diff.png")); | ||
case 32: | ||
case 33: | ||
diffBase64 = _context4.sent; | ||
diffName = attachment.name.replace(diffEndRegexp, ""); | ||
this.allureRuntime.writeAttachment(diffName, Buffer.from(JSON.stringify({ | ||
this.allureRuntime.writeAttachment(testUuid, undefined, diffName, Buffer.from(JSON.stringify({ | ||
expected: expectedBase64, | ||
@@ -531,5 +536,5 @@ actual: actualBase64, | ||
fileExtension: ".imagediff" | ||
}, testUuid); | ||
}); | ||
this.processedDiffs.push(pathWithoutEnd); | ||
case 36: | ||
case 37: | ||
case "end": | ||
@@ -540,3 +545,3 @@ return _context4.stop(); | ||
})); | ||
function processAttachment(_x3, _x4) { | ||
function processAttachment(_x3, _x4, _x5) { | ||
return _processAttachment.apply(this, arguments); | ||
@@ -543,0 +548,0 @@ } |
@@ -27,5 +27,5 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } | ||
return _createClass(AllurePlaywrightTestRuntime, [{ | ||
key: "sendMessage", | ||
key: "step", | ||
value: function () { | ||
var _sendMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(message) { | ||
var _step = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(name, body) { | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
@@ -35,7 +35,8 @@ while (1) switch (_context.prev = _context.next) { | ||
_context.next = 2; | ||
return test.info().attach("allure-metadata.json", { | ||
contentType: ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE, | ||
body: Buffer.from(JSON.stringify(message), "utf8") | ||
return test.step(name, function () { | ||
return Promise.resolve(body()); | ||
}); | ||
case 2: | ||
return _context.abrupt("return", _context.sent); | ||
case 3: | ||
case "end": | ||
@@ -46,3 +47,72 @@ return _context.stop(); | ||
})); | ||
function sendMessage(_x) { | ||
function step(_x, _x2) { | ||
return _step.apply(this, arguments); | ||
} | ||
return step; | ||
}() | ||
}, { | ||
key: "attachment", | ||
value: function () { | ||
var _attachment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(name, content, options) { | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) switch (_context2.prev = _context2.next) { | ||
case 0: | ||
_context2.next = 2; | ||
return test.info().attach(name, { | ||
body: content, | ||
contentType: options.contentType | ||
}); | ||
case 2: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
}, _callee2); | ||
})); | ||
function attachment(_x3, _x4, _x5) { | ||
return _attachment.apply(this, arguments); | ||
} | ||
return attachment; | ||
}() | ||
}, { | ||
key: "attachmentFromPath", | ||
value: function () { | ||
var _attachmentFromPath = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(name, path, options) { | ||
return _regeneratorRuntime().wrap(function _callee3$(_context3) { | ||
while (1) switch (_context3.prev = _context3.next) { | ||
case 0: | ||
_context3.next = 2; | ||
return test.info().attach(name, { | ||
path: path, | ||
contentType: options.contentType | ||
}); | ||
case 2: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
}, _callee3); | ||
})); | ||
function attachmentFromPath(_x6, _x7, _x8) { | ||
return _attachmentFromPath.apply(this, arguments); | ||
} | ||
return attachmentFromPath; | ||
}() | ||
}, { | ||
key: "sendMessage", | ||
value: function () { | ||
var _sendMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(message) { | ||
return _regeneratorRuntime().wrap(function _callee4$(_context4) { | ||
while (1) switch (_context4.prev = _context4.next) { | ||
case 0: | ||
_context4.next = 2; | ||
return test.info().attach("Allure Metadata (".concat(message.type, ")"), { | ||
contentType: ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE, | ||
body: Buffer.from(JSON.stringify(message), "utf8") | ||
}); | ||
case 2: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
}, _callee4); | ||
})); | ||
function sendMessage(_x9) { | ||
return _sendMessage.apply(this, arguments); | ||
@@ -49,0 +119,0 @@ } |
@@ -7,4 +7,6 @@ import { escapeRegExp, parseTestPlan } from "allure-js-commons/sdk/reporter"; | ||
} | ||
return testPlan.tests.map(function (testInfo) { | ||
var pattern = testInfo.selector.replace("#", " "); | ||
return testPlan.tests.flatMap(function (testInfo) { | ||
return testInfo.selector ? [testInfo.selector] : []; | ||
}).map(function (selector) { | ||
var pattern = selector.replace("#", " "); | ||
return new RegExp("\\s".concat(escapeRegExp(pattern), "$")); | ||
@@ -11,0 +13,0 @@ }); |
@@ -32,2 +32,3 @@ /// <reference types="node" /> | ||
private readonly allureResultsUuids; | ||
private readonly attachmentSteps; | ||
constructor(config: AllurePlaywrightReporterConfig); | ||
@@ -34,0 +35,0 @@ onConfigure(config: FullConfig): void; |
import type { Config } from "allure-js-commons/sdk/reporter"; | ||
export interface AllurePlaywrightReporterConfig extends Omit<Config, "writer"> { | ||
detail?: boolean; | ||
outputFolder?: string; | ||
suiteTitle?: boolean; | ||
testMode?: boolean; | ||
} |
@@ -0,1 +1,3 @@ | ||
/// <reference types="node" /> | ||
import type { AttachmentOptions } from "allure-js-commons"; | ||
import type { RuntimeMessage } from "allure-js-commons/sdk"; | ||
@@ -5,3 +7,6 @@ import { MessageTestRuntime } from "allure-js-commons/sdk/runtime"; | ||
constructor(); | ||
step<T = void>(name: string, body: () => T | PromiseLike<T>): Promise<T>; | ||
attachment(name: string, content: Buffer | string, options: AttachmentOptions): Promise<void>; | ||
attachmentFromPath(name: string, path: string, options: AttachmentOptions): Promise<void>; | ||
sendMessage(message: RuntimeMessage): Promise<void>; | ||
} |
{ | ||
"name": "allure-playwright", | ||
"version": "3.0.0-beta.3", | ||
"version": "3.0.0-beta.4", | ||
"description": "Allure Playwright integration", | ||
@@ -50,10 +50,11 @@ "keywords": [ | ||
"compile:types": "tsc", | ||
"compile:fixup": "node ./scripts/fixup.mjs", | ||
"generate-report": "allure generate ./out/allure-results -o ./out/allure-report --clean", | ||
"lint": "eslint ./src ./test --ext .ts", | ||
"lint:fix": "eslint ./src ./test --ext .ts --fix", | ||
"pretest": "run compile", | ||
"pretest": "run-p clean compile", | ||
"test": "vitest run" | ||
}, | ||
"dependencies": { | ||
"allure-js-commons": "3.0.0-beta.3" | ||
"allure-js-commons": "3.0.0-beta.4" | ||
}, | ||
@@ -73,2 +74,4 @@ "devDependencies": { | ||
"@typescript-eslint/parser": "^7.0.0", | ||
"allure-commandline": "^2.29.0", | ||
"allure-vitest": "3.0.0-beta.4", | ||
"eslint": "^8.57.0", | ||
@@ -84,4 +87,4 @@ "eslint-config-prettier": "^9.0.0", | ||
"typescript": "^5.2.2", | ||
"vitest": "^1.5.0" | ||
"vitest": "^1.6.0" | ||
} | ||
} |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
312097
39
2020
1
25
3
+ Addedallure-js-commons@3.0.0-beta.4(transitive)
- Removedallure-js-commons@3.0.0-beta.3(transitive)