allure-playwright 3.10.2 → 3.11.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/README.md CHANGED
@@ -76,6 +76,19 @@ directory.
76
76
 
77
77
  You may select another location, or further customize the reporter's behavior with [the configuration options](https://allurereport.org/docs/playwright-configuration/).
78
78
 
79
+ To use name-based test selectors instead of source locations, enable the legacy full name format:
80
+
81
+ ```js
82
+ import { defineConfig } from "@playwright/test";
83
+
84
+ export default defineConfig({
85
+ reporter: [["allure-playwright", { useLegacyFullName: true }]],
86
+ });
87
+ ```
88
+
89
+ This produces full names in the `file#suite test` format instead of `file:line:column`. Test names must be unique
90
+ within the same suite when this option is enabled.
91
+
79
92
  ### View the report
80
93
 
81
94
  Use Allure Report 2:
package/dist/cjs/index.js CHANGED
@@ -78,6 +78,7 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
78
78
  _defineProperty(this, "pendingAttachmentTasks", new Map());
79
79
  _defineProperty(this, "attachmentTargetByStep", new WeakMap());
80
80
  _defineProperty(this, "pwStepUuid", new WeakMap());
81
+ _defineProperty(this, "emittedHookGlobalErrorKeys", new Set());
81
82
  _defineProperty(this, "testPlan", (0, _reporter.parseTestPlan)());
82
83
  this.options = _objectSpread({
83
84
  suiteTitle: true,
@@ -170,6 +171,7 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
170
171
  key: "onBegin",
171
172
  value: function onBegin(suite) {
172
173
  this.suite = suite;
174
+ this.emittedHookGlobalErrorKeys.clear();
173
175
  this.allureRuntime = new _reporter.ReporterRuntime(_objectSpread(_objectSpread({}, this.options), {}, {
174
176
  writer: (0, _reporter.createDefaultWriter)({
175
177
  resultsDir: this.options.resultsDir
@@ -189,7 +191,7 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
189
191
  parameters: [],
190
192
  steps: [],
191
193
  testCaseId: (0, _reporter.md5)(metadata.testCaseIdBase),
192
- fullName: metadata.fullName,
194
+ fullName: this.options.useLegacyFullName ? metadata.legacyFullName : metadata.fullName,
193
195
  titlePath: titlePath
194
196
  };
195
197
  result.labels.push((0, _reporter.getLanguageLabel)());
@@ -628,6 +630,10 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
628
630
 
629
631
  // If stack exists (was lazily created), finalize the root hook step
630
632
  if (stack) {
633
+ var rootStep = stack.currentStep();
634
+ if (step.error && rootStep && !rootStep.steps.length) {
635
+ this.emitGlobalErrorFromHookStep(step);
636
+ }
631
637
  stack.updateStep(function (stepResult) {
632
638
  return (0, _utils.finalizeStepResult)(stepResult, step);
633
639
  });
@@ -655,6 +661,7 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
655
661
  if (!_stack3) {
656
662
  return;
657
663
  }
664
+ this.emitGlobalErrorFromHookStep(step);
658
665
  _stack3.updateStep(function (stepResult) {
659
666
  return (0, _utils.finalizeStepResult)(stepResult, step);
660
667
  });
@@ -739,6 +746,13 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
739
746
  }
740
747
  }
741
748
  testResult.status = (0, _utils.statusToAllureStats)(result.status, test.expectedStatus);
749
+ if (result.retry > 0) {
750
+ testResult.parameters.push({
751
+ name: "Retry",
752
+ value: String(result.retry),
753
+ excluded: true
754
+ });
755
+ }
742
756
  testResult.stage = _allureJsCommons.Stage.FINISHED;
743
757
  });
744
758
  if (result.stdout.length > 0) {
@@ -911,6 +925,21 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
911
925
  }
912
926
  return onTestEnd;
913
927
  }()
928
+ }, {
929
+ key: "emitGlobalErrorFromHookStep",
930
+ value: function emitGlobalErrorFromHookStep(step) {
931
+ var _details$message, _details$trace;
932
+ if (!step.error || !isGlobalErrorHookStep(step)) {
933
+ return;
934
+ }
935
+ var details = (0, _sdk.getMessageAndTraceFromError)(step.error);
936
+ var key = [step.title, step.startTime.getTime(), (_details$message = details.message) !== null && _details$message !== void 0 ? _details$message : "", (_details$trace = details.trace) !== null && _details$trace !== void 0 ? _details$trace : ""].join("\0");
937
+ if (this.emittedHookGlobalErrorKeys.has(key)) {
938
+ return;
939
+ }
940
+ this.emittedHookGlobalErrorKeys.add(key);
941
+ this.allureRuntime.applyGlobalRuntimeMessages([toGlobalErrorMessage((0, _utils.normalizeHookTitle)(step.title), details)]);
942
+ }
914
943
  }, {
915
944
  key: "addSkippedResults",
916
945
  value: function () {
@@ -1410,5 +1439,24 @@ var allure = exports.allure = _legacy.allurePlaywrightLegacyApi;
1410
1439
  /**
1411
1440
  * @deprecated for removal, import functions directly from "@playwright/test".
1412
1441
  */
1442
+
1443
+ var toGlobalErrorMessage = function toGlobalErrorMessage(name, details) {
1444
+ return {
1445
+ type: "global_error",
1446
+ data: _objectSpread(_objectSpread({}, details), {}, {
1447
+ message: details.message ? "".concat(name, " failed: ").concat(details.message) : "".concat(name, " failed")
1448
+ })
1449
+ };
1450
+ };
1451
+ var isDirectHookStep = function isDirectHookStep(step) {
1452
+ var _step$parent, _step$parent2;
1453
+ return (((_step$parent = step.parent) === null || _step$parent === void 0 ? void 0 : _step$parent.title) === _utils.BEFORE_HOOKS_ROOT_STEP_TITLE || ((_step$parent2 = step.parent) === null || _step$parent2 === void 0 ? void 0 : _step$parent2.title) === _utils.AFTER_HOOKS_ROOT_STEP_TITLE) && step.category === "hook";
1454
+ };
1455
+ var isRootHookStep = function isRootHookStep(step) {
1456
+ return step.title === _utils.BEFORE_HOOKS_ROOT_STEP_TITLE || step.title === _utils.AFTER_HOOKS_ROOT_STEP_TITLE;
1457
+ };
1458
+ var isGlobalErrorHookStep = function isGlobalErrorHookStep(step) {
1459
+ return isRootHookStep(step) || isDirectHookStep(step);
1460
+ };
1413
1461
  var _default = exports["default"] = AllureReporter;
1414
1462
  //# sourceMappingURL=index.js.map