allure-playwright 3.4.2 → 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
@@ -50,7 +50,7 @@ export var AllureReporter = /*#__PURE__*/function () {
50
50
  _defineProperty(this, "processedDiffs", []);
51
51
  _defineProperty(this, "startedTestCasesTitlesCache", []);
52
52
  _defineProperty(this, "allureResultsUuids", new Map());
53
- _defineProperty(this, "attachmentSteps", new Map());
53
+ _defineProperty(this, "attachmentTargets", new Map());
54
54
  _defineProperty(this, "beforeHooksStepsStack", new Map());
55
55
  _defineProperty(this, "afterHooksStepsStack", new Map());
56
56
  _defineProperty(this, "beforeHooksAttachmentsStack", new Map());
@@ -254,7 +254,7 @@ export var AllureReporter = /*#__PURE__*/function () {
254
254
  }, {
255
255
  key: "onStepBegin",
256
256
  value: function onStepBegin(test, _result, step) {
257
- var _this$pwStepUuid$get;
257
+ var _this$pwStepUuid$get2;
258
258
  var isRootBeforeHook = step.title === BEFORE_HOOKS_ROOT_STEP_TITLE;
259
259
  var isRootAfterHook = step.title === AFTER_HOOKS_ROOT_STEP_TITLE;
260
260
  var isRootHook = isRootBeforeHook || isRootAfterHook;
@@ -262,12 +262,6 @@ export var AllureReporter = /*#__PURE__*/function () {
262
262
  var isAfterHookDescendant = isAfterHookStep(step);
263
263
  var isHookStep = isBeforeHookDescendant || isAfterHookDescendant;
264
264
  var testUuid = this.allureResultsUuids.get(test.id);
265
- if (["test.attach", "attach"].includes(step.category) && !isHookStep) {
266
- var _this$allureRuntime, _this$attachmentSteps;
267
- var currentStep = (_this$allureRuntime = this.allureRuntime) === null || _this$allureRuntime === void 0 ? void 0 : _this$allureRuntime.currentStep(testUuid);
268
- this.attachmentSteps.set(testUuid, [].concat(_toConsumableArray((_this$attachmentSteps = this.attachmentSteps.get(testUuid)) !== null && _this$attachmentSteps !== void 0 ? _this$attachmentSteps : []), [currentStep]));
269
- return;
270
- }
271
265
  if (_assertClassBrand(_AllureReporter_brand, this, _shouldIgnoreStep).call(this, step)) {
272
266
  return;
273
267
  }
@@ -277,20 +271,38 @@ export var AllureReporter = /*#__PURE__*/function () {
277
271
  stage: Stage.RUNNING,
278
272
  uuid: randomUuid()
279
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
+ }
280
284
  if (isHookStep) {
281
285
  var stack = isBeforeHookDescendant ? this.beforeHooksStepsStack.get(test.id) : this.afterHooksStepsStack.get(test.id);
282
286
  if (["test.attach", "attach"].includes(step.category)) {
287
+ var _this$attachmentTarge2;
288
+ var hookStepWithUuid;
283
289
  stack.startStep(baseStep);
284
290
  var attachStack = isBeforeHookDescendant ? this.beforeHooksAttachmentsStack : this.afterHooksAttachmentsStack;
285
291
  stack.updateStep(function (stepResult) {
286
292
  var _attachStack$get;
293
+ hookStepWithUuid = _objectSpread(_objectSpread({}, step), {}, {
294
+ uuid: stepResult.uuid
295
+ });
287
296
  stepResult.name = normalizeHookTitle(stepResult.name);
288
297
  stepResult.stage = Stage.FINISHED;
289
- attachStack.set(test.id, [].concat(_toConsumableArray((_attachStack$get = attachStack.get(test.id)) !== null && _attachStack$get !== void 0 ? _attachStack$get : []), [_objectSpread(_objectSpread({}, step), {}, {
290
- uuid: stepResult.uuid
291
- })]));
298
+ attachStack.set(test.id, [].concat(_toConsumableArray((_attachStack$get = attachStack.get(test.id)) !== null && _attachStack$get !== void 0 ? _attachStack$get : []), [hookStepWithUuid]));
292
299
  });
293
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);
294
306
  return;
295
307
  }
296
308
  stack.startStep(baseStep);
@@ -306,7 +318,7 @@ export var AllureReporter = /*#__PURE__*/function () {
306
318
  }
307
319
  return;
308
320
  }
309
- var parentUuid = step.parent ? (_this$pwStepUuid$get = this.pwStepUuid.get(step.parent)) !== null && _this$pwStepUuid$get !== void 0 ? _this$pwStepUuid$get : null : null;
321
+ var parentUuid = step.parent ? (_this$pwStepUuid$get2 = this.pwStepUuid.get(step.parent)) !== null && _this$pwStepUuid$get2 !== void 0 ? _this$pwStepUuid$get2 : null : null;
310
322
  var createdUuid = this.allureRuntime.startStep(testUuid, parentUuid, baseStep);
311
323
  if (createdUuid) {
312
324
  this.pwStepUuid.set(step, createdUuid);
@@ -376,9 +388,8 @@ export var AllureReporter = /*#__PURE__*/function () {
376
388
  var _onTestEnd = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(test, result) {
377
389
  var _this = this,
378
390
  _this$beforeHooksAtta,
379
- _this$afterHooksAttac,
380
- _this$attachmentSteps2;
381
- 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;
382
393
  return _regenerator().w(function (_context) {
383
394
  while (1) switch (_context.n) {
384
395
  case 0:
@@ -426,89 +437,6 @@ export var AllureReporter = /*#__PURE__*/function () {
426
437
  testResult.status = statusToAllureStats(result.status, test.expectedStatus);
427
438
  testResult.stage = Stage.FINISHED;
428
439
  });
429
- attachmentsInBeforeHooks = (_this$beforeHooksAtta = this.beforeHooksAttachmentsStack.get(test.id)) !== null && _this$beforeHooksAtta !== void 0 ? _this$beforeHooksAtta : [];
430
- attachmentsInAfterHooks = (_this$afterHooksAttac = this.afterHooksAttachmentsStack.get(test.id)) !== null && _this$afterHooksAttac !== void 0 ? _this$afterHooksAttac : [];
431
- attachmentSteps = (_this$attachmentSteps2 = this.attachmentSteps.get(testUuid)) !== null && _this$attachmentSteps2 !== void 0 ? _this$attachmentSteps2 : [];
432
- attachmentToStepMap = new Map();
433
- attachmentIndex = 0;
434
- _iterator2 = _createForOfIteratorHelper(attachmentsInBeforeHooks);
435
- try {
436
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
437
- _hookStep = _step2.value;
438
- attachmentToStepMap.set(attachmentIndex, {
439
- stepUuid: _hookStep.uuid,
440
- isHook: true,
441
- hookStep: _hookStep
442
- });
443
- attachmentIndex++;
444
- }
445
- } catch (err) {
446
- _iterator2.e(err);
447
- } finally {
448
- _iterator2.f();
449
- }
450
- _iterator3 = _createForOfIteratorHelper(attachmentSteps);
451
- try {
452
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
453
- stepUuid = _step3.value;
454
- attachmentToStepMap.set(attachmentIndex, {
455
- stepUuid: stepUuid,
456
- isHook: false
457
- });
458
- attachmentIndex++;
459
- }
460
- } catch (err) {
461
- _iterator3.e(err);
462
- } finally {
463
- _iterator3.f();
464
- }
465
- _iterator4 = _createForOfIteratorHelper(attachmentsInAfterHooks);
466
- try {
467
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
468
- _hookStep2 = _step4.value;
469
- attachmentToStepMap.set(attachmentIndex, {
470
- stepUuid: _hookStep2.uuid,
471
- isHook: true,
472
- hookStep: _hookStep2
473
- });
474
- attachmentIndex++;
475
- }
476
- } catch (err) {
477
- _iterator4.e(err);
478
- } finally {
479
- _iterator4.f();
480
- }
481
- i = 0;
482
- case 1:
483
- if (!(i < result.attachments.length)) {
484
- _context.n = 6;
485
- break;
486
- }
487
- attachment = result.attachments[i];
488
- stepInfo = attachmentToStepMap.get(i);
489
- if (!(stepInfo !== null && stepInfo !== void 0 && stepInfo.isHook)) {
490
- _context.n = 2;
491
- break;
492
- }
493
- return _context.a(3, 5);
494
- case 2:
495
- if (!(stepInfo !== null && stepInfo !== void 0 && stepInfo.stepUuid)) {
496
- _context.n = 4;
497
- break;
498
- }
499
- _context.n = 3;
500
- return this.processAttachment(testUuid, stepInfo.stepUuid, attachment);
501
- case 3:
502
- _context.n = 5;
503
- break;
504
- case 4:
505
- _context.n = 5;
506
- return this.processAttachment(testUuid, undefined, attachment);
507
- case 5:
508
- i++;
509
- _context.n = 1;
510
- break;
511
- case 6:
512
440
  if (result.stdout.length > 0) {
513
441
  this.allureRuntime.writeAttachment(testUuid, undefined, "stdout", Buffer.from(stripAnsi(result.stdout.join("")), "utf-8"), {
514
442
  contentType: ContentType.TEXT
@@ -519,49 +447,78 @@ export var AllureReporter = /*#__PURE__*/function () {
519
447
  contentType: ContentType.TEXT
520
448
  });
521
449
  }
522
-
523
- // FIXME: temp logic for labels override, we need it here to keep the reporter compatible with v2 API
524
- // in next iterations we need to implement the logic for every javascript integration
525
- _i = 0;
526
- case 7:
527
- if (!(_i < result.attachments.length)) {
528
- _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;
529
459
  break;
530
460
  }
531
- _attachment = result.attachments[_i];
532
- _stepInfo = attachmentToStepMap.get(_i);
533
- if (!(_stepInfo !== null && _stepInfo !== void 0 && _stepInfo.isHook && _stepInfo.hookStep)) {
534
- _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;
535
466
  break;
536
467
  }
537
- hookStep = _stepInfo.hookStep;
538
- isBeforeHook = attachmentsInBeforeHooks.includes(hookStep);
539
- targetStack = isBeforeHook ? beforeHooksStack : afterHooksStack;
540
- if (!(_attachment.contentType === ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE)) {
541
- _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;
542
476
  break;
543
477
  }
544
- _context.n = 8;
545
- return this.processAttachment(testUuid, hookStep.uuid, _attachment);
546
- case 8:
547
- return _context.a(3, 10);
548
- case 9:
478
+ hookStep = stepInfo.hookStep;
479
+ isBeforeHook = attachmentsInBeforeHooks.includes(hookStep);
480
+ targetStack = isBeforeHook ? beforeHooksStack : afterHooksStack;
549
481
  if (targetStack) {
550
482
  stepResult = targetStack.findStepByUuid(hookStep.uuid);
551
483
  if (stepResult) {
552
- fileName = targetStack.addAttachment(_attachment, this.allureRuntime.writer);
484
+ fileName = targetStack.addAttachment(attachment, this.allureRuntime.writer);
553
485
  stepResult.attachments.push({
554
- name: _attachment.name,
555
- type: _attachment.contentType,
486
+ name: attachment.name,
487
+ type: attachment.contentType,
556
488
  source: fileName
557
489
  });
558
490
  }
559
491
  }
560
- case 10:
561
- _i++;
562
- _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;
507
+ break;
508
+ case 9:
509
+ _context.n = 11;
563
510
  break;
511
+ case 10:
512
+ _context.p = 10;
513
+ _t = _context.v;
514
+ _iterator2.e(_t);
564
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
565
522
  this.allureRuntime.updateTest(testUuid, function (testResult) {
566
523
  var mappedLabels = testResult.labels.reduce(function (acc, label) {
567
524
  if (!acc[label.name]) {
@@ -593,10 +550,10 @@ export var AllureReporter = /*#__PURE__*/function () {
593
550
  duration: result.duration
594
551
  });
595
552
  this.allureRuntime.writeTest(testUuid);
596
- case 12:
553
+ case 13:
597
554
  return _context.a(2);
598
555
  }
599
- }, _callee, this);
556
+ }, _callee, this, [[1, 10, 11, 12]]);
600
557
  }));
601
558
  function onTestEnd(_x, _x2) {
602
559
  return _onTestEnd.apply(this, arguments);
@@ -608,7 +565,7 @@ export var AllureReporter = /*#__PURE__*/function () {
608
565
  value: function () {
609
566
  var _addSkippedResults = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
610
567
  var _this2 = this;
611
- var unprocessedCases, _iterator5, _step5, testCase, _t;
568
+ var unprocessedCases, _iterator3, _step3, testCase, _t2;
612
569
  return _regenerator().w(function (_context2) {
613
570
  while (1) switch (_context2.n) {
614
571
  case 0:
@@ -617,15 +574,15 @@ export var AllureReporter = /*#__PURE__*/function () {
617
574
  var titleMetadata = extractMetadataFromString(title);
618
575
  return !_this2.startedTestCasesTitlesCache.includes(titleMetadata.cleanTitle);
619
576
  });
620
- _iterator5 = _createForOfIteratorHelper(unprocessedCases);
577
+ _iterator3 = _createForOfIteratorHelper(unprocessedCases);
621
578
  _context2.p = 1;
622
- _iterator5.s();
579
+ _iterator3.s();
623
580
  case 2:
624
- if ((_step5 = _iterator5.n()).done) {
581
+ if ((_step3 = _iterator3.n()).done) {
625
582
  _context2.n = 4;
626
583
  break;
627
584
  }
628
- testCase = _step5.value;
585
+ testCase = _step3.value;
629
586
  this.onTestBegin(testCase);
630
587
  _context2.n = 3;
631
588
  return this.onTestEnd(testCase, {
@@ -650,11 +607,11 @@ export var AllureReporter = /*#__PURE__*/function () {
650
607
  break;
651
608
  case 5:
652
609
  _context2.p = 5;
653
- _t = _context2.v;
654
- _iterator5.e(_t);
610
+ _t2 = _context2.v;
611
+ _iterator3.e(_t2);
655
612
  case 6:
656
613
  _context2.p = 6;
657
- _iterator5.f();
614
+ _iterator3.f();
658
615
  return _context2.f(6);
659
616
  case 7:
660
617
  return _context2.a(2);
@@ -893,7 +850,7 @@ export var AllureReporter = /*#__PURE__*/function () {
893
850
  * @deprecated for removal, import functions directly from "allure-js-commons".
894
851
  */
895
852
  function _shouldIgnoreStep(step) {
896
- if (!this.options.detail && step.category !== "test.step") {
853
+ if (!this.options.detail && !["test.step", "attach", "test.attach"].includes(step.category)) {
897
854
  return true;
898
855
  }
899
856