allure-playwright 2.15.1 → 3.0.0-beta.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.
Files changed (45) hide show
  1. package/README.md +138 -66
  2. package/dist/cjs/autoconfig.js +6 -0
  3. package/dist/cjs/autoconfig.js.map +1 -0
  4. package/dist/cjs/index.js +572 -0
  5. package/dist/cjs/index.js.map +1 -0
  6. package/dist/cjs/legacy.js +176 -0
  7. package/dist/cjs/legacy.js.map +1 -0
  8. package/dist/cjs/model.js +2 -0
  9. package/dist/cjs/model.js.map +1 -0
  10. package/dist/cjs/runtime.js +58 -0
  11. package/dist/cjs/runtime.js.map +1 -0
  12. package/dist/cjs/testplan.js +18 -0
  13. package/dist/cjs/testplan.js.map +1 -0
  14. package/dist/cjs/utils.js +20 -0
  15. package/dist/cjs/utils.js.map +1 -0
  16. package/dist/esm/autoconfig.js +4 -0
  17. package/dist/esm/autoconfig.js.map +1 -0
  18. package/dist/esm/index.js +556 -0
  19. package/dist/esm/index.js.map +1 -0
  20. package/dist/esm/legacy.js +168 -0
  21. package/dist/esm/legacy.js.map +1 -0
  22. package/dist/esm/model.js +2 -0
  23. package/dist/esm/model.js.map +1 -0
  24. package/dist/esm/runtime.js +51 -0
  25. package/dist/esm/runtime.js.map +1 -0
  26. package/dist/esm/testplan.js +12 -0
  27. package/dist/esm/testplan.js.map +1 -0
  28. package/dist/esm/utils.js +14 -0
  29. package/dist/esm/utils.js.map +1 -0
  30. package/dist/types/autoconfig.d.ts +1 -0
  31. package/dist/types/index.d.ts +51 -0
  32. package/dist/types/legacy.d.ts +34 -0
  33. package/dist/types/model.d.ts +7 -0
  34. package/dist/types/runtime.d.ts +6 -0
  35. package/dist/types/utils.d.ts +3 -0
  36. package/package.json +42 -13
  37. package/dist/helpers.d.ts +0 -30
  38. package/dist/helpers.js +0 -112
  39. package/dist/helpers.js.map +0 -1
  40. package/dist/index.d.ts +0 -41
  41. package/dist/index.js +0 -316
  42. package/dist/index.js.map +0 -1
  43. package/dist/testplan.js +0 -16
  44. package/dist/testplan.js.map +0 -1
  45. /package/dist/{testplan.d.ts → types/testplan.d.ts} +0 -0
