allure-playwright 3.7.2 → 3.9.0

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
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- 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); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
@@ -19,6 +18,7 @@ Object.defineProperty(exports, "test", {
19
18
  });
20
19
  var _nodeFs = require("node:fs");
21
20
  var _promises = require("node:fs/promises");
21
+ var _nodeModule = require("node:module");
22
22
  var _nodePath = _interopRequireDefault(require("node:path"));
23
23
  var _nodeProcess = _interopRequireDefault(require("node:process"));
24
24
  var _allureJsCommons = require("allure-js-commons");
@@ -28,11 +28,11 @@ var _legacy = require("./legacy.js");
28
28
  var _utils = require("./utils.js");
29
29
  var _test = require("@playwright/test");
30
30
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
31
- function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
32
- function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
33
31
  function _toArray(r) { return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest(); }
34
32
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
35
33
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
34
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
35
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
36
36
  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); }
37
37
  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); }); }; }
38
38
  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; } } }; }
@@ -42,6 +42,7 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
42
42
  function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
43
43
  function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
44
44
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
45
+ 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); }
45
46
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
46
47
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
47
48
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
@@ -53,6 +54,9 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
53
54
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
54
55
  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); }
55
56
  function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); } /* eslint max-lines: off */
57
+ var localRequire = typeof require === "function" ? require : (0, _nodeModule.createRequire)(require('url').pathToFileURL(__filename).toString());
58
+ var testPlanFilterSymbol = Symbol["for"]("allure-playwright.testPlanFilter");
59
+ var testPlanFilterPatchSymbol = Symbol["for"]("allure-playwright.testPlanFilterPatch");
56
60
  var _AllureReporter_brand = /*#__PURE__*/new WeakSet();
57
61
  var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
