allure-playwright 3.10.2 → 3.11.1

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 () {
@@ -1156,12 +1185,23 @@ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
1156
1185
  }, {
1157
1186
  key: "getPlaywrightSuitePrototype",
1158
1187
  value: function getPlaywrightSuitePrototype() {
1188
+ var playwrightTestRequire = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : (0, _nodeModule.createRequire)(localRequire.resolve("@playwright/test"));
1159
1189
  try {
1160
1190
  var _playwrightCommon$tes;
1161
- var playwrightTestRequire = (0, _nodeModule.createRequire)(localRequire.resolve("@playwright/test"));
1162
1191
  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;
1192
+ var suitePrototype = (_playwrightCommon$tes = playwrightCommon.test) === null || _playwrightCommon$tes === void 0 || (_playwrightCommon$tes = _playwrightCommon$tes.Suite) === null || _playwrightCommon$tes === void 0 ? void 0 : _playwrightCommon$tes.prototype;
1193
+ if (suitePrototype) {
1194
+ return suitePrototype;
1195
+ }
1164
1196
  } catch (_unused) {
1197
+ // Playwright 1.53-1.59 didn't export playwright/lib/common, but the Suite lived in lib/common/test.js.
1198
+ }
1199
+ try {
1200
+ var _playwrightCommonTest;
1201
+ var playwrightPackagePath = playwrightTestRequire.resolve("playwright/package.json");
1202
+ var playwrightCommonTest = playwrightTestRequire(_nodePath["default"].join(_nodePath["default"].dirname(playwrightPackagePath), "lib/common/test.js"));
1203
+ return (_playwrightCommonTest = playwrightCommonTest.Suite) === null || _playwrightCommonTest === void 0 ? void 0 : _playwrightCommonTest.prototype;
1204
+ } catch (_unused2) {
1165
1205
  return undefined;
1166
1206
  }
1167
1207
  }
@@ -1410,5 +1450,24 @@ var allure = exports.allure = _legacy.allurePlaywrightLegacyApi;
1410
1450
  /**
1411
1451
  * @deprecated for removal, import functions directly from "@playwright/test".
1412
1452
  */
1453
+
1454
+ var toGlobalErrorMessage = function toGlobalErrorMessage(name, details) {
1455
+ return {
1456
+ type: "global_error",
1457
+ data: _objectSpread(_objectSpread({}, details), {}, {
1458
+ message: details.message ? "".concat(name, " failed: ").concat(details.message) : "".concat(name, " failed")
1459
+ })
1460
+ };
1461
+ };
1462
+ var isDirectHookStep = function isDirectHookStep(step) {
1463
+ var _step$parent, _step$parent2;
1464
+ 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";
1465
+ };
1466
+ var isRootHookStep = function isRootHookStep(step) {
1467
+ return step.title === _utils.BEFORE_HOOKS_ROOT_STEP_TITLE || step.title === _utils.AFTER_HOOKS_ROOT_STEP_TITLE;
1468
+ };
1469
+ var isGlobalErrorHookStep = function isGlobalErrorHookStep(step) {
1470
+ return isRootHookStep(step) || isDirectHookStep(step);
1471
+ };
1413
1472
  var _default = exports["default"] = AllureReporter;
1414
1473
  //# sourceMappingURL=index.js.map