@@ -0,0 +1,572 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = exports.allure = exports.AllureReporter = void 0;
7
+ Object.defineProperty(exports, "expect", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _test.expect;
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "test", {
14
+ enumerable: true,
15
+ get: function get() {
16
+ return _test.test;
17
+ }
18
+ });
19
+ var _nodeFs = require("node:fs");
20
+ var _nodeOs = _interopRequireDefault(require("node:os"));
21
+ var _nodePath = _interopRequireDefault(require("node:path"));
22
+ var _nodeProcess = _interopRequireDefault(require("node:process"));
23
+ var _allureJsCommons = require("allure-js-commons");
24
+ var _sdk = require("allure-js-commons/sdk");
25
+ var _reporter = require("allure-js-commons/sdk/reporter");
26
+ var _legacy = require("./legacy.js");
27
+ var _utils = require("./utils.js");
28
+ var _test = require("@playwright/test");
29
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
30
+ 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); }
31
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
32
+ 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; } } }; }
33
+ 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); }
34
+ 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); }); }; }
35
+ function _toArray(r) { return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest(); }
36
+ 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."); }
37
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
38
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
39
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
40
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
41
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
42
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
43
+ 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; }
44
+ 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; }
45
+ 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; }
46
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
47
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
48
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
49
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
50
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
51
+ 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); }
52
+ // TODO: move to utils.ts
53
+ var diffEndRegexp = /-((expected)|(diff)|(actual))\.png$/;
54
+ // 12 (allureattach) + 1 (_) + 36 (uuid v4) + 1 (_)
55
+ var stepAttachPrefixLength = 50;
56
+ var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {
57
+ function AllureReporter(config) {
58
+ _classCallCheck(this, AllureReporter);
59
+ _defineProperty(this, "config", void 0);
60
+ _defineProperty(this, "suite", void 0);
61
+ _defineProperty(this, "options", void 0);
62
+ _defineProperty(this, "allureRuntime", void 0);
63
+ _defineProperty(this, "hostname", _nodeProcess["default"].env.ALLURE_HOST_NAME || _nodeOs["default"].hostname());
64
+ _defineProperty(this, "globalStartTime", new Date());
65
+ _defineProperty(this, "processedDiffs", []);
66
+ _defineProperty(this, "startedTestCasesTitlesCache", []);
67
+ _defineProperty(this, "allureResultsUuids", new Map());
68
+ this.options = _objectSpread({
69
+ suiteTitle: true,
70
+ detail: true
71
+ }, config);
72
+ }
73
+ return _createClass(AllureReporter, [{
74
+ key: "onConfigure",
75
+ value: function onConfigure(config) {
76
+ this.config = config;
77
+ var testPlan = (0, _reporter.parseTestPlan)();
78
+ if (!testPlan) {
79
+ return;
80
+ }
81
+
82
+ // @ts-ignore
83
+ var configElement = config[Object.getOwnPropertySymbols(config)[0]];
84
+ if (!configElement) {
85
+ return;
86
+ }
87
+ var testsWithSelectors = testPlan.tests.filter(function (test) {
88
+ return test.selector;
89
+ });
90
+ var v1ReporterTests = [];
91
+ var v2ReporterTests = [];
92
+ var cliArgs = [];
93
+ testsWithSelectors.forEach(function (test) {
94
+ if (!/#/.test(test.selector)) {
95
+ v2ReporterTests.push(test);
96
+ return;
97
+ }
98
+ v1ReporterTests.push(test);
99
+ });
100
+ if (v2ReporterTests.length) {
101
+ // we need to cut off column because playwright works only with line number
102
+ var v2SelectorsArgs = v2ReporterTests.map(function (test) {
103
+ return test.selector.replace(/:\d+$/, "");
104
+ }).map(function (selector) {
105
+ return (0, _reporter.escapeRegExp)(selector);
106
+ });
107
+ cliArgs.push.apply(cliArgs, _toConsumableArray(v2SelectorsArgs));
108
+ }
109
+ if (v1ReporterTests.length) {
110
+ var v1SelectorsArgs = v1ReporterTests
111
+ // we can filter tests only by absolute path, so we need to cut off test name
112
+ .map(function (test) {
113
+ return test.selector.split("#")[0];
114
+ }).map(function (selector) {
115
+ return (0, _reporter.escapeRegExp)(selector);
116
+ });
117
+ cliArgs.push.apply(cliArgs, _toConsumableArray(v1SelectorsArgs));
118
+ }
119
+ if (!cliArgs.length) {
120
+ return;
121
+ }
122
+ configElement.cliArgs = cliArgs.map(function (selector) {
123
+ return "/".concat(selector);
124
+ });
125
+ }
126
+ }, {
127
+ key: "onError",
128
+ value: function onError() {}
129
+ }, {
130
+ key: "onExit",
131
+ value: function onExit() {}
132
+ }, {
133
+ key: "onStdErr",
134
+ value: function onStdErr() {}
135
+ }, {
136
+ key: "onStdOut",
137
+ value: function onStdOut() {}
138
+ }, {
139
+ key: "onBegin",
140
+ value: function onBegin(suite) {
141
+ var writer = this.options.testMode ? new _reporter.MessageWriter() : new _reporter.FileSystemWriter({
142
+ resultsDir: this.options.resultsDir || "./allure-results"
143
+ });
144
+ this.suite = suite;
145
+ this.allureRuntime = new _reporter.ReporterRuntime(_objectSpread(_objectSpread({}, this.options), {}, {
146
+ writer: writer
147
+ }));
148
+ }
149
+ }, {
150
+ key: "onTestBegin",
151
+ value: function onTestBegin(test) {
152
+ var suite = test.parent;
153
+ var titleMetadata = (0, _sdk.extractMetadataFromString)(test.title);
154
+ var project = suite.project();
155
+ var relativeFile = _nodePath["default"].relative(project === null || project === void 0 ? void 0 : project.testDir, test.location.file).split(_nodePath["default"].sep).join("/");
156
+ // root > project > file path > test.describe...
157
+ var _suite$titlePath = suite.titlePath(),
158
+ _suite$titlePath2 = _toArray(_suite$titlePath),
159
+ suiteTitles = _suite$titlePath2.slice(3);
160
+ var nameSuites = suiteTitles.length > 0 ? "".concat(suiteTitles.join(" "), " ") : "";
161
+ var testCaseIdBase = "".concat(relativeFile, "#").concat(nameSuites).concat(test.title);
162
+ var result = {
163
+ name: titleMetadata.cleanTitle,
164
+ labels: titleMetadata.labels,
165
+ links: [],
166
+ parameters: [],
167
+ testCaseId: (0, _reporter.md5)(testCaseIdBase),
168
+ fullName: "".concat(relativeFile, ":").concat(test.location.line, ":").concat(test.location.column)
169
+ };
170
+ result.labels.push({
171
+ name: _allureJsCommons.LabelName.LANGUAGE,
172
+ value: "JavaScript"
173
+ });
174
+ result.labels.push({
175
+ name: _allureJsCommons.LabelName.FRAMEWORK,
176
+ value: "Playwright"
177
+ });
178
+ result.labels.push({
179
+ name: "titlePath",
180
+ value: suite.titlePath().join(" > ")
181
+ });
182
+ if (project !== null && project !== void 0 && project.name) {
183
+ result.parameters.push({
184
+ name: "Project",
185
+ value: project.name
186
+ });
187
+ }
188
+ if ((project === null || project === void 0 ? void 0 : project.repeatEach) > 1) {
189
+ result.parameters.push({
190
+ name: "Repetition",
191
+ value: "".concat(test.repeatEachIndex + 1)
192
+ });
193
+ }
194
+ var testUuid = this.allureRuntime.startTest(result);
195
+ this.allureResultsUuids.set(test.id, testUuid);
196
+ this.startedTestCasesTitlesCache.push(titleMetadata.cleanTitle);
197
+ }
198
+ }, {
199
+ key: "onStepBegin",
200
+ value: function onStepBegin(test, _result, step) {
201
+ if (!this.options.detail && step.category !== "test.step") {
202
+ return;
203
+ }
204
+
205
+ // ignore attach steps since attachments are already in the report
206
+ if (step.category === "attach") {
207
+ return;
208
+ }
209
+ var testUuid = this.allureResultsUuids.get(test.id);
210
+ this.allureRuntime.startStep({
211
+ name: step.title.substring(0, stepAttachPrefixLength),
212
+ start: step.startTime.getTime()
213
+ }, testUuid);
214
+ }
215
+ }, {
216
+ key: "onStepEnd",
217
+ value: function onStepEnd(test, _result, step) {
218
+ if (!this.options.detail && step.category !== "test.step") {
219
+ return;
220
+ }
221
+
222
+ // ignore attach steps since attachments are already in the report
223
+ if (step.category === "attach") {
224
+ return;
225
+ }
226
+ var testUuid = this.allureResultsUuids.get(test.id);
227
+ this.allureRuntime.updateStep(function (stepResult) {
228
+ stepResult.status = step.error ? _allureJsCommons.Status.FAILED : _allureJsCommons.Status.PASSED;
229
+ stepResult.stage = _allureJsCommons.Stage.FINISHED;
230
+ if (step.error) {
231
+ stepResult.statusDetails = _objectSpread({}, (0, _sdk.getMessageAndTraceFromError)(step.error));
232
+ }
233
+ }, testUuid);
234
+ this.allureRuntime.stopStep({
235
+ uuid: testUuid
236
+ });
237
+ }
238
+ }, {
239
+ key: "onTestEnd",
240
+ value: function () {
241
+ var _onTestEnd = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(test, result) {
242
+ var _this = this;
243
+ var testUuid, threadId, thread, error, _test$parent$titlePat, _test$parent$titlePat2, projectSuiteTitle, fileSuiteTitle, suiteTitles, _iterator, _step, attachment;
244
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
245
+ while (1) switch (_context.prev = _context.next) {
246
+ case 0:
247
+ testUuid = this.allureResultsUuids.get(test.id); // We need to check parallelIndex first because pw introduced this field only in v1.30.0
248
+ threadId = result.parallelIndex !== undefined ? result.parallelIndex : result.workerIndex;
249
+ thread = _nodeProcess["default"].env.ALLURE_THREAD_NAME || "".concat(this.hostname, "-").concat(_nodeProcess["default"].pid, "-playwright-worker-").concat(threadId);
250
+ error = result.error; // only apply default suites if not set by user
251
+ _test$parent$titlePat = test.parent.titlePath(), _test$parent$titlePat2 = _toArray(_test$parent$titlePat), projectSuiteTitle = _test$parent$titlePat2[1], fileSuiteTitle = _test$parent$titlePat2[2], suiteTitles = _test$parent$titlePat2.slice(3);
252
+ this.allureRuntime.updateTest(function (testResult) {
253
+ testResult.labels.push({
254
+ name: _allureJsCommons.LabelName.HOST,
255
+ value: _this.hostname
256
+ });
257
+ testResult.labels.push({
258
+ name: _allureJsCommons.LabelName.THREAD,
259
+ value: thread
260
+ });
261
+ if (projectSuiteTitle && !(0, _sdk.hasLabel)(testResult, _allureJsCommons.LabelName.PARENT_SUITE)) {
262
+ testResult.labels.push({
263
+ name: _allureJsCommons.LabelName.PARENT_SUITE,
264
+ value: projectSuiteTitle
265
+ });
266
+ }
267
+ if (_this.options.suiteTitle && fileSuiteTitle && !(0, _sdk.hasLabel)(testResult, _allureJsCommons.LabelName.SUITE)) {
268
+ testResult.labels.push({
269
+ name: _allureJsCommons.LabelName.SUITE,
270
+ value: fileSuiteTitle
271
+ });
272
+ }
273
+ if (suiteTitles.length > 0 && !(0, _sdk.hasLabel)(testResult, _allureJsCommons.LabelName.SUB_SUITE)) {
274
+ testResult.labels.push({
275
+ name: _allureJsCommons.LabelName.SUB_SUITE,
276
+ value: suiteTitles.join(" > ")
277
+ });
278
+ }
279
+ if (error) {
280
+ testResult.statusDetails = _objectSpread({}, (0, _sdk.getMessageAndTraceFromError)(error));
281
+ }
282
+ testResult.status = (0, _utils.statusToAllureStats)(result.status, test.expectedStatus);
283
+ testResult.stage = _allureJsCommons.Stage.FINISHED;
284
+ }, testUuid);
285
+ _iterator = _createForOfIteratorHelper(result.attachments);
286
+ _context.prev = 7;
287
+ _iterator.s();
288
+ case 9:
289
+ if ((_step = _iterator.n()).done) {
290
+ _context.next = 15;
291
+ break;
292
+ }
293
+ attachment = _step.value;
294
+ _context.next = 13;
295
+ return this.processAttachment(test.id, attachment);
296
+ case 13:
297
+ _context.next = 9;
298
+ break;
299
+ case 15:
300
+ _context.next = 20;
301
+ break;
302
+ case 17:
303
+ _context.prev = 17;
304
+ _context.t0 = _context["catch"](7);
305
+ _iterator.e(_context.t0);
306
+ case 20:
307
+ _context.prev = 20;
308
+ _iterator.f();
309
+ return _context.finish(20);
310
+ case 23:
311
+ if (result.stdout.length > 0) {
312
+ this.allureRuntime.writeAttachment({
313
+ name: "stdout",
314
+ contentType: _allureJsCommons.ContentType.TEXT,
315
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
316
+ content: Buffer.from((0, _sdk.stripAnsi)(result.stdout.join("")), "utf8")
317
+ }, testUuid);
318
+ }
319
+ if (result.stderr.length > 0) {
320
+ this.allureRuntime.writeAttachment({
321
+ name: "stderr",
322
+ contentType: _allureJsCommons.ContentType.TEXT,
323
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
324
+ content: Buffer.from((0, _sdk.stripAnsi)(result.stderr.join("")), "utf8")
325
+ }, testUuid);
326
+ }
327
+
328
+ // FIXME: temp logic for labels override, we need it here to keep the reporter compatible with v2 API
329
+ // in next iterations we need to implement the logic for every javascript integration
330
+ this.allureRuntime.updateTest(function (testResult) {
331
+ var mappedLabels = testResult.labels.reduce(function (acc, label) {
332
+ if (!acc[label.name]) {
333
+ acc[label.name] = [];
334
+ }
335
+ acc[label.name].push(label);
336
+ return acc;
337
+ }, {});
338
+ var newLabels = Object.keys(mappedLabels).flatMap(function (labelName) {
339
+ var labelsGroup = mappedLabels[labelName];
340
+ if (labelName === _allureJsCommons.LabelName.SUITE || labelName === _allureJsCommons.LabelName.PARENT_SUITE || labelName === _allureJsCommons.LabelName.SUB_SUITE) {
341
+ return labelsGroup.slice(-1);
342
+ }
343
+ return labelsGroup;
344
+ });
345
+ testResult.labels = newLabels;
346
+ }, testUuid);
347
+ this.allureRuntime.stopTest({
348
+ uuid: testUuid
349
+ });
350
+ this.allureRuntime.writeTest(testUuid);
351
+ case 28:
352
+ case "end":
353
+ return _context.stop();
354
+ }
355
+ }, _callee, this, [[7, 17, 20, 23]]);
356
+ }));
357
+ function onTestEnd(_x, _x2) {
358
+ return _onTestEnd.apply(this, arguments);
359
+ }
360
+ return onTestEnd;
361
+ }()
362
+ }, {
363
+ key: "addSkippedResults",
364
+ value: function () {
365
+ var _addSkippedResults = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
366
+ var _this2 = this;
367
+ var unprocessedCases, _iterator2, _step2, testCase;
368
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
369
+ while (1) switch (_context2.prev = _context2.next) {
370
+ case 0:
371
+ unprocessedCases = this.suite.allTests().filter(function (_ref) {
372
+ var title = _ref.title;
373
+ var titleMetadata = (0, _sdk.extractMetadataFromString)(title);
374
+ return !_this2.startedTestCasesTitlesCache.includes(titleMetadata.cleanTitle);
375
+ });
376
+ _iterator2 = _createForOfIteratorHelper(unprocessedCases);
377
+ _context2.prev = 2;
378
+ _iterator2.s();
379
+ case 4:
380
+ if ((_step2 = _iterator2.n()).done) {
381
+ _context2.next = 11;
382
+ break;
383
+ }
384
+ testCase = _step2.value;
385
+ this.onTestBegin(testCase);
386
+ _context2.next = 9;
387
+ return this.onTestEnd(testCase, {
388
+ status: _allureJsCommons.Status.SKIPPED,
389
+ attachments: [],
390
+ duration: 0,
391
+ errors: [],
392
+ parallelIndex: 0,
393
+ workerIndex: 0,
394
+ retry: 0,
395
+ steps: [],
396
+ stderr: [],
397
+ stdout: [],
398
+ startTime: this.globalStartTime
399
+ });
400
+ case 9:
401
+ _context2.next = 4;
402
+ break;
403
+ case 11:
404
+ _context2.next = 16;
405
+ break;
406
+ case 13:
407
+ _context2.prev = 13;
408
+ _context2.t0 = _context2["catch"](2);
409
+ _iterator2.e(_context2.t0);
410
+ case 16:
411
+ _context2.prev = 16;
412
+ _iterator2.f();
413
+ return _context2.finish(16);
414
+ case 19:
415
+ case "end":
416
+ return _context2.stop();
417
+ }
418
+ }, _callee2, this, [[2, 13, 16, 19]]);
419
+ }));
420
+ function addSkippedResults() {
421
+ return _addSkippedResults.apply(this, arguments);
422
+ }
423
+ return addSkippedResults;
424
+ }()
425
+ }, {
426
+ key: "onEnd",
427
+ value: function () {
428
+ var _onEnd = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
429
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
430
+ while (1) switch (_context3.prev = _context3.next) {
431
+ case 0:
432
+ _context3.next = 2;
433
+ return this.addSkippedResults();
434
+ case 2:
435
+ this.allureRuntime.writeEnvironmentInfo();
436
+ this.allureRuntime.writeCategoriesDefinitions();
437
+ case 4:
438
+ case "end":
439
+ return _context3.stop();
440
+ }
441
+ }, _callee3, this);
442
+ }));
443
+ function onEnd() {
444
+ return _onEnd.apply(this, arguments);
445
+ }
446
+ return onEnd;
447
+ }()
448
+ }, {
449
+ key: "printsToStdio",
450
+ value: function printsToStdio() {
451
+ return false;
452
+ }
453
+ }, {
454
+ key: "processAttachment",
455
+ value: function () {
456
+ var _processAttachment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(testId, attachment) {
457
+ var testUuid, allureRuntimeMessage, message, pathWithoutEnd, actualBase64, expectedBase64, diffBase64, diffName;
458
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
459
+ while (1) switch (_context4.prev = _context4.next) {
460
+ case 0:
461
+ testUuid = this.allureResultsUuids.get(testId);
462
+ if (!(!attachment.body && !attachment.path)) {
463
+ _context4.next = 3;
464
+ break;
465
+ }
466
+ return _context4.abrupt("return");
467
+ case 3:
468
+ allureRuntimeMessage = attachment.contentType === _reporter.ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE;
469
+ if (!(allureRuntimeMessage && !attachment.body)) {
470
+ _context4.next = 6;
471
+ break;
472
+ }
473
+ return _context4.abrupt("return");
474
+ case 6:
475
+ if (!allureRuntimeMessage) {
476
+ _context4.next = 10;
477
+ break;
478
+ }
479
+ message = JSON.parse(attachment.body.toString()); // TODO: make possible to pass single message and list of them
480
+ this.allureRuntime.applyRuntimeMessages([message], {
481
+ testUuid: testUuid
482
+ });
483
+ return _context4.abrupt("return");
484
+ case 10:
485
+ if (!attachment.body) {
486
+ _context4.next = 14;
487
+ break;
488
+ }
489
+ this.allureRuntime.writeAttachment({
490
+ name: attachment.name,
491
+ contentType: attachment.contentType,
492
+ content: attachment.body
493
+ }, testUuid);
494
+ _context4.next = 19;
495
+ break;
496
+ case 14:
497
+ if ((0, _nodeFs.existsSync)(attachment.path)) {
498
+ _context4.next = 18;
499
+ break;
500
+ }
501
+ return _context4.abrupt("return");
502
+ case 18:
503
+ this.allureRuntime.writeAttachmentFromPath(attachment.name, attachment.path, {
504
+ contentType: attachment.contentType
505
+ }, testUuid);
506
+ case 19:
507
+ if (attachment.name.match(diffEndRegexp)) {
508
+ _context4.next = 21;
509
+ break;
510
+ }
511
+ return _context4.abrupt("return");
512
+ case 21:
513
+ pathWithoutEnd = attachment.path.replace(diffEndRegexp, "");
514
+ if (!this.processedDiffs.includes(pathWithoutEnd)) {
515
+ _context4.next = 24;
516
+ break;
517
+ }
518
+ return _context4.abrupt("return");
519
+ case 24:
520
+ _context4.next = 26;
521
+ return (0, _reporter.readImageAsBase64)("".concat(pathWithoutEnd, "-actual.png"));
522
+ case 26:
523
+ actualBase64 = _context4.sent;
524
+ _context4.next = 29;
525
+ return (0, _reporter.readImageAsBase64)("".concat(pathWithoutEnd, "-expected.png"));
526
+ case 29:
527
+ expectedBase64 = _context4.sent;
528
+ _context4.next = 32;
529
+ return (0, _reporter.readImageAsBase64)("".concat(pathWithoutEnd, "-diff.png"));
530
+ case 32:
531
+ diffBase64 = _context4.sent;
532
+ diffName = attachment.name.replace(diffEndRegexp, "");
533
+ this.allureRuntime.writeAttachment({
534
+ name: diffName,
535
+ content: JSON.stringify({
536
+ expected: expectedBase64,
537
+ actual: actualBase64,
538
+ diff: diffBase64,
539
+ name: diffName
540
+ }),
541
+ contentType: _allureJsCommons.ContentType.IMAGEDIFF,
542
+ fileExtension: ".imagediff"
543
+ }, testUuid);
544
+ this.processedDiffs.push(pathWithoutEnd);
545
+ case 36:
546
+ case "end":
547
+ return _context4.stop();
548
+ }
549
+ }, _callee4, this);
550
+ }));
551
+ function processAttachment(_x3, _x4) {
552
+ return _processAttachment.apply(this, arguments);
553
+ }
554
+ return processAttachment;
555
+ }()
556
+ }, {
557
+ key: "version",
558
+ value: function version() {
559
+ return "v2";
560
+ }
561
+ }]);
562
+ }();
563
+ /**
564
+ * @deprecated for removal, import functions directly from "allure-js-commons".
565
+ */
566
+ var allure = exports.allure = _legacy.allurePlaywrightLegacyApi;
567
+
568
+ /**
569
+ * @deprecated for removal, import functions directly from "@playwright/test".
570
+ */
571
+ var _default = exports["default"] = AllureReporter;
572
+ //# sourceMappingURL=index.js.map