58
62
  function AllureReporter(config) {
@@ -71,6 +75,8 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
71
75
  _defineProperty(this, "attachmentTargets", new Map());
72
76
  _defineProperty(this, "beforeHooksStepsStack", new Map());
73
77
  _defineProperty(this, "afterHooksStepsStack", new Map());
78
+ _defineProperty(this, "pendingAttachmentTasks", new Map());
79
+ _defineProperty(this, "attachmentTargetByStep", new WeakMap());
74
80
  _defineProperty(this, "pwStepUuid", new WeakMap());
75
81
  _defineProperty(this, "testPlan", (0, _reporter.parseTestPlan)());
76
82
  this.options = _objectSpread({
@@ -81,7 +87,8 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
81
87
  return _createClass(AllureReporter, [{
82
88
  key: "onConfigure",
83
89
  value: function onConfigure(config) {
84
- var _this = this;
90
+ var _configElement$preOnl,
91
+ _this = this;
85
92
  this.config = config;
86
93
  this.outputDir = config.projects[0].outputDir;
87
94
  this.snapshotDir = config.projects[0].snapshotDir;
@@ -89,13 +96,13 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
89
96
  if (!testPlan) {
90
97
  return;
91
98
  }
92
-
93
- // @ts-ignore
94
- var configElement = config[Object.getOwnPropertySymbols(config)[0]];
95
- if (!configElement) {
96
- return;
97
- }
98
- configElement.preOnlyTestFilters.push(function (test) {
99
+ this.installTestPlanExecutionFilter();
100
+ var configElement = Object.getOwnPropertySymbols(config).map(function (symbol) {
101
+ return config[symbol];
102
+ }).find(function (value) {
103
+ return _typeof(value) === "object" && value !== null && ("preOnlyTestFilters" in value || "cliArgs" in value);
104
+ });
105
+ configElement === null || configElement === void 0 || (_configElement$preOnl = configElement.preOnlyTestFilters) === null || _configElement$preOnl === void 0 || _configElement$preOnl.push(function (test) {
99
106
  return _this.isInTestPlan(test);
100
107
  });
101
108
  if (testPlan.tests.some(function (test) {
@@ -143,7 +150,9 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
143
150
  if (!cliArgs.length) {
144
151
  return;
145
152
  }
146
- configElement.cliArgs = cliArgs;
153
+ if (configElement) {
154
+ configElement.cliArgs = cliArgs;
155
+ }
147
156
  }
148
157
  }, {
149
158
  key: "onError",
@@ -172,6 +181,7 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
172
181
  value: function onTestBegin(test) {
173
182
  var _metadata$relativeFil, _metadata$project, _metadata$project2;
174
183
  var metadata = this.getStaticTestMetadata(test);
184
+ var titlePath = metadata.projectName ? [metadata.projectName].concat(_toConsumableArray(metadata.relativeFileParts), _toConsumableArray(metadata.suiteTitles)) : (_metadata$relativeFil = metadata.relativeFileParts).concat.apply(_metadata$relativeFil, _toConsumableArray(metadata.suiteTitles));
175
185
  var result = {
176
186
  name: metadata.titleMetadata.cleanTitle,
177
187
  labels: [].concat(_toConsumableArray(metadata.titleMetadata.labels), _toConsumableArray((0, _reporter.getEnvironmentLabels)())),
@@ -180,11 +190,12 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
180
190
  steps: [],
181
191
  testCaseId: (0, _reporter.md5)(metadata.testCaseIdBase),
182
192
  fullName: metadata.fullName,
183
- titlePath: (_metadata$relativeFil = metadata.relativeFileParts).concat.apply(_metadata$relativeFil, _toConsumableArray(metadata.suiteTitles))
193
+ titlePath: titlePath
184
194
  };
185
195
  result.labels.push((0, _reporter.getLanguageLabel)());
186
196
  result.labels.push((0, _reporter.getFrameworkLabel)("playwright"));
187
- result.labels.push((0, _reporter.getPackageLabel)(metadata.testFilePath));
197
+ result.labels.push((0, _reporter.getPackageLabel)(metadata.testFilePath, metadata.projectRootSearchFrom));
198
+ result.labels.push((0, _reporter.getFallbackTestCaseIdLabel)((0, _reporter.md5)(metadata.legacyTestCaseIdBase)));
188
199
  result.labels.push({
189
200
  name: "titlePath",
190
201
  value: test.parent.titlePath().join(" > ")
@@ -267,17 +278,275 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
267
278
  this.allureResultsUuids.set(test.id, testUuid);
268
279
  this.startedTestCasesTitlesCache.push(metadata.titleMetadata.cleanTitle);
269
280
  }
281
+ }, {
282
+ key: "queueAttachmentTask",
283
+ value: function queueAttachmentTask(testId, task) {
284
+ var _this$pendingAttachme;
285
+ var tasks = (_this$pendingAttachme = this.pendingAttachmentTasks.get(testId)) !== null && _this$pendingAttachme !== void 0 ? _this$pendingAttachme : [];
286
+ tasks.push(task);
287
+ this.pendingAttachmentTasks.set(testId, tasks);
288
+ }
289
+ }, {
290
+ key: "flushAttachmentTasks",
291
+ value: function () {
292
+ var _flushAttachmentTasks = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(testId) {
293
+ var _this$pendingAttachme2;
294
+ var tasks;
295
+ return _regenerator().w(function (_context) {
296
+ while (1) switch (_context.n) {
297
+ case 0:
298
+ tasks = (_this$pendingAttachme2 = this.pendingAttachmentTasks.get(testId)) !== null && _this$pendingAttachme2 !== void 0 ? _this$pendingAttachme2 : [];
299
+ this.pendingAttachmentTasks["delete"](testId);
300
+ if (!(tasks.length > 0)) {
301
+ _context.n = 1;
302
+ break;
303
+ }
304
+ _context.n = 1;
305
+ return Promise.all(tasks);
306
+ case 1:
307
+ return _context.a(2);
308
+ }
309
+ }, _callee, this);
310
+ }));
311
+ function flushAttachmentTasks(_x) {
312
+ return _flushAttachmentTasks.apply(this, arguments);
313
+ }
314
+ return flushAttachmentTasks;
315
+ }()
316
+ }, {
317
+ key: "recordAttachmentTarget",
318
+ value: function recordAttachmentTarget(testId, target) {
319
+ var _this$attachmentTarge;
320
+ var targets = (_this$attachmentTarge = this.attachmentTargets.get(testId)) !== null && _this$attachmentTarge !== void 0 ? _this$attachmentTarge : [];
321
+ targets.push(target);
322
+ this.attachmentTargets.set(testId, targets);
323
+ }
324
+ }, {
325
+ key: "getHookStepsStack",
326
+ value: function getHookStepsStack(testId, hookStep) {
327
+ return hookStep.hookScope === "before" ? this.beforeHooksStepsStack.get(testId) : this.afterHooksStepsStack.get(testId);
328
+ }
329
+ }, {
330
+ key: "removeHookAttachmentPlaceholder",
331
+ value: function removeHookAttachmentPlaceholder(steps, stepUuid) {
332
+ var index = steps.findIndex(function (step) {
333
+ return step.uuid === stepUuid;
334
+ });
335
+ if (index !== -1) {
336
+ steps.splice(index, 1);
337
+ return true;
338
+ }
339
+ var _iterator2 = _createForOfIteratorHelper(steps),
340
+ _step2;
341
+ try {
342
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
343
+ var step = _step2.value;
344
+ if (this.removeHookAttachmentPlaceholder(step.steps, stepUuid)) {
345
+ return true;
346
+ }
347
+ }
348
+ } catch (err) {
349
+ _iterator2.e(err);
350
+ } finally {
351
+ _iterator2.f();
352
+ }
353
+ return false;
354
+ }
355
+ }, {
356
+ key: "addAttachmentToHookStep",
357
+ value: function addAttachmentToHookStep(test, hookStep, attachment) {
358
+ var targetStack = this.getHookStepsStack(test.id, hookStep);
359
+ if (!targetStack) {
360
+ return;
361
+ }
362
+ var stepResult = targetStack.findStepByUuid(hookStep.uuid);
363
+ if (!stepResult) {
364
+ return;
365
+ }
366
+ var fileName = targetStack.addAttachment(attachment, this.allureRuntime.writer);
367
+ stepResult.attachments.push({
368
+ name: attachment.name,
369
+ type: attachment.contentType,
370
+ source: fileName
371
+ });
372
+ }
373
+ }, {
374
+ key: "addRuntimeAttachmentToHookStack",
375
+ value: function addRuntimeAttachmentToHookStack(targetStack, attachment, options) {
376
+ var _this2 = this;
377
+ var currentStep = targetStack.currentStep();
378
+ if (!currentStep) {
379
+ return;
380
+ }
381
+ var addAttachment = function addAttachment(stepResult) {
382
+ var fileName = targetStack.addAttachment(attachment, _this2.allureRuntime.writer);
383
+ stepResult.attachments.push({
384
+ name: attachment.name,
385
+ type: attachment.contentType,
386
+ source: fileName
387
+ });
388
+ };
389
+ if (options !== null && options !== void 0 && options.wrapInStep) {
390
+ targetStack.startStep({
391
+ name: attachment.name,
392
+ start: options.timestamp
393
+ });
394
+ addAttachment(targetStack.currentStep());
395
+ targetStack.stopStep({
396
+ stop: options.timestamp
397
+ });
398
+ return;
399
+ }
400
+ addAttachment(currentStep);
401
+ }
402
+ }, {
403
+ key: "processHookRuntimeMessage",
404
+ value: function processHookRuntimeMessage(test, testUuid, hookStep, attachment) {
405
+ if (!attachment.body) {
406
+ return false;
407
+ }
408
+ var targetStack = this.getHookStepsStack(test.id, hookStep);
409
+ if (!targetStack) {
410
+ return false;
411
+ }
412
+ this.removeHookAttachmentPlaceholder(targetStack.steps, hookStep.uuid);
413
+ var message = JSON.parse(attachment.body.toString());
414
+ switch (message.type) {
415
+ case "step_start":
416
+ targetStack.startStep(_objectSpread({}, message.data));
417
+ return true;
418
+ case "step_stop":
419
+ {
420
+ var currentStep = targetStack.currentStep();
421
+ if (!currentStep) {
422
+ return false;
423
+ }
424
+ targetStack.updateStep(function (stepResult) {
425
+ if (message.data.status && !stepResult.status) {
426
+ stepResult.status = message.data.status;
427
+ }
428
+ if (message.data.statusDetails) {
429
+ stepResult.statusDetails = _objectSpread(_objectSpread({}, stepResult.statusDetails), message.data.statusDetails);
430
+ }
431
+ });
432
+ targetStack.stopStep({
433
+ stop: message.data.stop
434
+ });
435
+ return true;
436
+ }
437
+ case "step_metadata":
438
+ {
439
+ var _currentStep$paramete, _message$data$paramet;
440
+ var _currentStep = targetStack.currentStep();
441
+ if (!_currentStep) {
442
+ return false;
443
+ }
444
+ if (message.data.name) {
445
+ _currentStep.name = message.data.name;
446
+ }
447
+ (_currentStep$paramete = _currentStep.parameters).push.apply(_currentStep$paramete, _toConsumableArray((_message$data$paramet = message.data.parameters) !== null && _message$data$paramet !== void 0 ? _message$data$paramet : []));
448
+ return true;
449
+ }
450
+ case "attachment_content":
451
+ this.addRuntimeAttachmentToHookStack(targetStack, {
452
+ name: message.data.name,
453
+ body: Buffer.from(message.data.content, message.data.encoding),
454
+ contentType: message.data.contentType
455
+ }, {
456
+ wrapInStep: message.data.wrapInStep,
457
+ timestamp: message.data.timestamp
458
+ });
459
+ return true;
460
+ case "attachment_path":
461
+ this.addRuntimeAttachmentToHookStack(targetStack, {
462
+ name: message.data.name,
463
+ path: message.data.path,
464
+ contentType: message.data.contentType
465
+ }, {
466
+ wrapInStep: message.data.wrapInStep,
467
+ timestamp: message.data.timestamp
468
+ });
469
+ return true;
470
+ default:
471
+ this.queueAttachmentTask(test.id, this.processAttachment(testUuid, undefined, attachment));
472
+ return true;
473
+ }
474
+ }
475
+ }, {
476
+ key: "shouldProcessAttachmentAtTestEnd",
477
+ value: function shouldProcessAttachmentAtTestEnd(attachment) {
478
+ if (attachment.name.match(_utils.diffEndRegexp)) {
479
+ return true;
480
+ }
481
+ if (attachment.contentType === "application/vnd.allure.playwright-trace") {
482
+ return true;
483
+ }
484
+ return attachment.name === "trace" && attachment.contentType === "application/zip";
485
+ }
486
+ }, {
487
+ key: "processStepEndAttachments",
488
+ value: function processStepEndAttachments(test, step) {
489
+ var _step$attachments;
490
+ var testUuid = this.allureResultsUuids.get(test.id);
491
+ var stepAttachments = (_step$attachments = step.attachments) !== null && _step$attachments !== void 0 ? _step$attachments : [];
492
+ var stepInfo = this.attachmentTargetByStep.get(step);
493
+ var hasExplicitParent = Boolean((stepInfo === null || stepInfo === void 0 ? void 0 : stepInfo.hookStep) || (stepInfo === null || stepInfo === void 0 ? void 0 : stepInfo.stepUuid));
494
+ if (stepAttachments.length === 0) {
495
+ if (stepInfo) {
496
+ this.recordAttachmentTarget(test.id, stepInfo);
497
+ }
498
+ return;
499
+ }
500
+ var _iterator3 = _createForOfIteratorHelper(stepAttachments),
501
+ _step3;
502
+ try {
503
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
504
+ var _stepInfo$hookStep$uu, _stepInfo$hookStep;
505
+ var attachment = _step3.value;
506
+ var isRuntimeMessage = attachment.contentType === _reporter.ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE;
507
+ var attachmentTarget = _objectSpread(_objectSpread({}, stepInfo), {}, {
508
+ name: attachment.name
509
+ });
510
+ this.recordAttachmentTarget(test.id, attachmentTarget);
511
+ if (this.shouldProcessAttachmentAtTestEnd(attachment) || !isRuntimeMessage && !hasExplicitParent) {
512
+ continue;
513
+ }
514
+ attachmentTarget.processedAtStepEnd = true;
515
+ if (stepInfo !== null && stepInfo !== void 0 && stepInfo.hookStep && isRuntimeMessage) {
516
+ if (!this.processHookRuntimeMessage(test, testUuid, stepInfo.hookStep, attachment)) {
517
+ attachmentTarget.processedAtStepEnd = false;
518
+ }
519
+ continue;
520
+ }
521
+ if (stepInfo !== null && stepInfo !== void 0 && stepInfo.hookStep) {
522
+ this.addAttachmentToHookStep(test, stepInfo.hookStep, attachment);
523
+ continue;
524
+ }
525
+ var attachmentStepUuid = (_stepInfo$hookStep$uu = stepInfo === null || stepInfo === void 0 || (_stepInfo$hookStep = stepInfo.hookStep) === null || _stepInfo$hookStep === void 0 ? void 0 : _stepInfo$hookStep.uuid) !== null && _stepInfo$hookStep$uu !== void 0 ? _stepInfo$hookStep$uu : stepInfo === null || stepInfo === void 0 ? void 0 : stepInfo.stepUuid;
526
+ this.queueAttachmentTask(test.id, this.processAttachment(testUuid, attachmentStepUuid, attachment));
527
+ }
528
+ } catch (err) {
529
+ _iterator3.e(err);
530
+ } finally {
531
+ _iterator3.f();
532
+ }
533
+ }
270
534
  }, {
271
535
  key: "onStepBegin",
272
536
  value: function onStepBegin(test, _result, step) {
273
537
  var _this$pwStepUuid$get2;
538
+ var testUuid = this.allureResultsUuids.get(test.id);
539
+ if (!testUuid) {
540
+ // eslint-disable-next-line no-console
541
+ console.warn("[allure-playwright] Ignoring onStepBegin for \"".concat(test.title, "\", step \"").concat(step.title, "\" (").concat(step.category, ") ") + "because no Allure test result has been started.");
542
+ return;
543
+ }
274
544
  var isRootBeforeHook = step.title === _utils.BEFORE_HOOKS_ROOT_STEP_TITLE;
275
545
  var isRootAfterHook = step.title === _utils.AFTER_HOOKS_ROOT_STEP_TITLE;
276
546
  var isRootHook = isRootBeforeHook || isRootAfterHook;
277
547
  var isBeforeHookDescendant = (0, _utils.isBeforeHookStep)(step);
278
548
  var isAfterHookDescendant = (0, _utils.isAfterHookStep)(step);
279
549
  var isHookStep = isBeforeHookDescendant || isAfterHookDescendant;
280
- var testUuid = this.allureResultsUuids.get(test.id);
281
550
  if (_assertClassBrand(_AllureReporter_brand, this, _shouldIgnoreStep).call(this, step)) {
282
551
  return;
283
552
  }
@@ -288,19 +557,17 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
288
557
  uuid: (0, _reporter.randomUuid)()
289
558
  });
290
559
  if (["test.attach", "attach"].includes(step.category) && !isHookStep) {
291
- var _this$pwStepUuid$get, _this$attachmentTarge;
560
+ var _this$pwStepUuid$get;
292
561
  var parent = step.parent ? (_this$pwStepUuid$get = this.pwStepUuid.get(step.parent)) !== null && _this$pwStepUuid$get !== void 0 ? _this$pwStepUuid$get : null : null;
293
- var targets = (_this$attachmentTarge = this.attachmentTargets.get(test.id)) !== null && _this$attachmentTarge !== void 0 ? _this$attachmentTarge : [];
294
- targets.push({
562
+ this.attachmentTargetByStep.set(step, {
295
563
  name: (0, _utils.normalizeAttachStepTitle)(step.title),
296
564
  stepUuid: parent !== null && parent !== void 0 ? parent : undefined
297
565
  });
298
- this.attachmentTargets.set(test.id, targets);
299
566
  return;
300
567
  }
301
568
  if (isHookStep) {
302
569
  if (["test.attach", "attach"].includes(step.category)) {
303
- var _stack$currentStep, _this$attachmentTarge2;
570
+ var _stack$currentStep;
304
571
  var attachmentName = (0, _utils.normalizeAttachStepTitle)(step.title);
305
572
  var _stack = _assertClassBrand(_AllureReporter_brand, this, _getOrCreateHookStack).call(this, test.id, isBeforeHookDescendant, step.startTime);
306
573
  var hookStepWithUuid;
@@ -308,19 +575,18 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
308
575
  _stack.startStep(baseStep);
309
576
  _stack.updateStep(function (stepResult) {
310
577
  hookStepWithUuid = _objectSpread(_objectSpread({}, step), {}, {
311
- uuid: stepResult.uuid
578
+ uuid: stepResult.uuid,
579
+ hookScope: isBeforeHookDescendant ? "before" : "after"
312
580
  });
313
581
  stepResult.name = (0, _utils.normalizeHookTitle)(stepResult.name);
314
582
  stepResult.stage = _allureJsCommons.Stage.FINISHED;
315
583
  });
316
584
  _stack.stopStep();
317
- var _targets = (_this$attachmentTarge2 = this.attachmentTargets.get(test.id)) !== null && _this$attachmentTarge2 !== void 0 ? _this$attachmentTarge2 : [];
318
- _targets.push({
585
+ this.attachmentTargetByStep.set(step, {
319
586
  name: attachmentName,
320
587
  hookStep: hookStepWithUuid,
321
588
  stepUuid: attachmentName === "Allure Step Metadata" ? parentHookStepUuid : undefined
322
589
  });
323
- this.attachmentTargets.set(test.id, _targets);
324
590
  return;
325
591
  }
326
592
  var stack = _assertClassBrand(_AllureReporter_brand, this, _getOrCreateHookStack).call(this, test.id, isBeforeHookDescendant, step.startTime);
@@ -346,6 +612,12 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
346
612
  }, {
347
613
  key: "onStepEnd",
348
614
  value: function onStepEnd(test, _result, step) {
615
+ var testUuid = this.allureResultsUuids.get(test.id);
616
+ if (!testUuid) {
617
+ // eslint-disable-next-line no-console
618
+ console.warn("[allure-playwright] Ignoring onStepEnd for \"".concat(test.title, "\", step \"").concat(step.title, "\" (").concat(step.category, ") ") + "because no Allure test result has been started.");
619
+ return;
620
+ }
349
621
  var isRootBeforeHook = step.title === _utils.BEFORE_HOOKS_ROOT_STEP_TITLE;
350
622
  var isRootAfterHook = step.title === _utils.AFTER_HOOKS_ROOT_STEP_TITLE;
351
623
  var isRootHook = isRootBeforeHook || isRootAfterHook;
@@ -368,11 +640,10 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
368
640
  if (_assertClassBrand(_AllureReporter_brand, this, _shouldIgnoreStep).call(this, step)) {
369
641
  return;
370
642
  }
371
- // ignore test.attach steps since attachments are already in the report
372
643
  if (["test.attach", "attach"].includes(step.category)) {
644
+ this.processStepEndAttachments(test, step);
373
645
  return;
374
646
  }
375
- var testUuid = this.allureResultsUuids.get(test.id);
376
647
  var isBeforeHookDescendant = (0, _utils.isBeforeHookStep)(step);
377
648
  var isAfterHookDescendant = (0, _utils.isAfterHookStep)(step);
378
649
  var isAfterHook = isAfterHookDescendant;
@@ -410,14 +681,23 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
410
681
  }, {
411
682
  key: "onTestEnd",
412
683
  value: function () {
413
- var _onTestEnd = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(test, result) {
414
- var _this2 = this,
415
- _this$attachmentTarge3;
416
- var testUuid, threadId, thread, error, _test$parent$titlePat, _test$parent$titlePat2, projectSuiteTitle, fileSuiteTitle, suiteTitles, beforeHooksStack, afterHooksStack, targets, targetsByName, _iterator2, _step2, _targetsByName$get, t, q, takeByName, _iterator3, _step3, attachment, isRuntimeMessage, stepInfo, _stepInfo$hookStep$uu, _stepInfo$hookStep, message, targetStack, _targetStack, stepUuid, hookStep, _targetStack2, stepResult, fileName, _t;
417
- return _regenerator().w(function (_context) {
418
- while (1) switch (_context.n) {
684
+ var _onTestEnd = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(test, result) {
685
+ var _this3 = this,
686
+ _this$attachmentTarge2;
687
+ var testUuid, threadId, thread, error, _test$parent$titlePat, _test$parent$titlePat2, projectSuiteTitle, fileSuiteTitle, suiteTitles, beforeHooksStack, afterHooksStack, targets, targetsByName, _iterator4, _step4, _targetsByName$get, t, q, takeByName, _iterator5, _step5, attachment, isRuntimeMessage, stepInfo, _stepInfo$hookStep$uu2, _stepInfo$hookStep2, message, targetStack, _targetStack, stepUuid, _targetStack2, stepResult, fileName, _t;
688
+ return _regenerator().w(function (_context2) {
689
+ while (1) switch (_context2.n) {
419
690
  case 0:
420
- testUuid = this.allureResultsUuids.get(test.id); // We need to check parallelIndex first because pw introduced this field only in v1.30.0
691
+ testUuid = this.allureResultsUuids.get(test.id);
692
+ if (testUuid) {
693
+ _context2.n = 1;
694
+ break;
695
+ }
696
+ // eslint-disable-next-line no-console
697
+ console.warn("[allure-playwright] Ignoring onTestEnd for \"".concat(test.title, "\" because no Allure test result has been started."));
698
+ return _context2.a(2);
699
+ case 1:
700
+ // We need to check parallelIndex first because pw introduced this field only in v1.30.0
421
701
  threadId = result.parallelIndex !== undefined ? result.parallelIndex : result.workerIndex;
422
702
  thread = "pid-".concat(_nodeProcess["default"].pid, "-worker-").concat(threadId);
423
703
  error = result.error; // only apply default suites if not set by user
@@ -433,7 +713,7 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
433
713
  value: projectSuiteTitle
434
714
  });
435
715
  }
436
- if (_this2.options.suiteTitle && fileSuiteTitle && !(0, _sdk.hasLabel)(testResult, _allureJsCommons.LabelName.SUITE)) {
716
+ if (_this3.options.suiteTitle && fileSuiteTitle && !(0, _sdk.hasLabel)(testResult, _allureJsCommons.LabelName.SUITE)) {
437
717
  testResult.labels.push({
438
718
  name: _allureJsCommons.LabelName.SUITE,
439
719
  value: fileSuiteTitle
@@ -473,20 +753,20 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
473
753
  }
474
754
 
475
755
  // FIFO
476
- targets = (_this$attachmentTarge3 = this.attachmentTargets.get(test.id)) !== null && _this$attachmentTarge3 !== void 0 ? _this$attachmentTarge3 : [];
756
+ targets = (_this$attachmentTarge2 = this.attachmentTargets.get(test.id)) !== null && _this$attachmentTarge2 !== void 0 ? _this$attachmentTarge2 : [];
477
757
  targetsByName = new Map();
478
- _iterator2 = _createForOfIteratorHelper(targets);
758
+ _iterator4 = _createForOfIteratorHelper(targets);
479
759
  try {
480
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
481
- t = _step2.value;
760
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
761
+ t = _step4.value;
482
762
  q = (_targetsByName$get = targetsByName.get(t.name)) !== null && _targetsByName$get !== void 0 ? _targetsByName$get : [];
483
763
  q.push(t);
484
764
  targetsByName.set(t.name, q);
485
765
  }
486
766
  } catch (err) {
487
- _iterator2.e(err);
767
+ _iterator4.e(err);
488
768
  } finally {
489
- _iterator2.f();
769
+ _iterator4.f();
490
770
  }
491
771
  takeByName = function takeByName(name) {
492
772
  var target = targetsByName.get(name);
@@ -495,52 +775,57 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
495
775
  }
496
776
  return target.shift();
497
777
  };
498
- _iterator3 = _createForOfIteratorHelper(result.attachments);
499
- _context.p = 1;
500
- _iterator3.s();
501
- case 2:
502
- if ((_step3 = _iterator3.n()).done) {
503
- _context.n = 10;
778
+ _iterator5 = _createForOfIteratorHelper(result.attachments);
779
+ _context2.p = 2;
780
+ _iterator5.s();
781
+ case 3:
782
+ if ((_step5 = _iterator5.n()).done) {
783
+ _context2.n = 12;
504
784
  break;
505
785
  }
506
- attachment = _step3.value;
786
+ attachment = _step5.value;
507
787
  isRuntimeMessage = attachment.contentType === _reporter.ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE;
508
788
  stepInfo = takeByName(attachment.name);
789
+ if (!(stepInfo !== null && stepInfo !== void 0 && stepInfo.processedAtStepEnd)) {
790
+ _context2.n = 4;
791
+ break;
792
+ }
793
+ return _context2.a(3, 11);
794
+ case 4:
509
795
  if (!isRuntimeMessage) {
510
- _context.n = 5;
796
+ _context2.n = 7;
511
797
  break;
512
798
  }
513
799
  message = attachment.body ? JSON.parse(attachment.body.toString()) : undefined;
514
800
  if (stepInfo !== null && stepInfo !== void 0 && stepInfo.hookStep) {
515
- targetStack = (0, _utils.isBeforeHookStep)(stepInfo.hookStep) ? beforeHooksStack : afterHooksStack;
801
+ targetStack = this.getHookStepsStack(test.id, stepInfo.hookStep);
516
802
  this.removeStepFromHookStack(targetStack, stepInfo.hookStep.uuid);
517
803
  }
518
804
  if (!((message === null || message === void 0 ? void 0 : message.type) === "step_metadata" && stepInfo !== null && stepInfo !== void 0 && stepInfo.stepUuid)) {
519
- _context.n = 3;
805
+ _context2.n = 5;
520
806
  break;
521
807
  }
522
808
  if (stepInfo.hookStep) {
523
- _targetStack = (0, _utils.isBeforeHookStep)(stepInfo.hookStep) ? beforeHooksStack : afterHooksStack;
809
+ _targetStack = this.getHookStepsStack(test.id, stepInfo.hookStep);
524
810
  this.processHookStepMetadataMessage(_targetStack, stepInfo.stepUuid, message);
525
811
  } else {
526
812
  this.processStepMetadataMessage(stepInfo.stepUuid, message);
527
813
  }
528
- return _context.a(3, 9);
529
- case 3:
530
- stepUuid = (_stepInfo$hookStep$uu = stepInfo === null || stepInfo === void 0 || (_stepInfo$hookStep = stepInfo.hookStep) === null || _stepInfo$hookStep === void 0 ? void 0 : _stepInfo$hookStep.uuid) !== null && _stepInfo$hookStep$uu !== void 0 ? _stepInfo$hookStep$uu : stepInfo === null || stepInfo === void 0 ? void 0 : stepInfo.stepUuid;
531
- _context.n = 4;
532
- return this.processAttachment(testUuid, stepUuid, attachment);
533
- case 4:
534
- return _context.a(3, 9);
814
+ return _context2.a(3, 11);
535
815
  case 5:
816
+ stepUuid = (_stepInfo$hookStep$uu2 = stepInfo === null || stepInfo === void 0 || (_stepInfo$hookStep2 = stepInfo.hookStep) === null || _stepInfo$hookStep2 === void 0 ? void 0 : _stepInfo$hookStep2.uuid) !== null && _stepInfo$hookStep$uu2 !== void 0 ? _stepInfo$hookStep$uu2 : stepInfo === null || stepInfo === void 0 ? void 0 : stepInfo.stepUuid;
817
+ _context2.n = 6;
818
+ return this.processAttachment(testUuid, stepUuid, attachment);
819
+ case 6:
820
+ return _context2.a(3, 11);
821
+ case 7:
536
822
  if (!(stepInfo !== null && stepInfo !== void 0 && stepInfo.hookStep)) {
537
- _context.n = 6;
823
+ _context2.n = 8;
538
824
  break;
539
825
  }
540
- hookStep = stepInfo.hookStep;
541
- _targetStack2 = (0, _utils.isBeforeHookStep)(hookStep) ? beforeHooksStack : afterHooksStack;
826
+ _targetStack2 = this.getHookStepsStack(test.id, stepInfo.hookStep);
542
827
  if (_targetStack2) {
543
- stepResult = _targetStack2.findStepByUuid(hookStep.uuid);
828
+ stepResult = _targetStack2.findStepByUuid(stepInfo.hookStep.uuid);
544
829
  if (stepResult) {
545
830
  fileName = _targetStack2.addAttachment(attachment, this.allureRuntime.writer);
546
831
  stepResult.attachments.push({
@@ -550,34 +835,37 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
550
835
  });
551
836
  }
552
837
  }
553
- return _context.a(3, 9);
554
- case 6:
838
+ return _context2.a(3, 11);
839
+ case 8:
555
840
  if (!(stepInfo !== null && stepInfo !== void 0 && stepInfo.stepUuid)) {
556
- _context.n = 8;
841
+ _context2.n = 10;
557
842
  break;
558
843
  }
559
- _context.n = 7;
844
+ _context2.n = 9;
560
845
  return this.processAttachment(testUuid, stepInfo.stepUuid, attachment);
561
- case 7:
562
- return _context.a(3, 9);
563
- case 8:
564
- _context.n = 9;
565
- return this.processAttachment(testUuid, undefined, attachment);
566
846
  case 9:
567
- _context.n = 2;
568
- break;
847
+ return _context2.a(3, 11);
569
848
  case 10:
570
- _context.n = 12;
571
- break;
849
+ _context2.n = 11;
850
+ return this.processAttachment(testUuid, undefined, attachment);
572
851
  case 11:
573
- _context.p = 11;
574
- _t = _context.v;
575
- _iterator3.e(_t);
852
+ _context2.n = 3;
853
+ break;
576
854
  case 12:
577
- _context.p = 12;
578
- _iterator3.f();
579
- return _context.f(12);
855
+ _context2.n = 14;
856
+ break;
580
857
  case 13:
858
+ _context2.p = 13;
859
+ _t = _context2.v;
860
+ _iterator5.e(_t);
861
+ case 14:
862
+ _context2.p = 14;
863
+ _iterator5.f();
864
+ return _context2.f(14);
865
+ case 15:
866
+ _context2.n = 16;
867
+ return this.flushAttachmentTasks(test.id);
868
+ case 16:
581
869
  // FIXME: temp logic for labels override, we need it here to keep the reporter compatible with v2 API
582
870
  // in next iterations we need to implement the logic for every javascript integration
583
871
  this.allureRuntime.updateTest(testUuid, function (testResult) {
@@ -597,14 +885,14 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
597
885
  });
598
886
  if (beforeHooksStack) {
599
887
  var _testResult$steps;
600
- (_testResult$steps = testResult.steps).unshift.apply(_testResult$steps, _toConsumableArray(beforeHooksStack.steps));
888
+ (_testResult$steps = testResult.steps).unshift.apply(_testResult$steps, _toConsumableArray(_this3.pruneEmptyHookRoots(beforeHooksStack.steps)));
601
889
  }
602
- _this2.beforeHooksStepsStack["delete"](test.id);
890
+ _this3.beforeHooksStepsStack["delete"](test.id);
603
891
  if (afterHooksStack) {
604
892
  var _testResult$steps2;
605
- (_testResult$steps2 = testResult.steps).push.apply(_testResult$steps2, _toConsumableArray(afterHooksStack.steps));
893
+ (_testResult$steps2 = testResult.steps).push.apply(_testResult$steps2, _toConsumableArray(_this3.pruneEmptyHookRoots(afterHooksStack.steps)));
606
894
  }
607
- _this2.afterHooksStepsStack["delete"](test.id);
895
+ _this3.afterHooksStepsStack["delete"](test.id);
608
896
  testResult.labels = newLabels;
609
897
  });
610
898
  this.allureRuntime.stopTest(testUuid, {
@@ -612,12 +900,13 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
612
900
  });
613
901
  this.allureRuntime.writeTest(testUuid);
614
902
  this.attachmentTargets["delete"](test.id);
615
- case 14:
616
- return _context.a(2);
903
+ this.pendingAttachmentTasks["delete"](test.id);
904
+ case 17:
905
+ return _context2.a(2);
617
906
  }
618
- }, _callee, this, [[1, 11, 12, 13]]);
907
+ }, _callee2, this, [[2, 13, 14, 15]]);
619
908
  }));
620
- function onTestEnd(_x, _x2) {
909
+ function onTestEnd(_x2, _x3) {
621
910
  return _onTestEnd.apply(this, arguments);
622
911
  }
623
912
  return onTestEnd;
@@ -625,28 +914,28 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
625
914
  }, {
626
915
  key: "addSkippedResults",
627
916
  value: function () {
628
- var _addSkippedResults = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
629
- var _this3 = this;
630
- var unprocessedCases, _iterator4, _step4, testCase, _t2;
631
- return _regenerator().w(function (_context2) {
632
- while (1) switch (_context2.n) {
917
+ var _addSkippedResults = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
918
+ var _this4 = this;
919
+ var unprocessedCases, _iterator6, _step6, testCase, _t2;
920
+ return _regenerator().w(function (_context3) {
921
+ while (1) switch (_context3.n) {
633
922
  case 0:
634
- unprocessedCases = this.suite.allTests().filter(function (_ref2) {
635
- var title = _ref2.title;
923
+ unprocessedCases = this.suite.allTests().filter(function (testCase) {
924
+ var title = testCase.title;
636
925
  var titleMetadata = (0, _sdk.extractMetadataFromString)(title);
637
- return !_this3.startedTestCasesTitlesCache.includes(titleMetadata.cleanTitle);
926
+ return !_this4.startedTestCasesTitlesCache.includes(titleMetadata.cleanTitle);
638
927
  });
639
- _iterator4 = _createForOfIteratorHelper(unprocessedCases);
640
- _context2.p = 1;
641
- _iterator4.s();
928
+ _iterator6 = _createForOfIteratorHelper(unprocessedCases);
929
+ _context3.p = 1;
930
+ _iterator6.s();
642
931
  case 2:
643
- if ((_step4 = _iterator4.n()).done) {
644
- _context2.n = 4;
932
+ if ((_step6 = _iterator6.n()).done) {
933
+ _context3.n = 4;
645
934
  break;
646
935
  }
647
- testCase = _step4.value;
936
+ testCase = _step6.value;
648
937
  this.onTestBegin(testCase);
649
- _context2.n = 3;
938
+ _context3.n = 3;
650
939
  return this.onTestEnd(testCase, {
651
940
  status: _allureJsCommons.Status.SKIPPED,
652
941
  attachments: [],
@@ -662,23 +951,23 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
662
951
  annotations: []
663
952
  });
664
953
  case 3:
665
- _context2.n = 2;
954
+ _context3.n = 2;
666
955
  break;
667
956
  case 4:
668
- _context2.n = 6;
957
+ _context3.n = 6;
669
958
  break;
670
959
  case 5:
671
- _context2.p = 5;
672
- _t2 = _context2.v;
673
- _iterator4.e(_t2);
960
+ _context3.p = 5;
961
+ _t2 = _context3.v;
962
+ _iterator6.e(_t2);
674
963
  case 6:
675
- _context2.p = 6;
676
- _iterator4.f();
677
- return _context2.f(6);
964
+ _context3.p = 6;
965
+ _iterator6.f();
966
+ return _context3.f(6);
678
967
  case 7:
679
- return _context2.a(2);
968
+ return _context3.a(2);
680
969
  }
681
- }, _callee2, this, [[1, 5, 6, 7]]);
970
+ }, _callee3, this, [[1, 5, 6, 7]]);
682
971
  }));
683
972
  function addSkippedResults() {
684
973
  return _addSkippedResults.apply(this, arguments);
@@ -688,19 +977,19 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
688
977
  }, {
689
978
  key: "onEnd",
690
979
  value: function () {
691
- var _onEnd = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
692
- return _regenerator().w(function (_context3) {
693
- while (1) switch (_context3.n) {
980
+ var _onEnd = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
981
+ return _regenerator().w(function (_context4) {
982
+ while (1) switch (_context4.n) {
694
983
  case 0:
695
- _context3.n = 1;
984
+ _context4.n = 1;
696
985
  return this.addSkippedResults();
697
986
  case 1:
698
987
  this.allureRuntime.writeEnvironmentInfo();
699
988
  this.allureRuntime.writeCategoriesDefinitions();
700
989
  case 2:
701
- return _context3.a(2);
990
+ return _context4.a(2);
702
991
  }
703
- }, _callee3, this);
992
+ }, _callee4, this);
704
993
  }));
705
994
  function onEnd() {
706
995
  return _onEnd.apply(this, arguments);
@@ -712,9 +1001,30 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
712
1001
  value: function printsToStdio() {
713
1002
  return false;
714
1003
  }
1004
+ }, {
1005
+ key: "isEmptyPassedHookRoot",
1006
+ value: function isEmptyPassedHookRoot(step) {
1007
+ if (this.options.detail) {
1008
+ return false;
1009
+ }
1010
+ return (step.name === _utils.BEFORE_HOOKS_ROOT_STEP_TITLE || step.name === _utils.AFTER_HOOKS_ROOT_STEP_TITLE) && step.steps.length === 0 && step.attachments.length === 0 && step.status === _allureJsCommons.Status.PASSED;
1011
+ }
1012
+ }, {
1013
+ key: "pruneEmptyHookRoots",
1014
+ value: function pruneEmptyHookRoots(steps) {
1015
+ var _this5 = this;
1016
+ return steps.map(function (step) {
1017
+ return _objectSpread(_objectSpread({}, step), {}, {
1018
+ steps: _this5.pruneEmptyHookRoots(step.steps)
1019
+ });
1020
+ }).filter(function (step) {
1021
+ return !_this5.isEmptyPassedHookRoot(step);
1022
+ });
1023
+ }
715
1024
  }, {
716
1025
  key: "removeStepFromHookStack",
717
1026
  value: function removeStepFromHookStack(stack, stepUuid) {
1027
+ var _this6 = this;
718
1028
  if (!stack) {
719
1029
  return;
720
1030
  }
@@ -726,26 +1036,27 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
726
1036
  steps: _removeRecursively(step.steps)
727
1037
  });
728
1038
  }).filter(function (step) {
729
- return step.name !== _utils.BEFORE_HOOKS_ROOT_STEP_TITLE && step.name !== _utils.AFTER_HOOKS_ROOT_STEP_TITLE || step.steps.length > 0 || step.attachments.length > 0 || step.status !== _allureJsCommons.Status.PASSED;
1039
+ return !_this6.isEmptyPassedHookRoot(step);
730
1040
  });
731
1041
  };
732
1042
  stack.steps = _removeRecursively(stack.steps);
733
1043
  }
734
1044
  }, {
735
1045
  key: "getStaticTestMetadata",
736
- value: function getStaticTestMetadata(test) {
737
- var _ref3, _test$parent$project, _titleMetadata$labels;
1046
+ value: function getStaticTestMetadata(test, parentSuite) {
1047
+ var _ref2, _testParent$project, _testParent$titlePath, _titleMetadata$labels;
738
1048
  var titleMetadata = (0, _sdk.extractMetadataFromString)(test.title);
739
- var project = (_ref3 = (_test$parent$project = test.parent.project()) !== null && _test$parent$project !== void 0 ? _test$parent$project : this.config.projects.find(function (candidate) {
1049
+ var testParent = parentSuite !== null && parentSuite !== void 0 ? parentSuite : test.parent;
1050
+ var project = (_ref2 = (_testParent$project = testParent === null || testParent === void 0 ? void 0 : testParent.project()) !== null && _testParent$project !== void 0 ? _testParent$project : this.config.projects.find(function (candidate) {
740
1051
  return test.location.file === candidate.testDir || test.location.file.startsWith("".concat(candidate.testDir).concat(_nodePath["default"].sep));
741
- })) !== null && _ref3 !== void 0 ? _ref3 : this.config.projects[0];
1052
+ })) !== null && _ref2 !== void 0 ? _ref2 : this.config.projects[0];
742
1053
  var testFilePath = _nodePath["default"].relative(project.testDir, test.location.file);
743
1054
  var relativeFileParts = testFilePath.split(_nodePath["default"].sep);
744
1055
  var relativeFile = relativeFileParts.join("/");
745
1056
  var normalizedAbsoluteFile = _nodePath["default"].normalize(test.location.file);
746
1057
  var normalizedRelativeFile = _nodePath["default"].normalize(testFilePath);
747
1058
  var fileTitleCandidates = new Set([normalizedAbsoluteFile, normalizedRelativeFile, relativeFile]);
748
- var suiteTitles = test.parent.titlePath().filter(Boolean);
1059
+ var suiteTitles = (_testParent$titlePath = testParent === null || testParent === void 0 ? void 0 : testParent.titlePath().filter(Boolean)) !== null && _testParent$titlePath !== void 0 ? _testParent$titlePath : [];
749
1060
  if (project.name && suiteTitles[0] === project.name) {
750
1061
  suiteTitles = suiteTitles.slice(1);
751
1062
  }
@@ -753,6 +1064,9 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
753
1064
  suiteTitles = suiteTitles.slice(1);
754
1065
  }
755
1066
  var suitePrefix = suiteTitles.length > 0 ? "".concat(suiteTitles.join(" "), " ") : "";
1067
+ var projectRootSearchFrom = _nodePath["default"].dirname(test.location.file);
1068
+ var projectName = (0, _reporter.getProjectName)(projectRootSearchFrom);
1069
+ var testCaseIdBase = "".concat(relativeFile, "#").concat(suitePrefix).concat(test.title);
756
1070
  var legacyFullName = "".concat(relativeFile, "#").concat(suitePrefix).concat(titleMetadata.cleanTitle);
757
1071
  var staticAllureId = (_titleMetadata$labels = titleMetadata.labels.find(function (label) {
758
1072
  return label.name === _allureJsCommons.LabelName.ALLURE_ID;
@@ -760,11 +1074,11 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
760
1074
 
761
1075
  // Test-plan matching happens during discovery, so runtime API labels are intentionally excluded here.
762
1076
  if (!staticAllureId && "annotations" in test) {
763
- var _iterator5 = _createForOfIteratorHelper(test.annotations),
764
- _step5;
1077
+ var _iterator7 = _createForOfIteratorHelper(test.annotations),
1078
+ _step7;
765
1079
  try {
766
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
767
- var annotation = _step5.value;
1080
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
1081
+ var annotation = _step7.value;
768
1082
  var label = (0, _sdk.getMetadataLabel)(annotation.type, annotation.description);
769
1083
  if ((label === null || label === void 0 ? void 0 : label.name) === _allureJsCommons.LabelName.ALLURE_ID) {
770
1084
  staticAllureId = label.value;
@@ -772,9 +1086,9 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
772
1086
  }
773
1087
  }
774
1088
  } catch (err) {
775
- _iterator5.e(err);
1089
+ _iterator7.e(err);
776
1090
  } finally {
777
- _iterator5.f();
1091
+ _iterator7.f();
778
1092
  }
779
1093
  }
780
1094
  return {
@@ -782,7 +1096,10 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
782
1096
  testFilePath: testFilePath,
783
1097
  relativeFileParts: relativeFileParts,
784
1098
  suiteTitles: suiteTitles,
785
- testCaseIdBase: "".concat(relativeFile, "#").concat(suitePrefix).concat(test.title),
1099
+ projectName: projectName,
1100
+ projectRootSearchFrom: projectRootSearchFrom,
1101
+ testCaseIdBase: projectName ? "".concat(projectName, ":").concat(testCaseIdBase) : testCaseIdBase,
1102
+ legacyTestCaseIdBase: testCaseIdBase,
786
1103
  titleMetadata: titleMetadata,
787
1104
  fullName: "".concat(relativeFile, ":").concat(test.location.line, ":").concat(test.location.column),
788
1105
  legacyFullName: legacyFullName,
@@ -791,11 +1108,11 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
791
1108
  }
792
1109
  }, {
793
1110
  key: "isInTestPlan",
794
- value: function isInTestPlan(test) {
1111
+ value: function isInTestPlan(test, parentSuite) {
795
1112
  if (!this.testPlan) {
796
1113
  return true;
797
1114
  }
798
- var _this$getStaticTestMe = this.getStaticTestMetadata(test),
1115
+ var _this$getStaticTestMe = this.getStaticTestMetadata(test, parentSuite),
799
1116
  fullName = _this$getStaticTestMe.fullName,
800
1117
  legacyFullName = _this$getStaticTestMe.legacyFullName,
801
1118
  staticAllureId = _this$getStaticTestMe.staticAllureId;
@@ -807,13 +1124,54 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
807
1124
  id: staticAllureId
808
1125
  });
809
1126
  }
1127
+ }, {
1128
+ key: "installTestPlanExecutionFilter",
1129
+ value: function installTestPlanExecutionFilter() {
1130
+ var _this7 = this;
1131
+ var suitePrototype = this.getPlaywrightSuitePrototype();
1132
+ if (!(suitePrototype !== null && suitePrototype !== void 0 && suitePrototype._addTest)) {
1133
+ // eslint-disable-next-line no-console
1134
+ console.warn("[allure-playwright] Could not install the test plan execution filter because Playwright " + "Suite.prototype._addTest was not found. Tests outside ALLURE_TESTPLAN_PATH may still run. " + "Please report this compatibility issue to https://github.com/allure-framework/allure-js/issues.");
1135
+ return;
1136
+ }
1137
+ var patchedSuitePrototype = suitePrototype;
1138
+ patchedSuitePrototype[testPlanFilterSymbol] = function (test, parentSuite) {
1139
+ return _this7.isInTestPlan(test, parentSuite);
1140
+ };
1141
+ if (patchedSuitePrototype[testPlanFilterPatchSymbol]) {
1142
+ return;
1143
+ }
1144
+ var addTest = suitePrototype._addTest;
1145
+
1146
+ // Dear Pavel: break us all day long you may; find the way back, my Codex and I always will.
1147
+ suitePrototype._addTest = function (test) {
1148
+ var testPlanFilter = patchedSuitePrototype[testPlanFilterSymbol];
1149
+ if (testPlanFilter && !testPlanFilter(test, this)) {
1150
+ return;
1151
+ }
1152
+ return addTest.call(this, test);
1153
+ };
1154
+ patchedSuitePrototype[testPlanFilterPatchSymbol] = true;
1155
+ }
1156
+ }, {
1157
+ key: "getPlaywrightSuitePrototype",
1158
+ value: function getPlaywrightSuitePrototype() {
1159
+ try {
1160
+ var _playwrightCommon$tes;
1161
+ var playwrightTestRequire = (0, _nodeModule.createRequire)(localRequire.resolve("@playwright/test"));
1162
+ var playwrightCommon = playwrightTestRequire("playwright/lib/common");
1163
+ return (_playwrightCommon$tes = playwrightCommon.test) === null || _playwrightCommon$tes === void 0 || (_playwrightCommon$tes = _playwrightCommon$tes.Suite) === null || _playwrightCommon$tes === void 0 ? void 0 : _playwrightCommon$tes.prototype;
1164
+ } catch (_unused) {
1165
+ return undefined;
1166
+ }
1167
+ }
810
1168
  }, {
811
1169
  key: "processStepMetadataMessage",
812
1170
  value: function processStepMetadataMessage(attachmentStepUuid, message) {
813
1171
  var _message$data = message.data,
814
1172
  name = _message$data.name,
815
- _message$data$paramet = _message$data.parameters,
816
- parameters = _message$data$paramet === void 0 ? [] : _message$data$paramet;
1173
+ _message$data$paramet2 = _message$data.parameters,
1174
+ parameters = _message$data$paramet2 === void 0 ? [] : _message$data$paramet2;
817
1175
  this.allureRuntime.updateStep(attachmentStepUuid, function (step) {
818
1176
  var _step$parameters;
819
1177
  if (name) {
@@ -842,32 +1200,32 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
842
1200
  }, {
843
1201
  key: "processAttachment",
844
1202
  value: function () {
845
- var _processAttachment = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(testUuid, attachmentStepUuid, attachment) {
1203
+ var _processAttachment = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(testUuid, attachmentStepUuid, attachment) {
846
1204
  var _replace;
847
1205
  var allureRuntimeMessage, message, parentUuid, contentType, pathWithoutEndFromSnapshotDir, pathWithoutEnd, fileExists, readImageFromDirs, actualBase64, expectedBase64, diffBase64, diffName;
848
- return _regenerator().w(function (_context6) {
849
- while (1) switch (_context6.n) {
1206
+ return _regenerator().w(function (_context7) {
1207
+ while (1) switch (_context7.n) {
850
1208
  case 0:
851
1209
  if (!(!attachment.body && !attachment.path)) {
852
- _context6.n = 1;
1210
+ _context7.n = 1;
853
1211
  break;
854
1212
  }
855
- return _context6.a(2);
1213
+ return _context7.a(2);
856
1214
  case 1:
857
1215
  allureRuntimeMessage = attachment.contentType === _reporter.ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE;
858
1216
  if (!(allureRuntimeMessage && !attachment.body)) {
859
- _context6.n = 2;
1217
+ _context7.n = 2;
860
1218
  break;
861
1219
  }
862
- return _context6.a(2);
1220
+ return _context7.a(2);
863
1221
  case 2:
864
1222
  if (!allureRuntimeMessage) {
865
- _context6.n = 3;
1223
+ _context7.n = 3;
866
1224
  break;
867
1225
  }
868
1226
  message = JSON.parse(attachment.body.toString());
869
1227
  this.allureRuntime.applyRuntimeMessages(testUuid, [message]);
870
- return _context6.a(2);
1228
+ return _context7.a(2);
871
1229
  case 3:
872
1230
  parentUuid = this.allureRuntime.startStep(testUuid, attachmentStepUuid, {
873
1231
  name: attachment.name
@@ -878,20 +1236,20 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
878
1236
  this.allureRuntime.stopStep(parentUuid, undefined);
879
1237
  }
880
1238
  if (!attachment.body) {
881
- _context6.n = 4;
1239
+ _context7.n = 4;
882
1240
  break;
883
1241
  }
884
1242
  this.allureRuntime.writeAttachment(testUuid, parentUuid, attachment.name, attachment.body, {
885
1243
  contentType: attachment.contentType
886
1244
  });
887
- _context6.n = 6;
1245
+ _context7.n = 6;
888
1246
  break;
889
1247
  case 4:
890
1248
  if ((0, _nodeFs.existsSync)(attachment.path)) {
891
- _context6.n = 5;
1249
+ _context7.n = 5;
892
1250
  break;
893
1251
  }
894
- return _context6.a(2);
1252
+ return _context7.a(2);
895
1253
  case 5:
896
1254
  contentType = attachment.name === "trace" && attachment.contentType === "application/zip" ? _allureJsCommons.ContentType.PLAYWRIGHT_TRACE : attachment.contentType;
897
1255
  this.allureRuntime.writeAttachment(testUuid, parentUuid, attachment.name, attachment.path, {
@@ -899,91 +1257,91 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
899
1257
  });
900
1258
  case 6:
901
1259
  if (attachment.name.match(_utils.diffEndRegexp)) {
902
- _context6.n = 7;
1260
+ _context7.n = 7;
903
1261
  break;
904
1262
  }
905
- return _context6.a(2);
1263
+ return _context7.a(2);
906
1264
  case 7:
907
1265
  pathWithoutEndFromSnapshotDir = (_replace = attachment.path.replace(this.outputDir, this.snapshotDir)) === null || _replace === void 0 ? void 0 : _replace.replace(_utils.diffEndRegexp, "").replace(/\.png/, "");
908
1266
  pathWithoutEnd = attachment.path.replace(_utils.diffEndRegexp, "").replace(/\.png/, "");
909
1267
  if (!(this.processedDiffs.includes(pathWithoutEnd) || this.processedDiffs.includes(pathWithoutEndFromSnapshotDir))) {
910
- _context6.n = 8;
1268
+ _context7.n = 8;
911
1269
  break;
912
1270
  }
913
- return _context6.a(2);
1271
+ return _context7.a(2);
914
1272
  case 8:
915
1273
  fileExists = /*#__PURE__*/function () {
916
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(filePath) {
917
- return _regenerator().w(function (_context4) {
918
- while (1) switch (_context4.n) {
1274
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(filePath) {
1275
+ return _regenerator().w(function (_context5) {
1276
+ while (1) switch (_context5.n) {
919
1277
  case 0:
920
- _context4.n = 1;
1278
+ _context5.n = 1;
921
1279
  return (0, _promises.access)(filePath).then(function () {
922
1280
  return true;
923
1281
  })["catch"](function () {
924
1282
  return false;
925
1283
  });
926
1284
  case 1:
927
- return _context4.a(2, _context4.v);
1285
+ return _context5.a(2, _context5.v);
928
1286
  }
929
- }, _callee4);
1287
+ }, _callee5);
930
1288
  }));
931
- return function fileExists(_x6) {
932
- return _ref4.apply(this, arguments);
1289
+ return function fileExists(_x7) {
1290
+ return _ref3.apply(this, arguments);
933
1291
  };
934
1292
  }();
935
1293
  readImageFromDirs = /*#__PURE__*/function () {
936
- var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(modifier) {
1294
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(modifier) {
937
1295
  var defaultPath, snapshotPath;
938
- return _regenerator().w(function (_context5) {
939
- while (1) switch (_context5.n) {
1296
+ return _regenerator().w(function (_context6) {
1297
+ while (1) switch (_context6.n) {
940
1298
  case 0:
941
1299
  defaultPath = "".concat(pathWithoutEnd, "-").concat(modifier, ".png");
942
1300
  snapshotPath = "".concat(pathWithoutEndFromSnapshotDir, "-").concat(modifier, ".png");
943
- _context5.n = 1;
1301
+ _context6.n = 1;
944
1302
  return fileExists(defaultPath);
945
1303
  case 1:
946
- if (!_context5.v) {
947
- _context5.n = 3;
1304
+ if (!_context6.v) {
1305
+ _context6.n = 3;
948
1306
  break;
949
1307
  }
950
- _context5.n = 2;
1308
+ _context6.n = 2;
951
1309
  return (0, _reporter.readImageAsBase64)(defaultPath);
952
1310
  case 2:
953
- return _context5.a(2, _context5.v);
1311
+ return _context6.a(2, _context6.v);
954
1312
  case 3:
955
- _context5.n = 4;
1313
+ _context6.n = 4;
956
1314
  return fileExists(snapshotPath);
957
1315
  case 4:
958
- if (!_context5.v) {
959
- _context5.n = 6;
1316
+ if (!_context6.v) {
1317
+ _context6.n = 6;
960
1318
  break;
961
1319
  }
962
- _context5.n = 5;
1320
+ _context6.n = 5;
963
1321
  return (0, _reporter.readImageAsBase64)(snapshotPath);
964
1322
  case 5:
965
- return _context5.a(2, _context5.v);
1323
+ return _context6.a(2, _context6.v);
966
1324
  case 6:
967
- return _context5.a(2, undefined);
1325
+ return _context6.a(2, undefined);
968
1326
  }
969
- }, _callee5);
1327
+ }, _callee6);
970
1328
  }));
971
- return function readImageFromDirs(_x7) {
972
- return _ref5.apply(this, arguments);
1329
+ return function readImageFromDirs(_x8) {
1330
+ return _ref4.apply(this, arguments);
973
1331
  };
974
1332
  }();
975
- _context6.n = 9;
1333
+ _context7.n = 9;
976
1334
  return readImageFromDirs("actual");
977
1335
  case 9:
978
- actualBase64 = _context6.v;
979
- _context6.n = 10;
1336
+ actualBase64 = _context7.v;
1337
+ _context7.n = 10;
980
1338
  return readImageFromDirs("expected");
981
1339
  case 10:
982
- expectedBase64 = _context6.v;
983
- _context6.n = 11;
1340
+ expectedBase64 = _context7.v;
1341
+ _context7.n = 11;
984
1342
  return readImageFromDirs("diff");
985
1343
  case 11:
986
- diffBase64 = _context6.v;
1344
+ diffBase64 = _context7.v;
987
1345
  diffName = attachment.name.replace(_utils.diffEndRegexp, "");
988
1346
  this.allureRuntime.writeAttachment(testUuid, undefined, diffName, Buffer.from(JSON.stringify({
989
1347
  expected: expectedBase64,
@@ -996,11 +1354,11 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
996
1354
  });
997
1355
  this.processedDiffs.push(pathWithoutEnd);
998
1356
  case 12:
999
- return _context6.a(2);
1357
+ return _context7.a(2);
1000
1358
  }
1001
- }, _callee6, this);
1359
+ }, _callee7, this);
1002
1360
  }));
1003
- function processAttachment(_x3, _x4, _x5) {
1361
+ function processAttachment(_x4, _x5, _x6) {
1004
1362
  return _processAttachment.apply(this, arguments);
1005
1363
  }
1006
1364
  return processAttachment;