allure-playwright 3.4.1 → 3.4.3

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
@@ -27,6 +27,7 @@ function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.h
27
27
  /* eslint max-lines: off */
28
28
 
29
29
  import { existsSync } from "node:fs";
30
+ import { access } from "node:fs/promises";
30
31
  import path from "node:path";
31
32
  import process from "node:process";
32
33
  import { ContentType, LabelName, LinkType, Stage, Status } from "allure-js-commons";
@@ -42,16 +43,19 @@ export var AllureReporter = /*#__PURE__*/function () {
42
43
  _defineProperty(this, "config", void 0);
43
44
  _defineProperty(this, "suite", void 0);
44
45
  _defineProperty(this, "options", void 0);
46
+ _defineProperty(this, "outputDir", void 0);
47
+ _defineProperty(this, "snapshotDir", void 0);
45
48
  _defineProperty(this, "allureRuntime", void 0);
46
49
  _defineProperty(this, "globalStartTime", new Date());
47
50
  _defineProperty(this, "processedDiffs", []);
48
51
  _defineProperty(this, "startedTestCasesTitlesCache", []);
49
52
  _defineProperty(this, "allureResultsUuids", new Map());
50
- _defineProperty(this, "attachmentSteps", new Map());
53
+ _defineProperty(this, "attachmentTargets", new Map());
51
54
  _defineProperty(this, "beforeHooksStepsStack", new Map());
52
55
  _defineProperty(this, "afterHooksStepsStack", new Map());
53
56
  _defineProperty(this, "beforeHooksAttachmentsStack", new Map());
54
57
  _defineProperty(this, "afterHooksAttachmentsStack", new Map());
58
+ _defineProperty(this, "pwStepUuid", new WeakMap());
55
59
  this.options = _objectSpread({
56
60
  suiteTitle: true,
57
61
  detail: true
@@ -61,6 +65,8 @@ export var AllureReporter = /*#__PURE__*/function () {
61
65
  key: "onConfigure",
62
66
  value: function onConfigure(config) {
63
67
  this.config = config;
68
+ this.outputDir = config.projects[0].outputDir;
69
+ this.snapshotDir = config.projects[0].snapshotDir;
64
70
  var testPlan = parseTestPlan();
65
71
  if (!testPlan) {
66
72
  return;
@@ -248,6 +254,7 @@ export var AllureReporter = /*#__PURE__*/function () {
248
254
  }, {
249
255
  key: "onStepBegin",
250
256
  value: function onStepBegin(test, _result, step) {
257
+ var _this$pwStepUuid$get2;
251
258
  var isRootBeforeHook = step.title === BEFORE_HOOKS_ROOT_STEP_TITLE;
252
259
  var isRootAfterHook = step.title === AFTER_HOOKS_ROOT_STEP_TITLE;
253
260
  var isRootHook = isRootBeforeHook || isRootAfterHook;
@@ -255,12 +262,6 @@ export var AllureReporter = /*#__PURE__*/function () {
255
262
  var isAfterHookDescendant = isAfterHookStep(step);
256
263
  var isHookStep = isBeforeHookDescendant || isAfterHookDescendant;
257
264
  var testUuid = this.allureResultsUuids.get(test.id);
258
- if (["test.attach", "attach"].includes(step.category) && !isHookStep) {
259
- var _this$allureRuntime, _this$attachmentSteps;
260
- var currentStep = (_this$allureRuntime = this.allureRuntime) === null || _this$allureRuntime === void 0 ? void 0 : _this$allureRuntime.currentStep(testUuid);
261
- this.attachmentSteps.set(testUuid, [].concat(_toConsumableArray((_this$attachmentSteps = this.attachmentSteps.get(testUuid)) !== null && _this$attachmentSteps !== void 0 ? _this$attachmentSteps : []), [currentStep]));
262
- return;
263
- }
264
265
  if (_assertClassBrand(_AllureReporter_brand, this, _shouldIgnoreStep).call(this, step)) {
265
266
  return;
266
267
  }
@@ -270,20 +271,38 @@ export var AllureReporter = /*#__PURE__*/function () {
270
271
  stage: Stage.RUNNING,
271
272
  uuid: randomUuid()
272
273
  });
274
+ if (["test.attach", "attach"].includes(step.category) && !isHookStep) {
275
+ var _this$pwStepUuid$get, _this$attachmentTarge;
276
+ var parent = step.parent ? (_this$pwStepUuid$get = this.pwStepUuid.get(step.parent)) !== null && _this$pwStepUuid$get !== void 0 ? _this$pwStepUuid$get : null : null;
277
+ var targets = (_this$attachmentTarge = this.attachmentTargets.get(test.id)) !== null && _this$attachmentTarge !== void 0 ? _this$attachmentTarge : [];
278
+ targets.push({
279
+ stepUuid: parent !== null && parent !== void 0 ? parent : undefined
280
+ });
281
+ this.attachmentTargets.set(test.id, targets);
282
+ return;
283
+ }
273
284
  if (isHookStep) {
274
285
  var stack = isBeforeHookDescendant ? this.beforeHooksStepsStack.get(test.id) : this.afterHooksStepsStack.get(test.id);
275
286
  if (["test.attach", "attach"].includes(step.category)) {
287
+ var _this$attachmentTarge2;
288
+ var hookStepWithUuid;
276
289
  stack.startStep(baseStep);
277
290
  var attachStack = isBeforeHookDescendant ? this.beforeHooksAttachmentsStack : this.afterHooksAttachmentsStack;
278
291
  stack.updateStep(function (stepResult) {
279
292
  var _attachStack$get;
293
+ hookStepWithUuid = _objectSpread(_objectSpread({}, step), {}, {
294
+ uuid: stepResult.uuid
295
+ });
280
296
  stepResult.name = normalizeHookTitle(stepResult.name);
281
297
  stepResult.stage = Stage.FINISHED;
282
- attachStack.set(test.id, [].concat(_toConsumableArray((_attachStack$get = attachStack.get(test.id)) !== null && _attachStack$get !== void 0 ? _attachStack$get : []), [_objectSpread(_objectSpread({}, step), {}, {
283
- uuid: stepResult.uuid
284
- })]));
298
+ attachStack.set(test.id, [].concat(_toConsumableArray((_attachStack$get = attachStack.get(test.id)) !== null && _attachStack$get !== void 0 ? _attachStack$get : []), [hookStepWithUuid]));
285
299
  });
286
300
  stack.stopStep();
301
+ var _targets = (_this$attachmentTarge2 = this.attachmentTargets.get(test.id)) !== null && _this$attachmentTarge2 !== void 0 ? _this$attachmentTarge2 : [];
302
+ _targets.push({
303
+ hookStep: hookStepWithUuid
304
+ });
305
+ this.attachmentTargets.set(test.id, _targets);
287
306
  return;
288
307
  }
289
308
  stack.startStep(baseStep);
@@ -299,7 +318,11 @@ export var AllureReporter = /*#__PURE__*/function () {
299
318
  }
300
319
  return;
301
320
  }
302
- this.allureRuntime.startStep(testUuid, undefined, baseStep);
321
+ var parentUuid = step.parent ? (_this$pwStepUuid$get2 = this.pwStepUuid.get(step.parent)) !== null && _this$pwStepUuid$get2 !== void 0 ? _this$pwStepUuid$get2 : null : null;
322
+ var createdUuid = this.allureRuntime.startStep(testUuid, parentUuid, baseStep);
323
+ if (createdUuid) {
324
+ this.pwStepUuid.set(step, createdUuid);
325
+ }
303
326
  }
304
327
  }, {
305
328
  key: "onStepEnd",
@@ -340,7 +363,11 @@ export var AllureReporter = /*#__PURE__*/function () {
340
363
  if (!currentStep) {
341
364
  return;
342
365
  }
343
- this.allureRuntime.updateStep(currentStep, function (stepResult) {
366
+ var stepUuid = this.pwStepUuid.get(step);
367
+ if (!stepUuid) {
368
+ return;
369
+ }
370
+ this.allureRuntime.updateStep(stepUuid, function (stepResult) {
344
371
  var _getWorstTestStepResu2;
345
372
  var _ref3 = (_getWorstTestStepResu2 = getWorstTestStepResult(stepResult.steps)) !== null && _getWorstTestStepResu2 !== void 0 ? _getWorstTestStepResu2 : {},
346
373
  _ref3$status = _ref3.status,
@@ -351,7 +378,7 @@ export var AllureReporter = /*#__PURE__*/function () {
351
378
  stepResult.statusDetails = _objectSpread({}, getMessageAndTraceFromError(step.error));
352
379
  }
353
380
  });
354
- this.allureRuntime.stopStep(currentStep, {
381
+ this.allureRuntime.stopStep(stepUuid, {
355
382
  duration: step.duration
356
383
  });
357
384
  }
@@ -361,9 +388,8 @@ export var AllureReporter = /*#__PURE__*/function () {
361
388
  var _onTestEnd = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(test, result) {
362
389
  var _this = this,
363
390
  _this$beforeHooksAtta,
364
- _this$afterHooksAttac,
365
- _this$attachmentSteps2;
366
- var testUuid, threadId, thread, error, _test$parent$titlePat, _test$parent$titlePat2, projectSuiteTitle, fileSuiteTitle, suiteTitles, beforeHooksStack, afterHooksStack, attachmentsInBeforeHooks, attachmentsInAfterHooks, attachmentSteps, attachmentToStepMap, attachmentIndex, _iterator2, _step2, _hookStep, _iterator3, _step3, stepUuid, _iterator4, _step4, _hookStep2, i, attachment, stepInfo, _i, _attachment, _stepInfo, hookStep, isBeforeHook, targetStack, stepResult, fileName;
391
+ _this$attachmentTarge3;
392
+ var testUuid, threadId, thread, error, _test$parent$titlePat, _test$parent$titlePat2, projectSuiteTitle, fileSuiteTitle, suiteTitles, beforeHooksStack, afterHooksStack, attachmentsInBeforeHooks, attachmentTargets, targetIndex, _iterator2, _step2, attachment, isRuntimeMessage, stepInfo, _stepInfo$hookStep$uu, _stepInfo$hookStep, stepUuid, hookStep, isBeforeHook, targetStack, stepResult, fileName, _t;
367
393
  return _regenerator().w(function (_context) {
368
394
  while (1) switch (_context.n) {
369
395
  case 0:
@@ -411,89 +437,6 @@ export var AllureReporter = /*#__PURE__*/function () {
411
437
  testResult.status = statusToAllureStats(result.status, test.expectedStatus);
412
438
  testResult.stage = Stage.FINISHED;
413
439
  });
414
- attachmentsInBeforeHooks = (_this$beforeHooksAtta = this.beforeHooksAttachmentsStack.get(test.id)) !== null && _this$beforeHooksAtta !== void 0 ? _this$beforeHooksAtta : [];
415
- attachmentsInAfterHooks = (_this$afterHooksAttac = this.afterHooksAttachmentsStack.get(test.id)) !== null && _this$afterHooksAttac !== void 0 ? _this$afterHooksAttac : [];
416
- attachmentSteps = (_this$attachmentSteps2 = this.attachmentSteps.get(testUuid)) !== null && _this$attachmentSteps2 !== void 0 ? _this$attachmentSteps2 : [];
417
- attachmentToStepMap = new Map();
418
- attachmentIndex = 0;
419
- _iterator2 = _createForOfIteratorHelper(attachmentsInBeforeHooks);
420
- try {
421
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
422
- _hookStep = _step2.value;
423
- attachmentToStepMap.set(attachmentIndex, {
424
- stepUuid: _hookStep.uuid,
425
- isHook: true,
426
- hookStep: _hookStep
427
- });
428
- attachmentIndex++;
429
- }
430
- } catch (err) {
431
- _iterator2.e(err);
432
- } finally {
433
- _iterator2.f();
434
- }
435
- _iterator3 = _createForOfIteratorHelper(attachmentSteps);
436
- try {
437
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
438
- stepUuid = _step3.value;
439
- attachmentToStepMap.set(attachmentIndex, {
440
- stepUuid: stepUuid,
441
- isHook: false
442
- });
443
- attachmentIndex++;
444
- }
445
- } catch (err) {
446
- _iterator3.e(err);
447
- } finally {
448
- _iterator3.f();
449
- }
450
- _iterator4 = _createForOfIteratorHelper(attachmentsInAfterHooks);
451
- try {
452
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
453
- _hookStep2 = _step4.value;
454
- attachmentToStepMap.set(attachmentIndex, {
455
- stepUuid: _hookStep2.uuid,
456
- isHook: true,
457
- hookStep: _hookStep2
458
- });
459
- attachmentIndex++;
460
- }
461
- } catch (err) {
462
- _iterator4.e(err);
463
- } finally {
464
- _iterator4.f();
465
- }
466
- i = 0;
467
- case 1:
468
- if (!(i < result.attachments.length)) {
469
- _context.n = 6;
470
- break;
471
- }
472
- attachment = result.attachments[i];
473
- stepInfo = attachmentToStepMap.get(i);
474
- if (!(stepInfo !== null && stepInfo !== void 0 && stepInfo.isHook)) {
475
- _context.n = 2;
476
- break;
477
- }
478
- return _context.a(3, 5);
479
- case 2:
480
- if (!(stepInfo !== null && stepInfo !== void 0 && stepInfo.stepUuid)) {
481
- _context.n = 4;
482
- break;
483
- }
484
- _context.n = 3;
485
- return this.processAttachment(testUuid, stepInfo.stepUuid, attachment);
486
- case 3:
487
- _context.n = 5;
488
- break;
489
- case 4:
490
- _context.n = 5;
491
- return this.processAttachment(testUuid, undefined, attachment);
492
- case 5:
493
- i++;
494
- _context.n = 1;
495
- break;
496
- case 6:
497
440
  if (result.stdout.length > 0) {
498
441
  this.allureRuntime.writeAttachment(testUuid, undefined, "stdout", Buffer.from(stripAnsi(result.stdout.join("")), "utf-8"), {
499
442
  contentType: ContentType.TEXT
@@ -504,49 +447,78 @@ export var AllureReporter = /*#__PURE__*/function () {
504
447
  contentType: ContentType.TEXT
505
448
  });
506
449
  }
507
-
508
- // FIXME: temp logic for labels override, we need it here to keep the reporter compatible with v2 API
509
- // in next iterations we need to implement the logic for every javascript integration
510
- _i = 0;
511
- case 7:
512
- if (!(_i < result.attachments.length)) {
513
- _context.n = 11;
450
+ attachmentsInBeforeHooks = (_this$beforeHooksAtta = this.beforeHooksAttachmentsStack.get(test.id)) !== null && _this$beforeHooksAtta !== void 0 ? _this$beforeHooksAtta : [];
451
+ attachmentTargets = (_this$attachmentTarge3 = this.attachmentTargets.get(test.id)) !== null && _this$attachmentTarge3 !== void 0 ? _this$attachmentTarge3 : [];
452
+ targetIndex = 0;
453
+ _iterator2 = _createForOfIteratorHelper(result.attachments);
454
+ _context.p = 1;
455
+ _iterator2.s();
456
+ case 2:
457
+ if ((_step2 = _iterator2.n()).done) {
458
+ _context.n = 9;
514
459
  break;
515
460
  }
516
- _attachment = result.attachments[_i];
517
- _stepInfo = attachmentToStepMap.get(_i);
518
- if (!(_stepInfo !== null && _stepInfo !== void 0 && _stepInfo.isHook && _stepInfo.hookStep)) {
519
- _context.n = 10;
461
+ attachment = _step2.value;
462
+ isRuntimeMessage = attachment.contentType === ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE;
463
+ stepInfo = targetIndex < attachmentTargets.length ? attachmentTargets[targetIndex++] : undefined;
464
+ if (!isRuntimeMessage) {
465
+ _context.n = 4;
520
466
  break;
521
467
  }
522
- hookStep = _stepInfo.hookStep;
523
- isBeforeHook = attachmentsInBeforeHooks.includes(hookStep);
524
- targetStack = isBeforeHook ? beforeHooksStack : afterHooksStack;
525
- if (!(_attachment.contentType === ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE)) {
526
- _context.n = 9;
468
+ 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;
469
+ _context.n = 3;
470
+ return this.processAttachment(testUuid, stepUuid, attachment);
471
+ case 3:
472
+ return _context.a(3, 8);
473
+ case 4:
474
+ if (!(stepInfo !== null && stepInfo !== void 0 && stepInfo.hookStep)) {
475
+ _context.n = 5;
527
476
  break;
528
477
  }
529
- _context.n = 8;
530
- return this.processAttachment(testUuid, hookStep.uuid, _attachment);
531
- case 8:
532
- return _context.a(3, 10);
533
- case 9:
478
+ hookStep = stepInfo.hookStep;
479
+ isBeforeHook = attachmentsInBeforeHooks.includes(hookStep);
480
+ targetStack = isBeforeHook ? beforeHooksStack : afterHooksStack;
534
481
  if (targetStack) {
535
482
  stepResult = targetStack.findStepByUuid(hookStep.uuid);
536
483
  if (stepResult) {
537
- fileName = targetStack.addAttachment(_attachment, this.allureRuntime.writer);
484
+ fileName = targetStack.addAttachment(attachment, this.allureRuntime.writer);
538
485
  stepResult.attachments.push({
539
- name: _attachment.name,
540
- type: _attachment.contentType,
486
+ name: attachment.name,
487
+ type: attachment.contentType,
541
488
  source: fileName
542
489
  });
543
490
  }
544
491
  }
545
- case 10:
546
- _i++;
547
- _context.n = 7;
492
+ return _context.a(3, 8);
493
+ case 5:
494
+ if (!(stepInfo !== null && stepInfo !== void 0 && stepInfo.stepUuid)) {
495
+ _context.n = 7;
496
+ break;
497
+ }
498
+ _context.n = 6;
499
+ return this.processAttachment(testUuid, stepInfo.stepUuid, attachment);
500
+ case 6:
501
+ return _context.a(3, 8);
502
+ case 7:
503
+ _context.n = 8;
504
+ return this.processAttachment(testUuid, undefined, attachment);
505
+ case 8:
506
+ _context.n = 2;
548
507
  break;
508
+ case 9:
509
+ _context.n = 11;
510
+ break;
511
+ case 10:
512
+ _context.p = 10;
513
+ _t = _context.v;
514
+ _iterator2.e(_t);
549
515
  case 11:
516
+ _context.p = 11;
517
+ _iterator2.f();
518
+ return _context.f(11);
519
+ case 12:
520
+ // FIXME: temp logic for labels override, we need it here to keep the reporter compatible with v2 API
521
+ // in next iterations we need to implement the logic for every javascript integration
550
522
  this.allureRuntime.updateTest(testUuid, function (testResult) {
551
523
  var mappedLabels = testResult.labels.reduce(function (acc, label) {
552
524
  if (!acc[label.name]) {
@@ -578,10 +550,10 @@ export var AllureReporter = /*#__PURE__*/function () {
578
550
  duration: result.duration
579
551
  });
580
552
  this.allureRuntime.writeTest(testUuid);
581
- case 12:
553
+ case 13:
582
554
  return _context.a(2);
583
555
  }
584
- }, _callee, this);
556
+ }, _callee, this, [[1, 10, 11, 12]]);
585
557
  }));
586
558
  function onTestEnd(_x, _x2) {
587
559
  return _onTestEnd.apply(this, arguments);
@@ -593,7 +565,7 @@ export var AllureReporter = /*#__PURE__*/function () {
593
565
  value: function () {
594
566
  var _addSkippedResults = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
595
567
  var _this2 = this;
596
- var unprocessedCases, _iterator5, _step5, testCase, _t;
568
+ var unprocessedCases, _iterator3, _step3, testCase, _t2;
597
569
  return _regenerator().w(function (_context2) {
598
570
  while (1) switch (_context2.n) {
599
571
  case 0:
@@ -602,15 +574,15 @@ export var AllureReporter = /*#__PURE__*/function () {
602
574
  var titleMetadata = extractMetadataFromString(title);
603
575
  return !_this2.startedTestCasesTitlesCache.includes(titleMetadata.cleanTitle);
604
576
  });
605
- _iterator5 = _createForOfIteratorHelper(unprocessedCases);
577
+ _iterator3 = _createForOfIteratorHelper(unprocessedCases);
606
578
  _context2.p = 1;
607
- _iterator5.s();
579
+ _iterator3.s();
608
580
  case 2:
609
- if ((_step5 = _iterator5.n()).done) {
581
+ if ((_step3 = _iterator3.n()).done) {
610
582
  _context2.n = 4;
611
583
  break;
612
584
  }
613
- testCase = _step5.value;
585
+ testCase = _step3.value;
614
586
  this.onTestBegin(testCase);
615
587
  _context2.n = 3;
616
588
  return this.onTestEnd(testCase, {
@@ -635,11 +607,11 @@ export var AllureReporter = /*#__PURE__*/function () {
635
607
  break;
636
608
  case 5:
637
609
  _context2.p = 5;
638
- _t = _context2.v;
639
- _iterator5.e(_t);
610
+ _t2 = _context2.v;
611
+ _iterator3.e(_t2);
640
612
  case 6:
641
613
  _context2.p = 6;
642
- _iterator5.f();
614
+ _iterator3.f();
643
615
  return _context2.f(6);
644
616
  case 7:
645
617
  return _context2.a(2);
@@ -696,38 +668,39 @@ export var AllureReporter = /*#__PURE__*/function () {
696
668
  }, {
697
669
  key: "processAttachment",
698
670
  value: function () {
699
- var _processAttachment = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(testUuid, attachmentStepUuid, attachment) {
700
- var allureRuntimeMessage, message, parentUuid, contentType, pathWithoutEnd, actualBase64, expectedBase64, diffBase64, diffName;
701
- return _regenerator().w(function (_context4) {
702
- while (1) switch (_context4.n) {
671
+ var _processAttachment = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(testUuid, attachmentStepUuid, attachment) {
672
+ var _replace;
673
+ var allureRuntimeMessage, message, parentUuid, contentType, pathWithoutEndFromSnapshotDir, pathWithoutEnd, fileExists, readImageFromDirs, actualBase64, expectedBase64, diffBase64, diffName;
674
+ return _regenerator().w(function (_context6) {
675
+ while (1) switch (_context6.n) {
703
676
  case 0:
704
677
  if (!(!attachment.body && !attachment.path)) {
705
- _context4.n = 1;
678
+ _context6.n = 1;
706
679
  break;
707
680
  }
708
- return _context4.a(2);
681
+ return _context6.a(2);
709
682
  case 1:
710
683
  allureRuntimeMessage = attachment.contentType === ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE;
711
684
  if (!(allureRuntimeMessage && !attachment.body)) {
712
- _context4.n = 2;
685
+ _context6.n = 2;
713
686
  break;
714
687
  }
715
- return _context4.a(2);
688
+ return _context6.a(2);
716
689
  case 2:
717
690
  if (!allureRuntimeMessage) {
718
- _context4.n = 4;
691
+ _context6.n = 4;
719
692
  break;
720
693
  }
721
694
  message = JSON.parse(attachment.body.toString());
722
695
  if (!(message.type === "step_metadata")) {
723
- _context4.n = 3;
696
+ _context6.n = 3;
724
697
  break;
725
698
  }
726
699
  this.processStepMetadataMessage(attachmentStepUuid, message);
727
- return _context4.a(2);
700
+ return _context6.a(2);
728
701
  case 3:
729
702
  this.allureRuntime.applyRuntimeMessages(testUuid, [message]);
730
- return _context4.a(2);
703
+ return _context6.a(2);
731
704
  case 4:
732
705
  parentUuid = this.allureRuntime.startStep(testUuid, attachmentStepUuid, {
733
706
  name: attachment.name
@@ -738,20 +711,20 @@ export var AllureReporter = /*#__PURE__*/function () {
738
711
  this.allureRuntime.stopStep(parentUuid, undefined);
739
712
  }
740
713
  if (!attachment.body) {
741
- _context4.n = 5;
714
+ _context6.n = 5;
742
715
  break;
743
716
  }
744
717
  this.allureRuntime.writeAttachment(testUuid, parentUuid, attachment.name, attachment.body, {
745
718
  contentType: attachment.contentType
746
719
  });
747
- _context4.n = 7;
720
+ _context6.n = 7;
748
721
  break;
749
722
  case 5:
750
723
  if (existsSync(attachment.path)) {
751
- _context4.n = 6;
724
+ _context6.n = 6;
752
725
  break;
753
726
  }
754
- return _context4.a(2);
727
+ return _context6.a(2);
755
728
  case 6:
756
729
  contentType = attachment.name === "trace" && attachment.contentType === "application/zip" ? "application/vnd.allure.playwright-trace" : attachment.contentType;
757
730
  this.allureRuntime.writeAttachment(testUuid, parentUuid, attachment.name, attachment.path, {
@@ -759,30 +732,91 @@ export var AllureReporter = /*#__PURE__*/function () {
759
732
  });
760
733
  case 7:
761
734
  if (attachment.name.match(diffEndRegexp)) {
762
- _context4.n = 8;
735
+ _context6.n = 8;
763
736
  break;
764
737
  }
765
- return _context4.a(2);
738
+ return _context6.a(2);
766
739
  case 8:
767
- pathWithoutEnd = attachment.path.replace(diffEndRegexp, "");
768
- if (!this.processedDiffs.includes(pathWithoutEnd)) {
769
- _context4.n = 9;
740
+ pathWithoutEndFromSnapshotDir = (_replace = attachment.path.replace(this.outputDir, this.snapshotDir)) === null || _replace === void 0 ? void 0 : _replace.replace(diffEndRegexp, "").replace(/\.png/, "");
741
+ pathWithoutEnd = attachment.path.replace(diffEndRegexp, "").replace(/\.png/, "");
742
+ if (!(this.processedDiffs.includes(pathWithoutEnd) || this.processedDiffs.includes(pathWithoutEndFromSnapshotDir))) {
743
+ _context6.n = 9;
770
744
  break;
771
745
  }
772
- return _context4.a(2);
746
+ return _context6.a(2);
773
747
  case 9:
774
- _context4.n = 10;
775
- return readImageAsBase64("".concat(pathWithoutEnd, "-actual.png"));
748
+ fileExists = /*#__PURE__*/function () {
749
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(filePath) {
750
+ return _regenerator().w(function (_context4) {
751
+ while (1) switch (_context4.n) {
752
+ case 0:
753
+ _context4.n = 1;
754
+ return access(filePath).then(function () {
755
+ return true;
756
+ })["catch"](function () {
757
+ return false;
758
+ });
759
+ case 1:
760
+ return _context4.a(2, _context4.v);
761
+ }
762
+ }, _callee4);
763
+ }));
764
+ return function fileExists(_x6) {
765
+ return _ref5.apply(this, arguments);
766
+ };
767
+ }();
768
+ readImageFromDirs = /*#__PURE__*/function () {
769
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(modifier) {
770
+ var defaultPath, snapshotPath;
771
+ return _regenerator().w(function (_context5) {
772
+ while (1) switch (_context5.n) {
773
+ case 0:
774
+ defaultPath = "".concat(pathWithoutEnd, "-").concat(modifier, ".png");
775
+ snapshotPath = "".concat(pathWithoutEndFromSnapshotDir, "-").concat(modifier, ".png");
776
+ _context5.n = 1;
777
+ return fileExists(defaultPath);
778
+ case 1:
779
+ if (!_context5.v) {
780
+ _context5.n = 3;
781
+ break;
782
+ }
783
+ _context5.n = 2;
784
+ return readImageAsBase64(defaultPath);
785
+ case 2:
786
+ return _context5.a(2, _context5.v);
787
+ case 3:
788
+ _context5.n = 4;
789
+ return fileExists(snapshotPath);
790
+ case 4:
791
+ if (!_context5.v) {
792
+ _context5.n = 6;
793
+ break;
794
+ }
795
+ _context5.n = 5;
796
+ return readImageAsBase64(snapshotPath);
797
+ case 5:
798
+ return _context5.a(2, _context5.v);
799
+ case 6:
800
+ return _context5.a(2, undefined);
801
+ }
802
+ }, _callee5);
803
+ }));
804
+ return function readImageFromDirs(_x7) {
805
+ return _ref6.apply(this, arguments);
806
+ };
807
+ }();
808
+ _context6.n = 10;
809
+ return readImageFromDirs("actual");
776
810
  case 10:
777
- actualBase64 = _context4.v;
778
- _context4.n = 11;
779
- return readImageAsBase64("".concat(pathWithoutEnd, "-expected.png"));
811
+ actualBase64 = _context6.v;
812
+ _context6.n = 11;
813
+ return readImageFromDirs("expected");
780
814
  case 11:
781
- expectedBase64 = _context4.v;
782
- _context4.n = 12;
783
- return readImageAsBase64("".concat(pathWithoutEnd, "-diff.png"));
815
+ expectedBase64 = _context6.v;
816
+ _context6.n = 12;
817
+ return readImageFromDirs("diff");
784
818
  case 12:
785
- diffBase64 = _context4.v;
819
+ diffBase64 = _context6.v;
786
820
  diffName = attachment.name.replace(diffEndRegexp, "");
787
821
  this.allureRuntime.writeAttachment(testUuid, undefined, diffName, Buffer.from(JSON.stringify({
788
822
  expected: expectedBase64,
@@ -795,9 +829,9 @@ export var AllureReporter = /*#__PURE__*/function () {
795
829
  });
796
830
  this.processedDiffs.push(pathWithoutEnd);
797
831
  case 13:
798
- return _context4.a(2);
832
+ return _context6.a(2);
799
833
  }
800
- }, _callee4, this);
834
+ }, _callee6, this);
801
835
  }));
802
836
  function processAttachment(_x3, _x4, _x5) {
803
837
  return _processAttachment.apply(this, arguments);
@@ -816,7 +850,7 @@ export var AllureReporter = /*#__PURE__*/function () {
816
850
  * @deprecated for removal, import functions directly from "allure-js-commons".
817
851
  */
818
852
  function _shouldIgnoreStep(step) {
819
- if (!this.options.detail && step.category !== "test.step") {
853
+ if (!this.options.detail && !["test.step", "attach", "test.attach"].includes(step.category)) {
820
854
  return true;
821
855
  }
822
856