allure-playwright 3.0.0-beta.2 → 3.0.0-beta.4

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/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  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); }
2
- 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; }
3
2
  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; } } }; }
3
+ 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; }
4
4
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
5
5
  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); }); }; }
6
6
  function _toArray(r) { return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest(); }
@@ -46,6 +46,7 @@ export var AllureReporter = /*#__PURE__*/function () {
46
46
  _defineProperty(this, "processedDiffs", []);
47
47
  _defineProperty(this, "startedTestCasesTitlesCache", []);
48
48
  _defineProperty(this, "allureResultsUuids", new Map());
49
+ _defineProperty(this, "attachmentSteps", new Map());
49
50
  this.options = _objectSpread({
50
51
  suiteTitle: true,
51
52
  detail: true
@@ -72,6 +73,7 @@ export var AllureReporter = /*#__PURE__*/function () {
72
73
  var v2ReporterTests = [];
73
74
  var cliArgs = [];
74
75
  testsWithSelectors.forEach(function (test) {
76
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
75
77
  if (!/#/.test(test.selector)) {
76
78
  v2ReporterTests.push(test);
77
79
  return;
@@ -80,7 +82,9 @@ export var AllureReporter = /*#__PURE__*/function () {
80
82
  });
81
83
  if (v2ReporterTests.length) {
82
84
  // we need to cut off column because playwright works only with line number
83
- var v2SelectorsArgs = v2ReporterTests.map(function (test) {
85
+ var v2SelectorsArgs = v2ReporterTests
86
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
87
+ .map(function (test) {
84
88
  return test.selector.replace(/:\d+$/, "");
85
89
  }).map(function (selector) {
86
90
  return escapeRegExp(selector);
@@ -90,6 +94,7 @@ export var AllureReporter = /*#__PURE__*/function () {
90
94
  if (v1ReporterTests.length) {
91
95
  var v1SelectorsArgs = v1ReporterTests
92
96
  // we can filter tests only by absolute path, so we need to cut off test name
97
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
93
98
  .map(function (test) {
94
99
  return test.selector.split("#")[0];
95
100
  }).map(function (selector) {
@@ -119,7 +124,7 @@ export var AllureReporter = /*#__PURE__*/function () {
119
124
  }, {
120
125
  key: "onBegin",
121
126
  value: function onBegin(suite) {
122
- var writer = this.options.testMode ? new MessageWriter() : new FileSystemWriter({
127
+ var writer = process.env.ALLURE_TEST_MODE ? new MessageWriter() : new FileSystemWriter({
123
128
  resultsDir: this.options.resultsDir || "./allure-results"
124
129
  });
125
130
  this.suite = suite;
@@ -179,19 +184,22 @@ export var AllureReporter = /*#__PURE__*/function () {
179
184
  }, {
180
185
  key: "onStepBegin",
181
186
  value: function onStepBegin(test, _result, step) {
182
- if (!this.options.detail && step.category !== "test.step") {
187
+ var testUuid = this.allureResultsUuids.get(test.id);
188
+ if (step.category === "attach") {
189
+ var _this$allureRuntime, _this$attachmentSteps;
190
+ var currentStep = (_this$allureRuntime = this.allureRuntime) === null || _this$allureRuntime === void 0 ? void 0 : _this$allureRuntime.currentStep(testUuid);
191
+ this.attachmentSteps.set(testUuid, [].concat(_toConsumableArray((_this$attachmentSteps = this.attachmentSteps.get(testUuid)) !== null && _this$attachmentSteps !== void 0 ? _this$attachmentSteps : []), [currentStep]));
183
192
  return;
184
193
  }
185
194
 
186
- // ignore attach steps since attachments are already in the report
187
- if (step.category === "attach") {
195
+ // TODO fix the details disable, e.g. only ignore pw:api steps
196
+ if (!this.options.detail && step.category !== "test.step") {
188
197
  return;
189
198
  }
190
- var testUuid = this.allureResultsUuids.get(test.id);
191
- this.allureRuntime.startStep({
199
+ this.allureRuntime.startStep(testUuid, undefined, {
192
200
  name: step.title.substring(0, stepAttachPrefixLength),
193
201
  start: step.startTime.getTime()
194
- }, testUuid);
202
+ });
195
203
  }
196
204
  }, {
197
205
  key: "onStepEnd",
@@ -205,23 +213,26 @@ export var AllureReporter = /*#__PURE__*/function () {
205
213
  return;
206
214
  }
207
215
  var testUuid = this.allureResultsUuids.get(test.id);
208
- this.allureRuntime.updateStep(function (stepResult) {
216
+ var currentStep = this.allureRuntime.currentStep(testUuid);
217
+ if (!currentStep) {
218
+ return;
219
+ }
220
+ this.allureRuntime.updateStep(currentStep, function (stepResult) {
209
221
  stepResult.status = step.error ? Status.FAILED : Status.PASSED;
210
222
  stepResult.stage = Stage.FINISHED;
211
223
  if (step.error) {
212
224
  stepResult.statusDetails = _objectSpread({}, getMessageAndTraceFromError(step.error));
213
225
  }
214
- }, testUuid);
215
- this.allureRuntime.stopStep({
216
- uuid: testUuid
217
226
  });
227
+ this.allureRuntime.stopStep(currentStep, step.startTime.getTime() + step.duration);
218
228
  }
219
229
  }, {
220
230
  key: "onTestEnd",
221
231
  value: function () {
222
232
  var _onTestEnd = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(test, result) {
223
- var _this = this;
224
- var testUuid, threadId, thread, error, _test$parent$titlePat, _test$parent$titlePat2, projectSuiteTitle, fileSuiteTitle, suiteTitles, _iterator, _step, attachment;
233
+ var _this = this,
234
+ _this$attachmentSteps2;
235
+ var testUuid, threadId, thread, error, _test$parent$titlePat, _test$parent$titlePat2, projectSuiteTitle, fileSuiteTitle, suiteTitles, attachmentSteps, i, attachment, attachmentStep;
225
236
  return _regeneratorRuntime().wrap(function _callee$(_context) {
226
237
  while (1) switch (_context.prev = _context.next) {
227
238
  case 0:
@@ -230,7 +241,7 @@ export var AllureReporter = /*#__PURE__*/function () {
230
241
  thread = process.env.ALLURE_THREAD_NAME || "".concat(this.hostname, "-").concat(process.pid, "-playwright-worker-").concat(threadId);
231
242
  error = result.error; // only apply default suites if not set by user
232
243
  _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);
233
- this.allureRuntime.updateTest(function (testResult) {
244
+ this.allureRuntime.updateTest(testUuid, function (testResult) {
234
245
  testResult.labels.push({
235
246
  name: LabelName.HOST,
236
247
  value: _this.hostname
@@ -262,47 +273,37 @@ export var AllureReporter = /*#__PURE__*/function () {
262
273
  }
263
274
  testResult.status = statusToAllureStats(result.status, test.expectedStatus);
264
275
  testResult.stage = Stage.FINISHED;
265
- }, testUuid);
266
- _iterator = _createForOfIteratorHelper(result.attachments);
267
- _context.prev = 7;
268
- _iterator.s();
269
- case 9:
270
- if ((_step = _iterator.n()).done) {
271
- _context.next = 15;
276
+ });
277
+ attachmentSteps = (_this$attachmentSteps2 = this.attachmentSteps.get(testUuid)) !== null && _this$attachmentSteps2 !== void 0 ? _this$attachmentSteps2 : [];
278
+ i = 0;
279
+ case 8:
280
+ if (!(i < result.attachments.length)) {
281
+ _context.next = 16;
272
282
  break;
273
283
  }
274
- attachment = _step.value;
284
+ attachment = result.attachments[i];
285
+ attachmentStep = attachmentSteps.length > i ? attachmentSteps[i] : undefined;
275
286
  _context.next = 13;
276
- return this.processAttachment(test.id, attachment);
287
+ return this.processAttachment(testUuid, attachmentStep, attachment);
277
288
  case 13:
278
- _context.next = 9;
289
+ i++;
290
+ _context.next = 8;
279
291
  break;
280
- case 15:
281
- _context.next = 20;
282
- break;
283
- case 17:
284
- _context.prev = 17;
285
- _context.t0 = _context["catch"](7);
286
- _iterator.e(_context.t0);
287
- case 20:
288
- _context.prev = 20;
289
- _iterator.f();
290
- return _context.finish(20);
291
- case 23:
292
+ case 16:
292
293
  if (result.stdout.length > 0) {
293
- this.allureRuntime.writeAttachment("stdout", Buffer.from(stripAnsi(result.stdout.join("")), "utf-8"), {
294
+ this.allureRuntime.writeAttachment(testUuid, undefined, "stdout", Buffer.from(stripAnsi(result.stdout.join("")), "utf-8"), {
294
295
  contentType: ContentType.TEXT
295
- }, testUuid);
296
+ });
296
297
  }
297
298
  if (result.stderr.length > 0) {
298
- this.allureRuntime.writeAttachment("stderr", Buffer.from(stripAnsi(result.stderr.join("")), "utf-8"), {
299
+ this.allureRuntime.writeAttachment(testUuid, undefined, "stderr", Buffer.from(stripAnsi(result.stderr.join("")), "utf-8"), {
299
300
  contentType: ContentType.TEXT
300
- }, testUuid);
301
+ });
301
302
  }
302
303
 
303
304
  // FIXME: temp logic for labels override, we need it here to keep the reporter compatible with v2 API
304
305
  // in next iterations we need to implement the logic for every javascript integration
305
- this.allureRuntime.updateTest(function (testResult) {
306
+ this.allureRuntime.updateTest(testUuid, function (testResult) {
306
307
  var mappedLabels = testResult.labels.reduce(function (acc, label) {
307
308
  if (!acc[label.name]) {
308
309
  acc[label.name] = [];
@@ -318,16 +319,14 @@ export var AllureReporter = /*#__PURE__*/function () {
318
319
  return labelsGroup;
319
320
  });
320
321
  testResult.labels = newLabels;
321
- }, testUuid);
322
- this.allureRuntime.stopTest({
323
- uuid: testUuid
324
322
  });
323
+ this.allureRuntime.stopTest(testUuid, result.startTime.getTime() + result.duration);
325
324
  this.allureRuntime.writeTest(testUuid);
326
- case 28:
325
+ case 21:
327
326
  case "end":
328
327
  return _context.stop();
329
328
  }
330
- }, _callee, this, [[7, 17, 20, 23]]);
329
+ }, _callee, this);
331
330
  }));
332
331
  function onTestEnd(_x, _x2) {
333
332
  return _onTestEnd.apply(this, arguments);
@@ -339,7 +338,7 @@ export var AllureReporter = /*#__PURE__*/function () {
339
338
  value: function () {
340
339
  var _addSkippedResults = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
341
340
  var _this2 = this;
342
- var unprocessedCases, _iterator2, _step2, testCase;
341
+ var unprocessedCases, _iterator, _step, testCase;
343
342
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
344
343
  while (1) switch (_context2.prev = _context2.next) {
345
344
  case 0:
@@ -348,15 +347,15 @@ export var AllureReporter = /*#__PURE__*/function () {
348
347
  var titleMetadata = extractMetadataFromString(title);
349
348
  return !_this2.startedTestCasesTitlesCache.includes(titleMetadata.cleanTitle);
350
349
  });
351
- _iterator2 = _createForOfIteratorHelper(unprocessedCases);
350
+ _iterator = _createForOfIteratorHelper(unprocessedCases);
352
351
  _context2.prev = 2;
353
- _iterator2.s();
352
+ _iterator.s();
354
353
  case 4:
355
- if ((_step2 = _iterator2.n()).done) {
354
+ if ((_step = _iterator.n()).done) {
356
355
  _context2.next = 11;
357
356
  break;
358
357
  }
359
- testCase = _step2.value;
358
+ testCase = _step.value;
360
359
  this.onTestBegin(testCase);
361
360
  _context2.next = 9;
362
361
  return this.onTestEnd(testCase, {
@@ -381,10 +380,10 @@ export var AllureReporter = /*#__PURE__*/function () {
381
380
  case 13:
382
381
  _context2.prev = 13;
383
382
  _context2.t0 = _context2["catch"](2);
384
- _iterator2.e(_context2.t0);
383
+ _iterator.e(_context2.t0);
385
384
  case 16:
386
385
  _context2.prev = 16;
387
- _iterator2.f();
386
+ _iterator.f();
388
387
  return _context2.finish(16);
389
388
  case 19:
390
389
  case "end":
@@ -428,82 +427,88 @@ export var AllureReporter = /*#__PURE__*/function () {
428
427
  }, {
429
428
  key: "processAttachment",
430
429
  value: function () {
431
- var _processAttachment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(testId, attachment) {
432
- var testUuid, allureRuntimeMessage, message, pathWithoutEnd, actualBase64, expectedBase64, diffBase64, diffName;
430
+ var _processAttachment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(testUuid, attachmentStepUuid, attachment) {
431
+ var allureRuntimeMessage, message, parentUuid, pathWithoutEnd, actualBase64, expectedBase64, diffBase64, diffName;
433
432
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
434
433
  while (1) switch (_context4.prev = _context4.next) {
435
434
  case 0:
436
- testUuid = this.allureResultsUuids.get(testId);
437
435
  if (!(!attachment.body && !attachment.path)) {
438
- _context4.next = 3;
436
+ _context4.next = 2;
439
437
  break;
440
438
  }
441
439
  return _context4.abrupt("return");
442
- case 3:
440
+ case 2:
443
441
  allureRuntimeMessage = attachment.contentType === ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE;
444
442
  if (!(allureRuntimeMessage && !attachment.body)) {
445
- _context4.next = 6;
443
+ _context4.next = 5;
446
444
  break;
447
445
  }
448
446
  return _context4.abrupt("return");
449
- case 6:
447
+ case 5:
450
448
  if (!allureRuntimeMessage) {
451
- _context4.next = 10;
449
+ _context4.next = 9;
452
450
  break;
453
451
  }
454
- message = JSON.parse(attachment.body.toString()); // TODO: make possible to pass single message and list of them
455
- this.allureRuntime.applyRuntimeMessages([message], {
456
- testUuid: testUuid
457
- });
452
+ message = JSON.parse(attachment.body.toString()); // TODO fix step metadata messages
453
+ this.allureRuntime.applyRuntimeMessages(testUuid, [message]);
458
454
  return _context4.abrupt("return");
459
- case 10:
455
+ case 9:
456
+ parentUuid = this.allureRuntime.startStep(testUuid, attachmentStepUuid, {
457
+ name: attachment.name
458
+ }); // only stop if step is created. Step may not be created only if test with specified uuid doesn't exists.
459
+ // usually, missing test by uuid means we should completely skip result processing;
460
+ // the later operations are safe and will only produce console warnings
461
+ if (parentUuid) {
462
+ this.allureRuntime.stopStep(parentUuid, undefined);
463
+ }
460
464
  if (!attachment.body) {
461
- _context4.next = 14;
465
+ _context4.next = 15;
462
466
  break;
463
467
  }
464
- this.allureRuntime.writeAttachment(attachment.name, attachment.body, {
468
+ this.allureRuntime.writeAttachment(testUuid, parentUuid, attachment.name, attachment.body, {
465
469
  contentType: attachment.contentType
466
- }, testUuid);
467
- _context4.next = 19;
470
+ });
471
+ _context4.next = 20;
468
472
  break;
469
- case 14:
473
+ case 15:
470
474
  if (existsSync(attachment.path)) {
471
- _context4.next = 18;
475
+ _context4.next = 19;
472
476
  break;
473
477
  }
474
478
  return _context4.abrupt("return");
475
- case 18:
476
- this.allureRuntime.writeAttachmentFromPath(attachment.name, attachment.path, {
477
- contentType: attachment.contentType
478
- }, testUuid);
479
479
  case 19:
480
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
481
+ this.allureRuntime.writeAttachment(testUuid, parentUuid, attachment.name, attachment.path, {
482
+ contentType: attachment.contentType
483
+ });
484
+ case 20:
480
485
  if (attachment.name.match(diffEndRegexp)) {
481
- _context4.next = 21;
486
+ _context4.next = 22;
482
487
  break;
483
488
  }
484
489
  return _context4.abrupt("return");
485
- case 21:
490
+ case 22:
486
491
  pathWithoutEnd = attachment.path.replace(diffEndRegexp, "");
487
492
  if (!this.processedDiffs.includes(pathWithoutEnd)) {
488
- _context4.next = 24;
493
+ _context4.next = 25;
489
494
  break;
490
495
  }
491
496
  return _context4.abrupt("return");
492
- case 24:
493
- _context4.next = 26;
497
+ case 25:
498
+ _context4.next = 27;
494
499
  return readImageAsBase64("".concat(pathWithoutEnd, "-actual.png"));
495
- case 26:
500
+ case 27:
496
501
  actualBase64 = _context4.sent;
497
- _context4.next = 29;
502
+ _context4.next = 30;
498
503
  return readImageAsBase64("".concat(pathWithoutEnd, "-expected.png"));
499
- case 29:
504
+ case 30:
500
505
  expectedBase64 = _context4.sent;
501
- _context4.next = 32;
506
+ _context4.next = 33;
502
507
  return readImageAsBase64("".concat(pathWithoutEnd, "-diff.png"));
503
- case 32:
508
+ case 33:
504
509
  diffBase64 = _context4.sent;
505
510
  diffName = attachment.name.replace(diffEndRegexp, "");
506
- this.allureRuntime.writeAttachment(diffName, Buffer.from(JSON.stringify({
511
+ this.allureRuntime.writeAttachment(testUuid, undefined, diffName, Buffer.from(JSON.stringify({
507
512
  expected: expectedBase64,
508
513
  actual: actualBase64,
509
514
  diff: diffBase64,
@@ -511,15 +516,15 @@ export var AllureReporter = /*#__PURE__*/function () {
511
516
  }), "utf-8"), {
512
517
  contentType: ContentType.IMAGEDIFF,
513
518
  fileExtension: ".imagediff"
514
- }, testUuid);
519
+ });
515
520
  this.processedDiffs.push(pathWithoutEnd);
516
- case 36:
521
+ case 37:
517
522
  case "end":
518
523
  return _context4.stop();
519
524
  }
520
525
  }, _callee4, this);
521
526
  }));
522
- function processAttachment(_x3, _x4) {
527
+ function processAttachment(_x3, _x4, _x5) {
523
528
  return _processAttachment.apply(this, arguments);
524
529
  }
525
530
  return processAttachment;