allure-playwright 3.0.0-beta.1 → 3.0.0-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -17,7 +17,6 @@ Object.defineProperty(exports, "test", {
17
17
  }
18
18
  });
19
19
  var _nodeFs = require("node:fs");
20
- var _nodeOs = _interopRequireDefault(require("node:os"));
21
20
  var _nodePath = _interopRequireDefault(require("node:path"));
22
21
  var _nodeProcess = _interopRequireDefault(require("node:process"));
23
22
  var _allureJsCommons = require("allure-js-commons");
@@ -28,8 +27,8 @@ var _utils = require("./utils.js");
28
27
  var _test = require("@playwright/test");
29
28
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
30
29
  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); }
31
- 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; }
32
30
  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; } } }; }
31
+ 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; }
33
32
  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); }
34
33
  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); }); }; }
35
34
  function _toArray(r) { return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest(); }
@@ -51,8 +50,6 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
51
50
  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); }
52
51
  // TODO: move to utils.ts
53
52
  var diffEndRegexp = /-((expected)|(diff)|(actual))\.png$/;
54
- // 12 (allureattach) + 1 (_) + 36 (uuid v4) + 1 (_)
55
- var stepAttachPrefixLength = 50;
56
53
  var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
57
54
  function AllureReporter(config) {
58
55
  _classCallCheck(this, AllureReporter);
@@ -60,11 +57,11 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
60
57
  _defineProperty(this, "suite", void 0);
61
58
  _defineProperty(this, "options", void 0);
62
59
  _defineProperty(this, "allureRuntime", void 0);
63
- _defineProperty(this, "hostname", _nodeProcess["default"].env.ALLURE_HOST_NAME || _nodeOs["default"].hostname());
64
60
  _defineProperty(this, "globalStartTime", new Date());
65
61
  _defineProperty(this, "processedDiffs", []);
66
62
  _defineProperty(this, "startedTestCasesTitlesCache", []);
67
63
  _defineProperty(this, "allureResultsUuids", new Map());
64
+ _defineProperty(this, "attachmentSteps", new Map());
68
65
  this.options = _objectSpread({
69
66
  suiteTitle: true,
70
67
  detail: true
@@ -91,6 +88,7 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
91
88
  var v2ReporterTests = [];
92
89
  var cliArgs = [];
93
90
  testsWithSelectors.forEach(function (test) {
91
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
94
92
  if (!/#/.test(test.selector)) {
95
93
  v2ReporterTests.push(test);
96
94
  return;
@@ -99,7 +97,9 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
99
97
  });
100
98
  if (v2ReporterTests.length) {
101
99
  // we need to cut off column because playwright works only with line number
102
- var v2SelectorsArgs = v2ReporterTests.map(function (test) {
100
+ var v2SelectorsArgs = v2ReporterTests
101
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
102
+ .map(function (test) {
103
103
  return test.selector.replace(/:\d+$/, "");
104
104
  }).map(function (selector) {
105
105
  return (0, _reporter.escapeRegExp)(selector);
@@ -109,6 +109,7 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
109
109
  if (v1ReporterTests.length) {
110
110
  var v1SelectorsArgs = v1ReporterTests
111
111
  // we can filter tests only by absolute path, so we need to cut off test name
112
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
112
113
  .map(function (test) {
113
114
  return test.selector.split("#")[0];
114
115
  }).map(function (selector) {
@@ -138,12 +139,11 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
138
139
  }, {
139
140
  key: "onBegin",
140
141
  value: function onBegin(suite) {
141
- var writer = this.options.testMode ? new _reporter.MessageWriter() : new _reporter.FileSystemWriter({
142
- resultsDir: this.options.resultsDir || "./allure-results"
143
- });
144
142
  this.suite = suite;
145
143
  this.allureRuntime = new _reporter.ReporterRuntime(_objectSpread(_objectSpread({}, this.options), {}, {
146
- writer: writer
144
+ writer: (0, _reporter.createDefaultWriter)({
145
+ resultsDir: this.options.resultsDir
146
+ })
147
147
  }));
148
148
  }
149
149
  }, {
@@ -152,7 +152,8 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
152
152
  var suite = test.parent;
153
153
  var titleMetadata = (0, _sdk.extractMetadataFromString)(test.title);
154
154
  var project = suite.project();
155
- var relativeFile = _nodePath["default"].relative(project === null || project === void 0 ? void 0 : project.testDir, test.location.file).split(_nodePath["default"].sep).join("/");
155
+ var testFilePath = _nodePath["default"].relative(project === null || project === void 0 ? void 0 : project.testDir, test.location.file);
156
+ var relativeFile = testFilePath.split(_nodePath["default"].sep).join("/");
156
157
  // root > project > file path > test.describe...
157
158
  var _suite$titlePath = suite.titlePath(),
158
159
  _suite$titlePath2 = _toArray(_suite$titlePath),
@@ -161,24 +162,31 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
161
162
  var testCaseIdBase = "".concat(relativeFile, "#").concat(nameSuites).concat(test.title);
162
163
  var result = {
163
164
  name: titleMetadata.cleanTitle,
164
- labels: titleMetadata.labels,
165
+ labels: [].concat(_toConsumableArray(titleMetadata.labels), _toConsumableArray((0, _reporter.getEnvironmentLabels)())),
165
166
  links: [],
166
167
  parameters: [],
167
168
  testCaseId: (0, _reporter.md5)(testCaseIdBase),
168
169
  fullName: "".concat(relativeFile, ":").concat(test.location.line, ":").concat(test.location.column)
169
170
  };
170
- result.labels.push({
171
- name: _allureJsCommons.LabelName.LANGUAGE,
172
- value: "JavaScript"
173
- });
174
- result.labels.push({
175
- name: _allureJsCommons.LabelName.FRAMEWORK,
176
- value: "Playwright"
177
- });
171
+ result.labels.push((0, _reporter.getLanguageLabel)());
172
+ result.labels.push((0, _reporter.getFrameworkLabel)("playwright"));
173
+ result.labels.push((0, _reporter.getPackageLabel)(testFilePath));
178
174
  result.labels.push({
179
175
  name: "titlePath",
180
176
  value: suite.titlePath().join(" > ")
181
177
  });
178
+
179
+ // support for earlier playwright versions
180
+ if ("tags" in test) {
181
+ var _ref;
182
+ var tags = test.tags.map(function (tag) {
183
+ return {
184
+ name: _allureJsCommons.LabelName.TAG,
185
+ value: tag.startsWith("@") ? tag.substring(1) : tag
186
+ };
187
+ });
188
+ (_ref = result.labels).push.apply(_ref, _toConsumableArray(tags));
189
+ }
182
190
  if (project !== null && project !== void 0 && project.name) {
183
191
  result.parameters.push({
184
192
  name: "Project",
@@ -198,19 +206,22 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
198
206
  }, {
199
207
  key: "onStepBegin",
200
208
  value: function onStepBegin(test, _result, step) {
201
- if (!this.options.detail && step.category !== "test.step") {
209
+ var testUuid = this.allureResultsUuids.get(test.id);
210
+ if (step.category === "attach") {
211
+ var _this$allureRuntime, _this$attachmentSteps;
212
+ var currentStep = (_this$allureRuntime = this.allureRuntime) === null || _this$allureRuntime === void 0 ? void 0 : _this$allureRuntime.currentStep(testUuid);
213
+ this.attachmentSteps.set(testUuid, [].concat(_toConsumableArray((_this$attachmentSteps = this.attachmentSteps.get(testUuid)) !== null && _this$attachmentSteps !== void 0 ? _this$attachmentSteps : []), [currentStep]));
202
214
  return;
203
215
  }
204
216
 
205
- // ignore attach steps since attachments are already in the report
206
- if (step.category === "attach") {
217
+ // TODO fix the details disable, e.g. only ignore pw:api steps
218
+ if (!this.options.detail && step.category !== "test.step") {
207
219
  return;
208
220
  }
209
- var testUuid = this.allureResultsUuids.get(test.id);
210
- this.allureRuntime.startStep({
211
- name: step.title.substring(0, stepAttachPrefixLength),
221
+ this.allureRuntime.startStep(testUuid, undefined, {
222
+ name: step.title,
212
223
  start: step.startTime.getTime()
213
- }, testUuid);
224
+ });
214
225
  }
215
226
  }, {
216
227
  key: "onStepEnd",
@@ -224,40 +235,39 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
224
235
  return;
225
236
  }
226
237
  var testUuid = this.allureResultsUuids.get(test.id);
227
- this.allureRuntime.updateStep(function (stepResult) {
238
+ var currentStep = this.allureRuntime.currentStep(testUuid);
239
+ if (!currentStep) {
240
+ return;
241
+ }
242
+ this.allureRuntime.updateStep(currentStep, function (stepResult) {
228
243
  stepResult.status = step.error ? _allureJsCommons.Status.FAILED : _allureJsCommons.Status.PASSED;
229
244
  stepResult.stage = _allureJsCommons.Stage.FINISHED;
230
245
  if (step.error) {
231
246
  stepResult.statusDetails = _objectSpread({}, (0, _sdk.getMessageAndTraceFromError)(step.error));
232
247
  }
233
- }, testUuid);
234
- this.allureRuntime.stopStep({
235
- uuid: testUuid
248
+ });
249
+ this.allureRuntime.stopStep(currentStep, {
250
+ duration: step.duration
236
251
  });
237
252
  }
238
253
  }, {
239
254
  key: "onTestEnd",
240
255
  value: function () {
241
256
  var _onTestEnd = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(test, result) {
242
- var _this = this;
243
- var testUuid, threadId, thread, error, _test$parent$titlePat, _test$parent$titlePat2, projectSuiteTitle, fileSuiteTitle, suiteTitles, _iterator, _step, attachment;
257
+ var _this = this,
258
+ _this$attachmentSteps2;
259
+ var testUuid, threadId, thread, error, _test$parent$titlePat, _test$parent$titlePat2, projectSuiteTitle, fileSuiteTitle, suiteTitles, attachmentSteps, i, attachment, attachmentStep;
244
260
  return _regeneratorRuntime().wrap(function _callee$(_context) {
245
261
  while (1) switch (_context.prev = _context.next) {
246
262
  case 0:
247
263
  testUuid = this.allureResultsUuids.get(test.id); // We need to check parallelIndex first because pw introduced this field only in v1.30.0
248
264
  threadId = result.parallelIndex !== undefined ? result.parallelIndex : result.workerIndex;
249
- thread = _nodeProcess["default"].env.ALLURE_THREAD_NAME || "".concat(this.hostname, "-").concat(_nodeProcess["default"].pid, "-playwright-worker-").concat(threadId);
265
+ thread = "pid-".concat(_nodeProcess["default"].pid, "-worker-").concat(threadId);
250
266
  error = result.error; // only apply default suites if not set by user
251
267
  _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);
252
- this.allureRuntime.updateTest(function (testResult) {
253
- testResult.labels.push({
254
- name: _allureJsCommons.LabelName.HOST,
255
- value: _this.hostname
256
- });
257
- testResult.labels.push({
258
- name: _allureJsCommons.LabelName.THREAD,
259
- value: thread
260
- });
268
+ this.allureRuntime.updateTest(testUuid, function (testResult) {
269
+ testResult.labels.push((0, _reporter.getHostLabel)());
270
+ testResult.labels.push((0, _reporter.getThreadLabel)(thread));
261
271
  if (projectSuiteTitle && !(0, _sdk.hasLabel)(testResult, _allureJsCommons.LabelName.PARENT_SUITE)) {
262
272
  testResult.labels.push({
263
273
  name: _allureJsCommons.LabelName.PARENT_SUITE,
@@ -278,56 +288,50 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
278
288
  }
279
289
  if (error) {
280
290
  testResult.statusDetails = _objectSpread({}, (0, _sdk.getMessageAndTraceFromError)(error));
291
+ } else {
292
+ var _test$annotations;
293
+ var skipReason = (_test$annotations = test.annotations) === null || _test$annotations === void 0 || (_test$annotations = _test$annotations.find(function (annotation) {
294
+ return annotation.type === "skip" || annotation.type === "fixme";
295
+ })) === null || _test$annotations === void 0 ? void 0 : _test$annotations.description;
296
+ if (skipReason) {
297
+ testResult.statusDetails = _objectSpread(_objectSpread({}, testResult.statusDetails), {}, {
298
+ message: skipReason
299
+ });
300
+ }
281
301
  }
282
302
  testResult.status = (0, _utils.statusToAllureStats)(result.status, test.expectedStatus);
283
303
  testResult.stage = _allureJsCommons.Stage.FINISHED;
284
- }, testUuid);
285
- _iterator = _createForOfIteratorHelper(result.attachments);
286
- _context.prev = 7;
287
- _iterator.s();
288
- case 9:
289
- if ((_step = _iterator.n()).done) {
290
- _context.next = 15;
304
+ });
305
+ attachmentSteps = (_this$attachmentSteps2 = this.attachmentSteps.get(testUuid)) !== null && _this$attachmentSteps2 !== void 0 ? _this$attachmentSteps2 : [];
306
+ i = 0;
307
+ case 8:
308
+ if (!(i < result.attachments.length)) {
309
+ _context.next = 16;
291
310
  break;
292
311
  }
293
- attachment = _step.value;
312
+ attachment = result.attachments[i];
313
+ attachmentStep = attachmentSteps.length > i ? attachmentSteps[i] : undefined;
294
314
  _context.next = 13;
295
- return this.processAttachment(test.id, attachment);
315
+ return this.processAttachment(testUuid, attachmentStep, attachment);
296
316
  case 13:
297
- _context.next = 9;
298
- break;
299
- case 15:
300
- _context.next = 20;
317
+ i++;
318
+ _context.next = 8;
301
319
  break;
302
- case 17:
303
- _context.prev = 17;
304
- _context.t0 = _context["catch"](7);
305
- _iterator.e(_context.t0);
306
- case 20:
307
- _context.prev = 20;
308
- _iterator.f();
309
- return _context.finish(20);
310
- case 23:
320
+ case 16:
311
321
  if (result.stdout.length > 0) {
312
- this.allureRuntime.writeAttachment({
313
- name: "stdout",
314
- contentType: _allureJsCommons.ContentType.TEXT,
315
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
316
- content: Buffer.from((0, _sdk.stripAnsi)(result.stdout.join("")), "utf8")
317
- }, testUuid);
322
+ this.allureRuntime.writeAttachment(testUuid, undefined, "stdout", Buffer.from((0, _sdk.stripAnsi)(result.stdout.join("")), "utf-8"), {
323
+ contentType: _allureJsCommons.ContentType.TEXT
324
+ });
318
325
  }
319
326
  if (result.stderr.length > 0) {
320
- this.allureRuntime.writeAttachment({
321
- name: "stderr",
322
- contentType: _allureJsCommons.ContentType.TEXT,
323
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
324
- content: Buffer.from((0, _sdk.stripAnsi)(result.stderr.join("")), "utf8")
325
- }, testUuid);
327
+ this.allureRuntime.writeAttachment(testUuid, undefined, "stderr", Buffer.from((0, _sdk.stripAnsi)(result.stderr.join("")), "utf-8"), {
328
+ contentType: _allureJsCommons.ContentType.TEXT
329
+ });
326
330
  }
327
331
 
328
332
  // FIXME: temp logic for labels override, we need it here to keep the reporter compatible with v2 API
329
333
  // in next iterations we need to implement the logic for every javascript integration
330
- this.allureRuntime.updateTest(function (testResult) {
334
+ this.allureRuntime.updateTest(testUuid, function (testResult) {
331
335
  var mappedLabels = testResult.labels.reduce(function (acc, label) {
332
336
  if (!acc[label.name]) {
333
337
  acc[label.name] = [];
@@ -343,16 +347,16 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
343
347
  return labelsGroup;
344
348
  });
345
349
  testResult.labels = newLabels;
346
- }, testUuid);
347
- this.allureRuntime.stopTest({
348
- uuid: testUuid
350
+ });
351
+ this.allureRuntime.stopTest(testUuid, {
352
+ duration: result.duration
349
353
  });
350
354
  this.allureRuntime.writeTest(testUuid);
351
- case 28:
355
+ case 21:
352
356
  case "end":
353
357
  return _context.stop();
354
358
  }
355
- }, _callee, this, [[7, 17, 20, 23]]);
359
+ }, _callee, this);
356
360
  }));
357
361
  function onTestEnd(_x, _x2) {
358
362
  return _onTestEnd.apply(this, arguments);
@@ -364,24 +368,24 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
364
368
  value: function () {
365
369
  var _addSkippedResults = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
366
370
  var _this2 = this;
367
- var unprocessedCases, _iterator2, _step2, testCase;
371
+ var unprocessedCases, _iterator, _step, testCase;
368
372
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
369
373
  while (1) switch (_context2.prev = _context2.next) {
370
374
  case 0:
371
- unprocessedCases = this.suite.allTests().filter(function (_ref) {
372
- var title = _ref.title;
375
+ unprocessedCases = this.suite.allTests().filter(function (_ref2) {
376
+ var title = _ref2.title;
373
377
  var titleMetadata = (0, _sdk.extractMetadataFromString)(title);
374
378
  return !_this2.startedTestCasesTitlesCache.includes(titleMetadata.cleanTitle);
375
379
  });
376
- _iterator2 = _createForOfIteratorHelper(unprocessedCases);
380
+ _iterator = _createForOfIteratorHelper(unprocessedCases);
377
381
  _context2.prev = 2;
378
- _iterator2.s();
382
+ _iterator.s();
379
383
  case 4:
380
- if ((_step2 = _iterator2.n()).done) {
384
+ if ((_step = _iterator.n()).done) {
381
385
  _context2.next = 11;
382
386
  break;
383
387
  }
384
- testCase = _step2.value;
388
+ testCase = _step.value;
385
389
  this.onTestBegin(testCase);
386
390
  _context2.next = 9;
387
391
  return this.onTestEnd(testCase, {
@@ -406,10 +410,10 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
406
410
  case 13:
407
411
  _context2.prev = 13;
408
412
  _context2.t0 = _context2["catch"](2);
409
- _iterator2.e(_context2.t0);
413
+ _iterator.e(_context2.t0);
410
414
  case 16:
411
415
  _context2.prev = 16;
412
- _iterator2.f();
416
+ _iterator.f();
413
417
  return _context2.finish(16);
414
418
  case 19:
415
419
  case "end":
@@ -453,102 +457,104 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
453
457
  }, {
454
458
  key: "processAttachment",
455
459
  value: function () {
456
- var _processAttachment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(testId, attachment) {
457
- var testUuid, allureRuntimeMessage, message, pathWithoutEnd, actualBase64, expectedBase64, diffBase64, diffName;
460
+ var _processAttachment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(testUuid, attachmentStepUuid, attachment) {
461
+ var allureRuntimeMessage, message, parentUuid, pathWithoutEnd, actualBase64, expectedBase64, diffBase64, diffName;
458
462
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
459
463
  while (1) switch (_context4.prev = _context4.next) {
460
464
  case 0:
461
- testUuid = this.allureResultsUuids.get(testId);
462
465
  if (!(!attachment.body && !attachment.path)) {
463
- _context4.next = 3;
466
+ _context4.next = 2;
464
467
  break;
465
468
  }
466
469
  return _context4.abrupt("return");
467
- case 3:
470
+ case 2:
468
471
  allureRuntimeMessage = attachment.contentType === _reporter.ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE;
469
472
  if (!(allureRuntimeMessage && !attachment.body)) {
470
- _context4.next = 6;
473
+ _context4.next = 5;
471
474
  break;
472
475
  }
473
476
  return _context4.abrupt("return");
474
- case 6:
477
+ case 5:
475
478
  if (!allureRuntimeMessage) {
476
- _context4.next = 10;
479
+ _context4.next = 9;
477
480
  break;
478
481
  }
479
- message = JSON.parse(attachment.body.toString()); // TODO: make possible to pass single message and list of them
480
- this.allureRuntime.applyRuntimeMessages([message], {
481
- testUuid: testUuid
482
- });
482
+ message = JSON.parse(attachment.body.toString()); // TODO fix step metadata messages
483
+ this.allureRuntime.applyRuntimeMessages(testUuid, [message]);
483
484
  return _context4.abrupt("return");
484
- case 10:
485
+ case 9:
486
+ parentUuid = this.allureRuntime.startStep(testUuid, attachmentStepUuid, {
487
+ name: attachment.name
488
+ }); // only stop if step is created. Step may not be created only if test with specified uuid doesn't exists.
489
+ // usually, missing test by uuid means we should completely skip result processing;
490
+ // the later operations are safe and will only produce console warnings
491
+ if (parentUuid) {
492
+ this.allureRuntime.stopStep(parentUuid, undefined);
493
+ }
485
494
  if (!attachment.body) {
486
- _context4.next = 14;
495
+ _context4.next = 15;
487
496
  break;
488
497
  }
489
- this.allureRuntime.writeAttachment({
490
- name: attachment.name,
491
- contentType: attachment.contentType,
492
- content: attachment.body
493
- }, testUuid);
494
- _context4.next = 19;
498
+ this.allureRuntime.writeAttachment(testUuid, parentUuid, attachment.name, attachment.body, {
499
+ contentType: attachment.contentType
500
+ });
501
+ _context4.next = 20;
495
502
  break;
496
- case 14:
503
+ case 15:
497
504
  if ((0, _nodeFs.existsSync)(attachment.path)) {
498
- _context4.next = 18;
505
+ _context4.next = 19;
499
506
  break;
500
507
  }
501
508
  return _context4.abrupt("return");
502
- case 18:
503
- this.allureRuntime.writeAttachmentFromPath(attachment.name, attachment.path, {
504
- contentType: attachment.contentType
505
- }, testUuid);
506
509
  case 19:
510
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
511
+ this.allureRuntime.writeAttachment(testUuid, parentUuid, attachment.name, attachment.path, {
512
+ contentType: attachment.contentType
513
+ });
514
+ case 20:
507
515
  if (attachment.name.match(diffEndRegexp)) {
508
- _context4.next = 21;
516
+ _context4.next = 22;
509
517
  break;
510
518
  }
511
519
  return _context4.abrupt("return");
512
- case 21:
520
+ case 22:
513
521
  pathWithoutEnd = attachment.path.replace(diffEndRegexp, "");
514
522
  if (!this.processedDiffs.includes(pathWithoutEnd)) {
515
- _context4.next = 24;
523
+ _context4.next = 25;
516
524
  break;
517
525
  }
518
526
  return _context4.abrupt("return");
519
- case 24:
520
- _context4.next = 26;
527
+ case 25:
528
+ _context4.next = 27;
521
529
  return (0, _reporter.readImageAsBase64)("".concat(pathWithoutEnd, "-actual.png"));
522
- case 26:
530
+ case 27:
523
531
  actualBase64 = _context4.sent;
524
- _context4.next = 29;
532
+ _context4.next = 30;
525
533
  return (0, _reporter.readImageAsBase64)("".concat(pathWithoutEnd, "-expected.png"));
526
- case 29:
534
+ case 30:
527
535
  expectedBase64 = _context4.sent;
528
- _context4.next = 32;
536
+ _context4.next = 33;
529
537
  return (0, _reporter.readImageAsBase64)("".concat(pathWithoutEnd, "-diff.png"));
530
- case 32:
538
+ case 33:
531
539
  diffBase64 = _context4.sent;
532
540
  diffName = attachment.name.replace(diffEndRegexp, "");
533
- this.allureRuntime.writeAttachment({
534
- name: diffName,
535
- content: JSON.stringify({
536
- expected: expectedBase64,
537
- actual: actualBase64,
538
- diff: diffBase64,
539
- name: diffName
540
- }),
541
+ this.allureRuntime.writeAttachment(testUuid, undefined, diffName, Buffer.from(JSON.stringify({
542
+ expected: expectedBase64,
543
+ actual: actualBase64,
544
+ diff: diffBase64,
545
+ name: diffName
546
+ }), "utf-8"), {
541
547
  contentType: _allureJsCommons.ContentType.IMAGEDIFF,
542
548
  fileExtension: ".imagediff"
543
- }, testUuid);
549
+ });
544
550
  this.processedDiffs.push(pathWithoutEnd);
545
- case 36:
551
+ case 37:
546
552
  case "end":
547
553
  return _context4.stop();
548
554
  }
549
555
  }, _callee4, this);
550
556
  }));
551
- function processAttachment(_x3, _x4) {
557
+ function processAttachment(_x3, _x4, _x5) {
552
558
  return _processAttachment.apply(this, arguments);
553
559
  }
554
560
  return processAttachment;