allure-cypress 3.0.0-beta.2 → 3.0.0-beta.4

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.
@@ -7,6 +7,7 @@ exports.allureCypress = exports.AllureCypress = void 0;
7
7
  var _allureJsCommons = require("allure-js-commons");
8
8
  var _sdk = require("allure-js-commons/sdk");
9
9
  var _reporter = require("allure-js-commons/sdk/reporter");
10
+ var _utils = require("./utils.js");
10
11
  var _excluded = ["resultsDir"];
11
12
  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; }
12
13
  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; }
@@ -17,101 +18,214 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
17
18
  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); }
18
19
  class AllureCypress {
19
20
  constructor(config) {
20
- _defineProperty(this, "runtime", void 0);
21
- _defineProperty(this, "testsUuidsByCypressAbsolutePath", new Map());
21
+ _defineProperty(this, "allureRuntime", void 0);
22
+ _defineProperty(this, "messagesByAbsolutePath", new Map());
23
+ _defineProperty(this, "runContextByAbsolutePath", new Map());
24
+ _defineProperty(this, "globalHooksMessages", []);
22
25
  var _ref = config || {},
23
26
  {
24
27
  resultsDir = "./allure-results"
25
28
  } = _ref,
26
29
  rest = _objectWithoutProperties(_ref, _excluded);
27
- this.runtime = new _reporter.ReporterRuntime(_objectSpread({
30
+ this.allureRuntime = new _reporter.ReporterRuntime(_objectSpread({
28
31
  writer: new _reporter.FileSystemWriter({
29
32
  resultsDir
30
33
  })
31
34
  }, rest));
32
35
  }
33
- pushTestUuid(absolutePath, uuid) {
34
- var currentUuids = this.testsUuidsByCypressAbsolutePath.get(absolutePath) || [];
35
- this.testsUuidsByCypressAbsolutePath.set(absolutePath, [...currentUuids, uuid]);
36
+ createEmptyRunContext(absolutePath) {
37
+ this.runContextByAbsolutePath.set(absolutePath, {
38
+ executables: [],
39
+ steps: [],
40
+ scopes: [],
41
+ globalHooksMessages: []
42
+ });
36
43
  }
37
44
  attachToCypress(on) {
38
45
  on("task", {
39
- allureReportTest: messages => {
40
- var startMessage = messages[0];
41
- var endMessage = messages[messages.length - 1];
42
- if (startMessage.type !== "cypress_start" || endMessage.type !== "cypress_end") {
43
- throw new Error("INTERNAL ERROR: Invalid message sequence");
44
- }
45
- var suiteLabels = (0, _reporter.getSuiteLabels)(startMessage.data.specPath.slice(0, -1));
46
- var testTitle = startMessage.data.specPath[startMessage.data.specPath.length - 1];
46
+ allureReportTest: _ref2 => {
47
+ var {
48
+ messages,
49
+ absolutePath
50
+ } = _ref2;
51
+ this.messagesByAbsolutePath.set(absolutePath, messages);
52
+ return null;
53
+ },
54
+ allureReportSpec: spec => {
55
+ this.createEmptyRunContext(spec.absolute);
56
+ this.endSpec(spec);
57
+ return null;
58
+ }
59
+ });
60
+ }
61
+ endRun(result) {
62
+ result.runs.forEach(run => {
63
+ this.createEmptyRunContext(run.spec.absolute);
64
+ this.endSpec(run.spec, run.video || undefined);
65
+ });
66
+ }
67
+ endSpec(spec, cypressVideoPath) {
68
+ var specMessages = this.messagesByAbsolutePath.get(spec.absolute);
69
+ var runContext = this.runContextByAbsolutePath.get(spec.absolute);
70
+ specMessages.forEach((message, i) => {
71
+ var _data;
72
+ // we add cypressTestId to messages where it's possible because the field is very useful to glue data
73
+ // @ts-ignore
74
+ // const {cypressTestId} = message.data
75
+ var previousMessagesSlice = specMessages.slice(0, i);
76
+ var lastHookMessage = (0, _utils.toReversed)(previousMessagesSlice).find(_ref3 => {
77
+ var {
78
+ type
79
+ } = _ref3;
80
+ return type === "cypress_hook_start" || type === "cypress_hook_end";
81
+ });
82
+ if (message.type === "cypress_suite_start") {
83
+ var scopeUuid = this.allureRuntime.startScope();
84
+ runContext.scopes.push(scopeUuid);
85
+ return;
86
+ }
87
+ if (message.type === "cypress_suite_end") {
88
+ var _scopeUuid = runContext.scopes.pop();
89
+ this.allureRuntime.writeScope(_scopeUuid);
90
+ return;
91
+ }
92
+ if (message.type === "cypress_hook_start" && message.data.global) {
93
+ runContext.globalHooksMessages.push(message);
94
+ return;
95
+ }
96
+ if (message.type === "cypress_hook_start") {
97
+ var fixtureUuid = this.allureRuntime.startFixture((0, _utils.last)(runContext.scopes), message.data.type, {
98
+ name: message.data.name,
99
+ start: message.data.start
100
+ });
101
+ runContext.executables.push(fixtureUuid);
102
+ return;
103
+ }
104
+ if (message.type === "cypress_hook_end" && lastHookMessage !== null && lastHookMessage !== void 0 && (_data = lastHookMessage.data) !== null && _data !== void 0 && _data.global && (lastHookMessage === null || lastHookMessage === void 0 ? void 0 : lastHookMessage.type) === "cypress_hook_start") {
105
+ runContext.globalHooksMessages.push(message);
106
+ return;
107
+ }
108
+ if (message.type === "cypress_hook_end") {
109
+ var _fixtureUuid = runContext.executables.pop();
110
+ this.allureRuntime.updateFixture(_fixtureUuid, r => {
111
+ r.stage = _allureJsCommons.Stage.FINISHED;
112
+ r.status = message.data.status;
113
+ r.stop = message.data.stop;
114
+ if (message.data.statusDetails) {
115
+ r.statusDetails = message.data.statusDetails;
116
+ }
117
+ });
118
+ this.allureRuntime.stopFixture(_fixtureUuid);
119
+ return;
120
+ }
121
+ if (message.type === "cypress_test_start") {
122
+ var suiteLabels = (0, _reporter.getSuiteLabels)(message.data.specPath.slice(0, -1));
123
+ var testTitle = message.data.specPath[message.data.specPath.length - 1];
47
124
  var titleMetadata = (0, _sdk.extractMetadataFromString)(testTitle);
48
- var testUuid = this.runtime.startTest({
125
+ var testUuid = this.allureRuntime.startTest({
49
126
  name: titleMetadata.cleanTitle || testTitle,
50
- start: startMessage.data.start,
51
- fullName: "".concat(startMessage.data.filename, "#").concat(startMessage.data.specPath.join(" ")),
52
- stage: _allureJsCommons.Stage.RUNNING
53
- });
54
- this.runtime.updateTest(result => {
55
- result.labels.push({
127
+ start: message.data.start,
128
+ fullName: "".concat(message.data.filename, "#").concat(message.data.specPath.join(" ")),
129
+ stage: _allureJsCommons.Stage.RUNNING,
130
+ labels: [{
56
131
  name: _allureJsCommons.LabelName.LANGUAGE,
57
132
  value: "javascript"
58
- });
59
- result.labels.push({
133
+ }, {
60
134
  name: _allureJsCommons.LabelName.FRAMEWORK,
61
135
  value: "cypress"
62
- });
63
- result.labels.push(...suiteLabels);
64
- result.labels.push(...titleMetadata.labels);
65
- this.runtime.applyRuntimeMessages(messages.slice(1, messages.length - 1), {
66
- testUuid
67
- });
68
- }, testUuid);
69
- this.runtime.updateTest(result => {
70
- result.stage = endMessage.data.stage;
71
- result.status = endMessage.data.status;
72
- if (!endMessage.data.statusDetails) {
136
+ }, ...suiteLabels, ...titleMetadata.labels]
137
+ }, runContext.scopes);
138
+ runContext.executables.push(testUuid);
139
+ return;
140
+ }
141
+ if (message.type === "cypress_test_end") {
142
+ var _testUuid = runContext.executables.pop();
143
+ this.allureRuntime.updateTest(_testUuid, result => {
144
+ result.stage = _allureJsCommons.Stage.FINISHED;
145
+ result.status = message.data.status;
146
+ if (!message.data.statusDetails) {
73
147
  return;
74
148
  }
75
- result.statusDetails = endMessage.data.statusDetails;
76
- }, testUuid);
77
- this.runtime.stopTest({
78
- uuid: testUuid,
79
- stop: Date.now()
149
+ result.statusDetails = message.data.statusDetails;
80
150
  });
81
- if (startMessage.data.isInteractive) {
82
- this.runtime.writeTest(testUuid);
83
- } else {
84
- // False positive by eslint (testUuid is string)
85
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
86
- this.pushTestUuid(startMessage.data.absolutePath, testUuid);
87
- }
88
- return null;
151
+ this.allureRuntime.stopTest(_testUuid);
152
+ this.allureRuntime.writeTest(_testUuid);
153
+ return;
154
+ }
155
+
156
+ // we can get error when we try to attach screenshot to a failed test because there is no test due to error in hook
157
+ if (runContext.executables.length === 0) {
158
+ return;
159
+ }
160
+ if (message.type === "cypress_command_start") {
161
+ var lastExecutableUuid = (0, _utils.last)(runContext.executables);
162
+ var lastStepUuid = (0, _utils.last)(runContext.steps);
163
+ var stepUuid = this.allureRuntime.startStep(lastExecutableUuid, lastStepUuid, {
164
+ name: message.data.name,
165
+ parameters: message.data.args.map((arg, j) => ({
166
+ name: "Argument [".concat(j, "]"),
167
+ value: arg
168
+ }))
169
+ });
170
+ runContext.steps.push(stepUuid);
171
+ return;
89
172
  }
173
+ if (message.type === "cypress_command_end") {
174
+ var _stepUuid = runContext.steps.pop();
175
+ this.allureRuntime.updateStep(_stepUuid, r => {
176
+ r.status = message.data.status;
177
+ if (message.data.statusDetails) {
178
+ r.statusDetails = message.data.statusDetails;
179
+ }
180
+ });
181
+ this.allureRuntime.stopStep(_stepUuid);
182
+ return;
183
+ }
184
+ this.allureRuntime.applyRuntimeMessages((0, _utils.last)(runContext.executables), [message]);
90
185
  });
91
- }
92
- endSpec(spec, cypressResult) {
93
- var testUuids = this.testsUuidsByCypressAbsolutePath.get(spec.absolute);
94
- this.testsUuidsByCypressAbsolutePath.delete(spec.absolute);
95
- if (!testUuids) {
96
- return;
186
+ if (cypressVideoPath) {
187
+ var fixtureUuid = this.allureRuntime.startFixture(runContext.scopes[0], "after", {
188
+ name: "Cypress video",
189
+ status: _allureJsCommons.Status.PASSED,
190
+ stage: _allureJsCommons.Stage.FINISHED
191
+ });
192
+ this.allureRuntime.writeAttachment(fixtureUuid, undefined, "Cypress video", cypressVideoPath, {
193
+ contentType: _allureJsCommons.ContentType.MP4
194
+ });
195
+ this.allureRuntime.stopFixture(fixtureUuid);
97
196
  }
98
- for (var uuid of testUuids) {
99
- // TODO add it to spec scope to remove duplicates.
100
- if (cypressResult.video) {
101
- this.runtime.writeAttachmentFromPath("Video", cypressResult.video, {
102
- contentType: _allureJsCommons.ContentType.MP4
103
- }, uuid);
104
- }
105
- this.runtime.writeTest(uuid);
197
+ if (runContext.globalHooksMessages.length > 0) {
198
+ runContext.globalHooksMessages.forEach(message => {
199
+ if (message.type === "cypress_hook_start") {
200
+ var _fixtureUuid2 = this.allureRuntime.startFixture(runContext.scopes[0], message.data.type, {
201
+ name: message.data.name,
202
+ start: message.data.start
203
+ });
204
+ runContext.executables.push(_fixtureUuid2);
205
+ return;
206
+ }
207
+ if (message.type === "cypress_hook_end") {
208
+ var _fixtureUuid3 = runContext.executables.pop();
209
+ this.allureRuntime.updateFixture(_fixtureUuid3, r => {
210
+ r.status = message.data.status;
211
+ r.stop = message.data.stop;
212
+ if (message.data.statusDetails) {
213
+ r.statusDetails = message.data.statusDetails;
214
+ }
215
+ });
216
+ this.allureRuntime.stopFixture(_fixtureUuid3);
217
+ }
218
+ });
106
219
  }
220
+ this.allureRuntime.writeScope(runContext.scopes.pop());
107
221
  }
108
222
  }
109
223
  exports.AllureCypress = AllureCypress;
110
224
  var allureCypress = (on, allureConfig) => {
111
225
  var allureCypressReporter = new AllureCypress(allureConfig);
112
226
  allureCypressReporter.attachToCypress(on);
113
- on("after:spec", (spec, result) => {
114
- allureCypressReporter.endSpec(spec, result);
227
+ on("after:run", results => {
228
+ allureCypressReporter.endRun(results);
115
229
  });
116
230
  return allureCypressReporter;
117
231
  };
@@ -1 +1 @@
1
- {"version":3,"file":"reporter.js","names":["_allureJsCommons","require","_sdk","_reporter","_excluded","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_objectWithoutProperties","i","_objectWithoutPropertiesLoose","n","indexOf","propertyIsEnumerable","call","hasOwnProperty","_toPropertyKey","value","configurable","writable","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","AllureCypress","constructor","config","Map","_ref","resultsDir","rest","runtime","ReporterRuntime","writer","FileSystemWriter","pushTestUuid","absolutePath","uuid","currentUuids","testsUuidsByCypressAbsolutePath","get","set","attachToCypress","on","allureReportTest","messages","startMessage","endMessage","type","Error","suiteLabels","getSuiteLabels","data","specPath","slice","testTitle","titleMetadata","extractMetadataFromString","testUuid","startTest","name","cleanTitle","start","fullName","concat","filename","join","stage","Stage","RUNNING","updateTest","result","labels","LabelName","LANGUAGE","FRAMEWORK","applyRuntimeMessages","status","statusDetails","stopTest","stop","Date","now","isInteractive","writeTest","endSpec","spec","cypressResult","testUuids","absolute","delete","video","writeAttachmentFromPath","contentType","ContentType","MP4","exports","allureCypress","allureConfig","allureCypressReporter"],"sources":["../../src/reporter.ts"],"sourcesContent":["import type Cypress from \"cypress\";\nimport { ContentType, LabelName, Stage } from \"allure-js-commons\";\nimport { extractMetadataFromString } from \"allure-js-commons/sdk\";\nimport { FileSystemWriter, ReporterRuntime, getSuiteLabels } from \"allure-js-commons/sdk/reporter\";\nimport type { CypressRuntimeMessage, CypressTestEndRuntimeMessage, CypressTestStartRuntimeMessage } from \"./model.js\";\n\nexport type AllureCypressConfig = {\n resultsDir?: string;\n links?: {\n type: string;\n urlTemplate: string;\n }[];\n};\n\nexport class AllureCypress {\n runtime: ReporterRuntime;\n\n testsUuidsByCypressAbsolutePath = new Map<string, string[]>();\n\n constructor(config?: AllureCypressConfig) {\n const { resultsDir = \"./allure-results\", ...rest } = config || {};\n\n this.runtime = new ReporterRuntime({\n writer: new FileSystemWriter({\n resultsDir,\n }),\n ...rest,\n });\n }\n\n private pushTestUuid(absolutePath: string, uuid: string) {\n const currentUuids = this.testsUuidsByCypressAbsolutePath.get(absolutePath) || [];\n\n this.testsUuidsByCypressAbsolutePath.set(absolutePath, [...currentUuids, uuid]);\n }\n\n attachToCypress(on: Cypress.PluginEvents) {\n on(\"task\", {\n allureReportTest: (messages: CypressRuntimeMessage[]) => {\n const startMessage = messages[0] as CypressTestStartRuntimeMessage;\n const endMessage = messages[messages.length - 1] as CypressTestEndRuntimeMessage;\n\n if (startMessage.type !== \"cypress_start\" || endMessage.type !== \"cypress_end\") {\n throw new Error(\"INTERNAL ERROR: Invalid message sequence\");\n }\n\n const suiteLabels = getSuiteLabels(startMessage.data.specPath.slice(0, -1));\n const testTitle = startMessage.data.specPath[startMessage.data.specPath.length - 1];\n const titleMetadata = extractMetadataFromString(testTitle);\n const testUuid = this.runtime.startTest({\n name: titleMetadata.cleanTitle || testTitle,\n start: startMessage.data.start,\n fullName: `${startMessage.data.filename}#${startMessage.data.specPath.join(\" \")}`,\n stage: Stage.RUNNING,\n });\n\n this.runtime.updateTest((result) => {\n result.labels.push({\n name: LabelName.LANGUAGE,\n value: \"javascript\",\n });\n result.labels.push({\n name: LabelName.FRAMEWORK,\n value: \"cypress\",\n });\n result.labels.push(...suiteLabels);\n result.labels.push(...titleMetadata.labels);\n\n this.runtime.applyRuntimeMessages(messages.slice(1, messages.length - 1), {\n testUuid,\n });\n }, testUuid);\n this.runtime.updateTest((result) => {\n result.stage = endMessage.data.stage;\n result.status = endMessage.data.status;\n\n if (!endMessage.data.statusDetails) {\n return;\n }\n\n result.statusDetails = endMessage.data.statusDetails;\n }, testUuid);\n\n this.runtime.stopTest({ uuid: testUuid, stop: Date.now() });\n\n if (startMessage.data.isInteractive) {\n this.runtime.writeTest(testUuid);\n } else {\n // False positive by eslint (testUuid is string)\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n this.pushTestUuid(startMessage.data.absolutePath, testUuid);\n }\n\n return null;\n },\n });\n }\n\n endSpec(spec: Cypress.Spec, cypressResult: CypressCommandLine.RunResult) {\n const testUuids = this.testsUuidsByCypressAbsolutePath.get(spec.absolute);\n this.testsUuidsByCypressAbsolutePath.delete(spec.absolute);\n\n if (!testUuids) {\n return;\n }\n\n for (const uuid of testUuids) {\n // TODO add it to spec scope to remove duplicates.\n if (cypressResult.video) {\n this.runtime.writeAttachmentFromPath(\n \"Video\",\n cypressResult.video,\n {\n contentType: ContentType.MP4,\n },\n uuid,\n );\n }\n\n this.runtime.writeTest(uuid);\n }\n }\n}\n\nexport const allureCypress = (on: Cypress.PluginEvents, allureConfig?: AllureCypressConfig) => {\n const allureCypressReporter = new AllureCypress(allureConfig);\n\n allureCypressReporter.attachToCypress(on);\n\n on(\"after:spec\", (spec, result) => {\n allureCypressReporter.endSpec(spec, result);\n });\n\n return allureCypressReporter;\n};\n"],"mappings":";;;;;;AACA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAAmG,IAAAG,SAAA;AAAA,SAAAC,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,OAAAa,OAAA,WAAAd,CAAA,IAAAe,eAAA,CAAAhB,CAA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ACM,IAAI,CAAChB,YAAY,EAAEsB,QAAQ,CAAC;QAC7D;QAEA,OAAO,IAAI;MACb;IACF,CAAC,CAAC;EACJ;EAEA2B,OAAOA,CAACC,IAAkB,EAAEC,aAA2C,EAAE;IACvE,IAAMC,SAAS,GAAG,IAAI,CAACjD,+BAA+B,CAACC,GAAG,CAAC8C,IAAI,CAACG,QAAQ,CAAC;IACzE,IAAI,CAAClD,+BAA+B,CAACmD,MAAM,CAACJ,IAAI,CAACG,QAAQ,CAAC;IAE1D,IAAI,CAACD,SAAS,EAAE;MACd;IACF;IAEA,KAAK,IAAMnD,IAAI,IAAImD,SAAS,EAAE;MAC5B;MACA,IAAID,aAAa,CAACI,KAAK,EAAE;QACvB,IAAI,CAAC5D,OAAO,CAAC6D,uBAAuB,CAClC,OAAO,EACPL,aAAa,CAACI,KAAK,EACnB;UACEE,WAAW,EAAEC,4BAAW,CAACC;QAC3B,CAAC,EACD1D,IACF,CAAC;MACH;MAEA,IAAI,CAACN,OAAO,CAACqD,SAAS,CAAC/C,IAAI,CAAC;IAC9B;EACF;AACF;AAAC2D,OAAA,CAAAxE,aAAA,GAAAA,aAAA;AAEM,IAAMyE,aAAa,GAAGA,CAACtD,EAAwB,EAAEuD,YAAkC,KAAK;EAC7F,IAAMC,qBAAqB,GAAG,IAAI3E,aAAa,CAAC0E,YAAY,CAAC;EAE7DC,qBAAqB,CAACzD,eAAe,CAACC,EAAE,CAAC;EAEzCA,EAAE,CAAC,YAAY,EAAE,CAAC2C,IAAI,EAAEf,MAAM,KAAK;IACjC4B,qBAAqB,CAACd,OAAO,CAACC,IAAI,EAAEf,MAAM,CAAC;EAC7C,CAAC,CAAC;EAEF,OAAO4B,qBAAqB;AAC9B,CAAC;AAACH,OAAA,CAAAC,aAAA,GAAAA,aAAA","ignoreList":[]}
1
+ {"version":3,"file":"reporter.js","names":["_allureJsCommons","require","_sdk","_reporter","_utils","_excluded","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_objectWithoutProperties","i","_objectWithoutPropertiesLoose","n","indexOf","propertyIsEnumerable","call","hasOwnProperty","_toPropertyKey","value","configurable","writable","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","AllureCypress","constructor","config","Map","_ref","resultsDir","rest","allureRuntime","ReporterRuntime","writer","FileSystemWriter","createEmptyRunContext","absolutePath","runContextByAbsolutePath","set","executables","steps","scopes","globalHooksMessages","attachToCypress","on","allureReportTest","_ref2","messages","messagesByAbsolutePath","allureReportSpec","spec","absolute","endSpec","endRun","result","runs","run","video","undefined","cypressVideoPath","specMessages","get","runContext","message","_data","previousMessagesSlice","slice","lastHookMessage","toReversed","find","_ref3","type","scopeUuid","startScope","pop","writeScope","data","global","fixtureUuid","startFixture","last","name","start","updateFixture","stage","Stage","FINISHED","status","stop","statusDetails","stopFixture","suiteLabels","getSuiteLabels","specPath","testTitle","titleMetadata","extractMetadataFromString","testUuid","startTest","cleanTitle","fullName","concat","filename","join","RUNNING","labels","LabelName","LANGUAGE","FRAMEWORK","updateTest","stopTest","writeTest","lastExecutableUuid","lastStepUuid","stepUuid","startStep","parameters","args","map","arg","j","updateStep","stopStep","applyRuntimeMessages","Status","PASSED","writeAttachment","contentType","ContentType","MP4","exports","allureCypress","allureConfig","allureCypressReporter","results"],"sources":["../../src/reporter.ts"],"sourcesContent":["import type Cypress from \"cypress\";\nimport { ContentType, LabelName, Stage, Status } from \"allure-js-commons\";\nimport type { RuntimeMessage } from \"allure-js-commons/sdk\";\nimport { extractMetadataFromString } from \"allure-js-commons/sdk\";\nimport { FileSystemWriter, ReporterRuntime, getSuiteLabels } from \"allure-js-commons/sdk/reporter\";\nimport type { Config } from \"allure-js-commons/sdk/reporter\";\nimport type {\n CypressHookEndMessage,\n CypressHookStartMessage,\n CypressMessage,\n RunContextByAbsolutePath,\n} from \"./model.js\";\nimport { last, toReversed } from \"./utils.js\";\n\nexport class AllureCypress {\n allureRuntime: ReporterRuntime;\n\n messagesByAbsolutePath = new Map<string, CypressMessage[]>();\n runContextByAbsolutePath = new Map<string, RunContextByAbsolutePath>();\n\n globalHooksMessages: CypressMessage[] = [];\n\n constructor(config?: Config) {\n const { resultsDir = \"./allure-results\", ...rest } = config || {};\n\n this.allureRuntime = new ReporterRuntime({\n writer: new FileSystemWriter({\n resultsDir,\n }),\n ...rest,\n });\n }\n\n createEmptyRunContext(absolutePath: string) {\n this.runContextByAbsolutePath.set(absolutePath, {\n executables: [],\n steps: [],\n scopes: [],\n globalHooksMessages: [],\n });\n }\n\n attachToCypress(on: Cypress.PluginEvents) {\n on(\"task\", {\n allureReportTest: ({ messages, absolutePath }: { messages: CypressMessage[]; absolutePath: string }) => {\n this.messagesByAbsolutePath.set(absolutePath, messages);\n\n return null;\n },\n allureReportSpec: (spec: { absolute: string }) => {\n this.createEmptyRunContext(spec.absolute);\n this.endSpec(spec as Cypress.Spec);\n\n return null;\n },\n });\n }\n\n endRun(result: CypressCommandLine.CypressRunResult) {\n result.runs.forEach((run) => {\n this.createEmptyRunContext(run.spec.absolute);\n this.endSpec(run.spec, run.video || undefined);\n });\n }\n\n endSpec(spec: Cypress.Spec, cypressVideoPath?: string) {\n const specMessages = this.messagesByAbsolutePath.get(spec.absolute)!;\n const runContext = this.runContextByAbsolutePath.get(spec.absolute)!;\n\n specMessages.forEach((message, i) => {\n // we add cypressTestId to messages where it's possible because the field is very useful to glue data\n // @ts-ignore\n // const {cypressTestId} = message.data\n const previousMessagesSlice = specMessages.slice(0, i);\n const lastHookMessage = toReversed(previousMessagesSlice).find(\n ({ type }) => type === \"cypress_hook_start\" || type === \"cypress_hook_end\",\n ) as CypressHookStartMessage | CypressHookEndMessage;\n\n if (message.type === \"cypress_suite_start\") {\n const scopeUuid = this.allureRuntime.startScope();\n\n runContext.scopes.push(scopeUuid);\n return;\n }\n\n if (message.type === \"cypress_suite_end\") {\n const scopeUuid = runContext.scopes.pop()!;\n\n this.allureRuntime.writeScope(scopeUuid);\n return;\n }\n\n if (message.type === \"cypress_hook_start\" && message.data.global) {\n runContext.globalHooksMessages.push(message);\n return;\n }\n\n if (message.type === \"cypress_hook_start\") {\n const fixtureUuid = this.allureRuntime.startFixture(last(runContext.scopes)!, message.data.type, {\n name: message.data.name,\n start: message.data.start,\n })!;\n\n runContext.executables.push(fixtureUuid);\n return;\n }\n\n if (\n message.type === \"cypress_hook_end\" &&\n (lastHookMessage as CypressHookEndMessage)?.data?.global &&\n lastHookMessage?.type === \"cypress_hook_start\"\n ) {\n runContext.globalHooksMessages.push(message);\n return;\n }\n\n if (message.type === \"cypress_hook_end\") {\n const fixtureUuid = runContext.executables.pop()!;\n\n this.allureRuntime.updateFixture(fixtureUuid, (r) => {\n r.stage = Stage.FINISHED;\n r.status = message.data.status;\n r.stop = message.data.stop;\n\n if (message.data.statusDetails) {\n r.statusDetails = message.data.statusDetails;\n }\n });\n this.allureRuntime.stopFixture(fixtureUuid);\n return;\n }\n\n if (message.type === \"cypress_test_start\") {\n const suiteLabels = getSuiteLabels(message.data.specPath.slice(0, -1));\n const testTitle = message.data.specPath[message.data.specPath.length - 1];\n const titleMetadata = extractMetadataFromString(testTitle);\n const testUuid = this.allureRuntime.startTest(\n {\n name: titleMetadata.cleanTitle || testTitle,\n start: message.data.start,\n fullName: `${message.data.filename}#${message.data.specPath.join(\" \")}`,\n stage: Stage.RUNNING,\n labels: [\n {\n name: LabelName.LANGUAGE,\n value: \"javascript\",\n },\n {\n name: LabelName.FRAMEWORK,\n value: \"cypress\",\n },\n ...suiteLabels,\n ...titleMetadata.labels,\n ],\n },\n runContext.scopes,\n );\n\n runContext.executables.push(testUuid);\n return;\n }\n\n if (message.type === \"cypress_test_end\") {\n const testUuid = runContext.executables.pop()!;\n\n this.allureRuntime.updateTest(testUuid, (result) => {\n result.stage = Stage.FINISHED;\n result.status = message.data.status;\n\n if (!message.data.statusDetails) {\n return;\n }\n\n result.statusDetails = message.data.statusDetails;\n });\n\n this.allureRuntime.stopTest(testUuid);\n this.allureRuntime.writeTest(testUuid);\n return;\n }\n\n // we can get error when we try to attach screenshot to a failed test because there is no test due to error in hook\n if (runContext.executables.length === 0) {\n return;\n }\n\n if (message.type === \"cypress_command_start\") {\n const lastExecutableUuid = last(runContext.executables)!;\n const lastStepUuid = last(runContext.steps);\n const stepUuid = this.allureRuntime.startStep(lastExecutableUuid, lastStepUuid, {\n name: message.data.name,\n parameters: message.data.args.map((arg, j) => ({\n name: `Argument [${j}]`,\n value: arg,\n })),\n })!;\n\n runContext.steps.push(stepUuid);\n return;\n }\n\n if (message.type === \"cypress_command_end\") {\n const stepUuid = runContext.steps.pop()!;\n\n this.allureRuntime.updateStep(stepUuid, (r) => {\n r.status = message.data.status;\n\n if (message.data.statusDetails) {\n r.statusDetails = message.data.statusDetails;\n }\n });\n this.allureRuntime.stopStep(stepUuid);\n return;\n }\n\n this.allureRuntime.applyRuntimeMessages(last(runContext.executables)!, [message] as RuntimeMessage[]);\n });\n\n if (cypressVideoPath) {\n const fixtureUuid = this.allureRuntime.startFixture(runContext.scopes[0], \"after\", {\n name: \"Cypress video\",\n status: Status.PASSED,\n stage: Stage.FINISHED,\n })!;\n this.allureRuntime.writeAttachment(fixtureUuid, undefined, \"Cypress video\", cypressVideoPath, {\n contentType: ContentType.MP4,\n });\n this.allureRuntime.stopFixture(fixtureUuid);\n }\n\n if (runContext.globalHooksMessages.length > 0) {\n runContext.globalHooksMessages.forEach((message) => {\n if (message.type === \"cypress_hook_start\") {\n const fixtureUuid = this.allureRuntime.startFixture(runContext.scopes[0], message.data.type, {\n name: message.data.name,\n start: message.data.start,\n })!;\n\n runContext.executables.push(fixtureUuid);\n return;\n }\n\n if (message.type === \"cypress_hook_end\") {\n const fixtureUuid = runContext.executables.pop()!;\n\n this.allureRuntime.updateFixture(fixtureUuid, (r) => {\n r.status = message.data.status;\n r.stop = message.data.stop;\n\n if (message.data.statusDetails) {\n r.statusDetails = message.data.statusDetails;\n }\n });\n this.allureRuntime.stopFixture(fixtureUuid);\n }\n });\n }\n\n this.allureRuntime.writeScope(runContext.scopes.pop()!);\n }\n}\n\nexport const allureCypress = (on: Cypress.PluginEvents, allureConfig?: Config) => {\n const allureCypressReporter = new AllureCypress(allureConfig);\n\n allureCypressReporter.attachToCypress(on);\n\n on(\"after:run\", (results) => {\n allureCypressReporter.endRun(results as CypressCommandLine.CypressRunResult);\n });\n\n return allureCypressReporter;\n};\n"],"mappings":";;;;;;AACA,IAAAA,gBAAA,GAAAC,OAAA;AAEA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAQA,IAAAG,MAAA,GAAAH,OAAA;AAA8C,IAAAI,SAAA;AAAA,SAAAC,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,OAAAa,OAAA,WAAAd,CAAA,IAAAe,eAAA,CAAAhB,CAAA,EAAAC,CAAA,EAAAC,CAAA,CAAAD,CAAA,SAAAE,MAAA,CAAAc,yBAAA,GAAAd,MAAA,CAAAe,gBAAA,CAAAlB,CAAA,EA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mC,GAAG,CAAC,CAAE;UAEjD,IAAI,CAAC3C,aAAa,CAACoD,aAAa,CAACL,aAAW,EAAG3F,CAAC,IAAK;YACnDA,CAAC,CAACoG,MAAM,GAAGxB,OAAO,CAACa,IAAI,CAACW,MAAM;YAC9BpG,CAAC,CAACqG,IAAI,GAAGzB,OAAO,CAACa,IAAI,CAACY,IAAI;YAE1B,IAAIzB,OAAO,CAACa,IAAI,CAACa,aAAa,EAAE;cAC9BtG,CAAC,CAACsG,aAAa,GAAG1B,OAAO,CAACa,IAAI,CAACa,aAAa;YAC9C;UACF,CAAC,CAAC;UACF,IAAI,CAAC1D,aAAa,CAAC2D,WAAW,CAACZ,aAAW,CAAC;QAC7C;MACF,CAAC,CAAC;IACJ;IAEA,IAAI,CAAC/C,aAAa,CAAC4C,UAAU,CAACb,UAAU,CAACrB,MAAM,CAACiC,GAAG,CAAC,CAAE,CAAC;EACzD;AACF;AAACwD,OAAA,CAAA1G,aAAA,GAAAA,aAAA;AAEM,IAAM2G,aAAa,GAAGA,CAACvF,EAAwB,EAAEwF,YAAqB,KAAK;EAChF,IAAMC,qBAAqB,GAAG,IAAI7G,aAAa,CAAC4G,YAAY,CAAC;EAE7DC,qBAAqB,CAAC1F,eAAe,CAACC,EAAE,CAAC;EAEzCA,EAAE,CAAC,WAAW,EAAG0F,OAAO,IAAK;IAC3BD,qBAAqB,CAAChF,MAAM,CAACiF,OAA8C,CAAC;EAC9E,CAAC,CAAC;EAEF,OAAOD,qBAAqB;AAC9B,CAAC;AAACH,OAAA,CAAAC,aAAA,GAAAA,aAAA","ignoreList":[]}
package/dist/cjs/utils.js CHANGED
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.uint8ArrayToBase64 = exports.normalizeAttachmentContentEncoding = exports.getSuitePath = void 0;
6
+ exports.uint8ArrayToBase64 = exports.toReversed = exports.normalizeAttachmentContentEncoding = exports.last = exports.isGlobalHook = exports.isCommandShouldBeSkipped = exports.getSuitePath = exports.getHookType = void 0;
7
+ var _model = require("./model.js");
7
8
  var uint8ArrayToBase64 = data => {
8
9
  // @ts-ignore
9
10
  var u8arrayLike = Array.isArray(data) || data.buffer;
@@ -36,4 +37,41 @@ var getSuitePath = test => {
36
37
  return path;
37
38
  };
38
39
  exports.getSuitePath = getSuitePath;
40
+ var isCommandShouldBeSkipped = command => {
41
+ if (command.attributes.name === "task" && command.attributes.args[0] === "allureReportTest") {
42
+ return true;
43
+ }
44
+
45
+ // we don't need to report then commands because it's just a promise handle
46
+ if (command.attributes.name === "then") {
47
+ return true;
48
+ }
49
+
50
+ // we should skip artificial wrap from allure steps
51
+ if (command.attributes.name === "wrap" && command.attributes.args[0] === _model.ALLURE_REPORT_STEP_COMMAND) {
52
+ return true;
53
+ }
54
+ return false;
55
+ };
56
+ exports.isCommandShouldBeSkipped = isCommandShouldBeSkipped;
57
+ var toReversed = arr => {
58
+ var result = [];
59
+ for (var i = arr.length - 1; i >= 0; i--) {
60
+ result.push(arr[i]);
61
+ }
62
+ return result;
63
+ };
64
+ exports.toReversed = toReversed;
65
+ var isGlobalHook = hookName => {
66
+ return /(before|after) all/.test(hookName);
67
+ };
68
+ exports.isGlobalHook = isGlobalHook;
69
+ var getHookType = hookName => {
70
+ return hookName.includes("before") ? "before" : "after";
71
+ };
72
+ exports.getHookType = getHookType;
73
+ var last = arr => {
74
+ return arr[arr.length - 1];
75
+ };
76
+ exports.last = last;
39
77
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["uint8ArrayToBase64","data","u8arrayLike","Array","isArray","buffer","btoa","String","fromCharCode","apply","exports","normalizeAttachmentContentEncoding","encoding","getSuitePath","test","path","currentSuite","parent","title","unshift"],"sources":["../../src/utils.ts"],"sourcesContent":["export const uint8ArrayToBase64 = (data: unknown) => {\n // @ts-ignore\n const u8arrayLike = Array.isArray(data) || data.buffer;\n\n if (!u8arrayLike) {\n return data as string;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n return btoa(String.fromCharCode.apply(null, data as number[]));\n};\n\nexport const normalizeAttachmentContentEncoding = (data: unknown, encoding: BufferEncoding): BufferEncoding => {\n // @ts-ignore\n const u8arrayLike = Array.isArray(data) || data.buffer;\n\n if (u8arrayLike) {\n return \"base64\";\n }\n\n return encoding;\n};\n\nexport const getSuitePath = (test: Mocha.Test): string[] => {\n const path: string[] = [];\n let currentSuite: Mocha.Suite | undefined = test.parent;\n\n while (currentSuite) {\n if (currentSuite.title) {\n path.unshift(currentSuite.title);\n }\n\n currentSuite = currentSuite.parent;\n }\n\n return path;\n};\n"],"mappings":";;;;;;AAAO,IAAMA,kBAAkB,GAAIC,IAAa,IAAK;EACnD;EACA,IAAMC,WAAW,GAAGC,KAAK,CAACC,OAAO,CAACH,IAAI,CAAC,IAAIA,IAAI,CAACI,MAAM;EAEtD,IAAI,CAACH,WAAW,EAAE;IAChB,OAAOD,IAAI;EACb;;EAEA;EACA,OAAOK,IAAI,CAACC,MAAM,CAACC,YAAY,CAACC,KAAK,CAAC,IAAI,EAAER,IAAgB,CAAC,CAAC;AAChE,CAAC;AAACS,OAAA,CAAAV,kBAAA,GAAAA,kBAAA;AAEK,IAAMW,kCAAkC,GAAGA,CAACV,IAAa,EAAEW,QAAwB,KAAqB;EAC7G;EACA,IAAMV,WAAW,GAAGC,KAAK,CAACC,OAAO,CAACH,IAAI,CAAC,IAAIA,IAAI,CAACI,MAAM;EAEtD,IAAIH,WAAW,EAAE;IACf,OAAO,QAAQ;EACjB;EAEA,OAAOU,QAAQ;AACjB,CAAC;AAACF,OAAA,CAAAC,kCAAA,GAAAA,kCAAA;AAEK,IAAME,YAAY,GAAIC,IAAgB,IAAe;EAC1D,IAAMC,IAAc,GAAG,EAAE;EACzB,IAAIC,YAAqC,GAAGF,IAAI,CAACG,MAAM;EAEvD,OAAOD,YAAY,EAAE;IACnB,IAAIA,YAAY,CAACE,KAAK,EAAE;MACtBH,IAAI,CAACI,OAAO,CAACH,YAAY,CAACE,KAAK,CAAC;IAClC;IAEAF,YAAY,GAAGA,YAAY,CAACC,MAAM;EACpC;EAEA,OAAOF,IAAI;AACb,CAAC;AAACL,OAAA,CAAAG,YAAA,GAAAA,YAAA","ignoreList":[]}
1
+ {"version":3,"file":"utils.js","names":["_model","require","uint8ArrayToBase64","data","u8arrayLike","Array","isArray","buffer","btoa","String","fromCharCode","apply","exports","normalizeAttachmentContentEncoding","encoding","getSuitePath","test","path","currentSuite","parent","title","unshift","isCommandShouldBeSkipped","command","attributes","name","args","ALLURE_REPORT_STEP_COMMAND","toReversed","arr","result","i","length","push","isGlobalHook","hookName","getHookType","includes","last"],"sources":["../../src/utils.ts"],"sourcesContent":["import type { CypressCommand } from \"./model.js\";\nimport { ALLURE_REPORT_STEP_COMMAND } from \"./model.js\";\n\nexport const uint8ArrayToBase64 = (data: unknown) => {\n // @ts-ignore\n const u8arrayLike = Array.isArray(data) || data.buffer;\n\n if (!u8arrayLike) {\n return data as string;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n return btoa(String.fromCharCode.apply(null, data as number[]));\n};\n\nexport const normalizeAttachmentContentEncoding = (data: unknown, encoding: BufferEncoding): BufferEncoding => {\n // @ts-ignore\n const u8arrayLike = Array.isArray(data) || data.buffer;\n\n if (u8arrayLike) {\n return \"base64\";\n }\n\n return encoding;\n};\n\nexport const getSuitePath = (test: Mocha.Test): string[] => {\n const path: string[] = [];\n let currentSuite: Mocha.Suite | undefined = test.parent;\n\n while (currentSuite) {\n if (currentSuite.title) {\n path.unshift(currentSuite.title);\n }\n\n currentSuite = currentSuite.parent;\n }\n\n return path;\n};\n\nexport const isCommandShouldBeSkipped = (command: CypressCommand) => {\n if (command.attributes.name === \"task\" && command.attributes.args[0] === \"allureReportTest\") {\n return true;\n }\n\n // we don't need to report then commands because it's just a promise handle\n if (command.attributes.name === \"then\") {\n return true;\n }\n\n // we should skip artificial wrap from allure steps\n if (command.attributes.name === \"wrap\" && command.attributes.args[0] === ALLURE_REPORT_STEP_COMMAND) {\n return true;\n }\n\n return false;\n};\n\nexport const toReversed = <T = unknown>(arr: T[]): T[] => {\n const result: T[] = [];\n\n for (let i = arr.length - 1; i >= 0; i--) {\n result.push(arr[i]);\n }\n\n return result;\n};\n\nexport const isGlobalHook = (hookName: string) => {\n return /(before|after) all/.test(hookName);\n};\n\nexport const getHookType = (hookName: string) => {\n return hookName.includes(\"before\") ? \"before\" : \"after\";\n};\n\nexport const last = <T = unknown>(arr: T[]): T | undefined => {\n return arr[arr.length - 1];\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEO,IAAMC,kBAAkB,GAAIC,IAAa,IAAK;EACnD;EACA,IAAMC,WAAW,GAAGC,KAAK,CAACC,OAAO,CAACH,IAAI,CAAC,IAAIA,IAAI,CAACI,MAAM;EAEtD,IAAI,CAACH,WAAW,EAAE;IAChB,OAAOD,IAAI;EACb;;EAEA;EACA,OAAOK,IAAI,CAACC,MAAM,CAACC,YAAY,CAACC,KAAK,CAAC,IAAI,EAAER,IAAgB,CAAC,CAAC;AAChE,CAAC;AAACS,OAAA,CAAAV,kBAAA,GAAAA,kBAAA;AAEK,IAAMW,kCAAkC,GAAGA,CAACV,IAAa,EAAEW,QAAwB,KAAqB;EAC7G;EACA,IAAMV,WAAW,GAAGC,KAAK,CAACC,OAAO,CAACH,IAAI,CAAC,IAAIA,IAAI,CAACI,MAAM;EAEtD,IAAIH,WAAW,EAAE;IACf,OAAO,QAAQ;EACjB;EAEA,OAAOU,QAAQ;AACjB,CAAC;AAACF,OAAA,CAAAC,kCAAA,GAAAA,kCAAA;AAEK,IAAME,YAAY,GAAIC,IAAgB,IAAe;EAC1D,IAAMC,IAAc,GAAG,EAAE;EACzB,IAAIC,YAAqC,GAAGF,IAAI,CAACG,MAAM;EAEvD,OAAOD,YAAY,EAAE;IACnB,IAAIA,YAAY,CAACE,KAAK,EAAE;MACtBH,IAAI,CAACI,OAAO,CAACH,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QAAQ,GAAG,OAAO;AACzD,CAAC;AAACzB,OAAA,CAAAwB,WAAA,GAAAA,WAAA;AAEK,IAAME,IAAI,GAAiBT,GAAQ,IAAoB;EAC5D,OAAOA,GAAG,CAACA,GAAG,CAACG,MAAM,GAAG,CAAC,CAAC;AAC5B,CAAC;AAACpB,OAAA,CAAA0B,IAAA,GAAAA,IAAA","ignoreList":[]}
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var p=function(e){return e.FAILED="failed",e.BROKEN="broken",e.PASSED="passed",e.SKIPPED="skipped",e}({}),j=[p.FAILED,p.BROKEN,p.PASSED,p.SKIPPED],h=function(e){return e.SCHEDULED="scheduled",e.RUNNING="running",e.FINISHED="finished",e.PENDING="pending",e.INTERRUPTED="interrupted",e}({}),l=function(e){return e.ALLURE_ID="ALLURE_ID",e.AS_ID="ALLURE_ID",e.SUITE="suite",e.PARENT_SUITE="parentSuite",e.SUB_SUITE="subSuite",e.EPIC="epic",e.FEATURE="feature",e.STORY="story",e.SEVERITY="severity",e.TAG="tag",e.OWNER="owner",e.LEAD="lead",e.HOST="host",e.THREAD="thread",e.TEST_METHOD="testMethod",e.TEST_CLASS="testClass",e.PACKAGE="package",e.FRAMEWORK="framework",e.LANGUAGE="language",e.LAYER="layer",e}({}),L=function(e){return e.BLOCKER="blocker",e.CRITICAL="critical",e.NORMAL="normal",e.MINOR="minor",e.TRIVIAL="trivial",e}({}),A=function(e){return e.TEXT="text/plain",e.XML="application/xml",e.HTML="text/html",e.CSV="text/csv",e.TSV="text/tab-separated-values",e.CSS="text/css",e.URI="text/uri-list",e.SVG="image/svg+xml",e.PNG="image/png",e.JSON="application/json",e.ZIP="application/zip",e.WEBM="video/webm",e.JPEG="image/jpeg",e.MP4="video/mp4",e.IMAGEDIFF="application/vnd.allure.image.diff",e}({}),E=function(e){return e.ISSUE="issue",e.TMS="tms",e}({});function O(e,t,r,s,n,a,i){try{var u=e[a](i),o=u.value}catch(g){return void r(g)}u.done?t(o):Promise.resolve(o).then(s,n)}function d(e){return function(){var t=this,r=arguments;return new Promise(function(s,n){var a=e.apply(t,r);function i(o){O(a,s,n,i,u,"next",o)}function u(o){O(a,s,n,i,u,"throw",o)}i(void 0)})}}var R=class{attachment(){var t=this;return d(function*(){yield t.warning()})()}attachmentFromPath(){var t=this;return d(function*(){yield t.warning()})()}description(){var t=this;return d(function*(){yield t.warning()})()}descriptionHtml(){var t=this;return d(function*(){yield t.warning()})()}displayName(){var t=this;return d(function*(){yield t.warning()})()}historyId(){var t=this;return d(function*(){yield t.warning()})()}labels(){var t=this;return d(function*(){yield t.warning()})()}links(){var t=this;return d(function*(){yield t.warning()})()}parameter(){var t=this;return d(function*(){yield t.warning()})()}step(t,r){var s=this;return d(function*(){return yield s.warning(),r()})()}stepDisplayName(){var t=this;return d(function*(){yield t.warning()})()}stepParameter(){var t=this;return d(function*(){yield t.warning()})()}testCaseId(){var t=this;return d(function*(){yield t.warning()})()}warning(){return d(function*(){console.log("no test runtime is found. Please check test framework configuration")})()}},y=new R;var C="allureTestRuntime",T=e=>{globalThis[C]=()=>e},b=()=>globalThis?.[C],v=()=>{var e=b();if(e){var t;return(t=e())!==null&&t!==void 0?t:y}return y},w=()=>{var e=b();if(e){var t;return(t=e())!==null&&t!==void 0?t:y}if("_playwrightInstance"in globalThis)try{return(0,eval)("(() => import('allure-playwright/autoconfig'))()").then(()=>{var r,s;return(r=(s=b())===null||s===void 0?void 0:s())!==null&&r!==void 0?r:y})}catch(r){return console.log("can't execute allure-playwright/autoconfig",r),y}return y};function x(){x=function(a,i){return new r(a,void 0,i)};var e=RegExp.prototype,t=new WeakMap;function r(n,a,i){var u=RegExp(n,a);return t.set(u,i||t.get(n)),S(u,r.prototype)}function s(n,a){var i=t.get(a);return Object.keys(i).reduce(function(u,o){var g=i[o];if(typeof g=="number")u[o]=n[g];else{for(var f=0;n[g[f]]===void 0&&f+1<g.length;)f++;u[o]=n[g[f]]}return u},Object.create(null))}return U(r,RegExp),r.prototype.exec=function(n){var a=e.exec.call(this,n);if(a){a.groups=s(a,this);var i=a.indices;i&&(i.groups=s(i,this))}return a},r.prototype[Symbol.replace]=function(n,a){if(typeof a=="string"){var i=t.get(this);return e[Symbol.replace].call(this,n,a.replace(/\$<([^>]+)>/g,function(o,g){var f=i[g];return"$"+(Array.isArray(f)?f.join("$"):f)}))}if(typeof a=="function"){var u=this;return e[Symbol.replace].call(this,n,function(){var o=arguments;return typeof o[o.length-1]!="object"&&(o=[].slice.call(o)).push(s(o,u)),a.apply(this,o)})}return e[Symbol.replace].call(this,n,a)},x.apply(this,arguments)}function U(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&S(e,t)}function S(e,t){return S=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,s){return r.__proto__=s,r},S(e,t)}var H=x(/@?allure.id[:=]([^\s]+)/,{id:1}),be=new RegExp(H,"g"),B=x(/@?allure.label.([^\s]+?)[:=]([^\s]+)/,{name:1,value:2}),Te=new RegExp(B,"g");var I=e=>e.some(t=>t.type==="step_start"||t.type==="step_stop"),k=e=>e.reduce((t,r)=>{if(r.type!=="step_start"&&r.type!=="step_stop")return t;if(r.type==="step_start")return t.push([r]),t;var s=t.findLastIndex(n=>n.length===1);return s===-1||t[s].push(r),t},[]),M=e=>{var t=k(e);return t.filter(r=>r.length===1)},P=e=>!!e&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function";var c=function(t){for(var r=arguments.length,s=new Array(r>1?r-1:0),n=1;n<r;n++)s[n-1]=arguments[n];var a=w();return P(a)?a.then(i=>i[t](...s)):a[t](...s)},m=(e,t)=>c("labels",{name:e,value:t}),K=function(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return c("labels",...r)},_=(e,t,r)=>c("links",{url:e,type:r,name:t}),z=function(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return c("links",...r)},V=(e,t,r)=>c("parameter",e,t,r),W=e=>c("description",e),Y=e=>c("descriptionHtml",e),Z=e=>c("displayName",e),$=e=>c("historyId",e),J=e=>c("testCaseId",e),X=(e,t,r)=>{var s=typeof r=="string"?{contentType:r}:r;return c("attachment",e,t,s)};var q=()=>({displayName:e=>c("stepDisplayName",e),parameter:(e,t,r)=>c("stepParameter",e,t,r)}),Q=(e,t)=>c("step",e,()=>t(q())),ee=(e,t)=>_(e,t,E.ISSUE),te=(e,t)=>_(e,t,E.TMS),re=e=>m(l.ALLURE_ID,e),se=e=>m(l.EPIC,e),ne=e=>m(l.FEATURE,e),ae=e=>m(l.STORY,e),ie=e=>m(l.SUITE,e),oe=e=>m(l.PARENT_SUITE,e),ue=e=>m(l.SUB_SUITE,e),pe=e=>m(l.OWNER,e),le=e=>m(l.SEVERITY,e),ce=e=>m(l.LAYER,e),de=e=>m(l.TAG,e),me=function(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return c("labels",...r.map(n=>({name:l.TAG,value:n})))};var F=e=>Array.isArray(e)||e.buffer?btoa(String.fromCharCode.apply(null,e)):e,G=(e,t)=>Array.isArray(e)||e.buffer?"base64":t,N=e=>{let t=[],r=e.parent;for(;r;)r.title&&t.unshift(r.title),r=r.parent;return t};var D=class{labels(...t){return this.sendMessageAsync({type:"metadata",data:{labels:t}})}links(...t){return this.sendMessageAsync({type:"metadata",data:{links:t}})}parameter(t,r,s){return this.sendMessageAsync({type:"metadata",data:{parameters:[{name:t,value:r,...s}]}})}description(t){return this.sendMessageAsync({type:"metadata",data:{description:t}})}descriptionHtml(t){return this.sendMessageAsync({type:"metadata",data:{descriptionHtml:t}})}displayName(t){return this.sendMessageAsync({type:"metadata",data:{displayName:t}})}historyId(t){return this.sendMessageAsync({type:"metadata",data:{historyId:t}})}testCaseId(t){return this.sendMessageAsync({type:"metadata",data:{testCaseId:t}})}attachment(t,r,s){let n=r?.type==="Buffer"?r.data:r,a=r instanceof Buffer?"base64":"utf-8",i=G(n,a),u=F(n);return this.sendMessageAsync({type:"attachment_content",data:{name:t,content:u,encoding:i,contentType:s.contentType,fileExtension:s.fileExtension}})}attachmentFromPath(t,r,s){return this.sendMessageAsync({type:"attachment_path",data:{name:t,path:r,contentType:s.contentType,fileExtension:s.fileExtension}})}step(t,r){return cy.wrap(null,{log:!1}).then(()=>(this.sendMessage({type:"step_start",data:{name:t,start:Date.now()}}),Cypress.Promise.resolve(r()))).then(s=>this.sendMessageAsync({type:"step_stop",data:{status:p.PASSED,stage:h.FINISHED,stop:Date.now()}}).then(()=>s))}stepDisplayName(t){return this.sendMessageAsync({type:"step_metadata",data:{name:t}})}stepParameter(t,r,s){return this.sendMessageAsync({type:"step_metadata",data:{parameters:[{name:t,value:r,mode:s}]}})}sendMessage(t){let r=Cypress.env("allureRuntimeMessages")||[];Cypress.env("allureRuntimeMessages",r.concat(t))}sendMessageAsync(t){return this.sendMessage(t),Cypress.Promise.resolve()}},{EVENT_TEST_BEGIN:he,EVENT_TEST_FAIL:ye,EVENT_TEST_PASS:ve}=Mocha.Runner.constants,Ee=()=>{Cypress.env("allureInitialized")||(Cypress.mocha.getRunner().on(he,t=>{let r=new D;Cypress.env("allureRuntimeMessages",[]),r.sendMessage({type:"cypress_start",data:{isInteractive:Cypress.config("isInteractive"),absolutePath:Cypress.spec.absolute,specPath:N(t).concat(t.title),filename:Cypress.spec.relative,start:Date.now()}}),T(r)}).on(ve,()=>{let t=v(),r=Cypress.env("allureRuntimeMessages");M(r).forEach(()=>{t.sendMessage({type:"step_stop",data:{stage:h.FINISHED,status:p.PASSED,stop:Date.now()}})}),t.sendMessage({type:"cypress_end",data:{stage:h.FINISHED,status:p.PASSED,stop:Date.now()}})}).on(ye,(t,r)=>{v().sendMessage({type:"cypress_end",data:{stage:h.FINISHED,status:r.constructor.name==="AssertionError"?p.FAILED:p.BROKEN,statusDetails:{message:r.message,trace:r.stack},stop:Date.now()}})}),Cypress.Screenshot.defaults({onAfterScreenshot:(t,r)=>v().sendMessageAsync({type:"attachment_path",data:{path:r.path,name:r.name||"Screenshot",contentType:A.PNG}})}),Cypress.on("fail",t=>{let r=v(),s=Cypress.env("allureRuntimeMessages");if(!I(s))throw t;let a=M(s);if(a.length===0)throw t;let i=t.constructor.name==="AssertionError"?p.FAILED:p.BROKEN;throw a.forEach(()=>{r.sendMessage({type:"step_stop",data:{stage:h.FINISHED,status:i,stop:Date.now(),statusDetails:{message:t.message,trace:t.stack}}})}),t}),afterEach(()=>{let t=Cypress.env("allureRuntimeMessages");cy.task("allureReportTest",t,{log:!1})}),Cypress.env("allureInitialized",!0))};Ee();export{D as AllureCypressTestRuntime,A as ContentType,l as LabelName,E as LinkType,L as Severity,h as Stage,p as Status,j as StatusByPriority,re as allureId,X as attachment,W as description,Y as descriptionHtml,Z as displayName,se as epic,ne as feature,$ as historyId,ee as issue,m as label,K as labels,ce as layer,_ as link,z as links,pe as owner,V as parameter,oe as parentSuite,le as severity,Q as step,ae as story,ue as subSuite,ie as suite,de as tag,me as tags,J as testCaseId,te as tms};
1
+ var p=function(t){return t.FAILED="failed",t.BROKEN="broken",t.PASSED="passed",t.SKIPPED="skipped",t}({}),V=[p.FAILED,p.BROKEN,p.PASSED,p.SKIPPED],z=function(t){return t.SCHEDULED="scheduled",t.RUNNING="running",t.FINISHED="finished",t.PENDING="pending",t.INTERRUPTED="interrupted",t}({}),d=function(t){return t.ALLURE_ID="ALLURE_ID",t.AS_ID="ALLURE_ID",t.SUITE="suite",t.PARENT_SUITE="parentSuite",t.SUB_SUITE="subSuite",t.EPIC="epic",t.FEATURE="feature",t.STORY="story",t.SEVERITY="severity",t.TAG="tag",t.OWNER="owner",t.LEAD="lead",t.HOST="host",t.THREAD="thread",t.TEST_METHOD="testMethod",t.TEST_CLASS="testClass",t.PACKAGE="package",t.FRAMEWORK="framework",t.LANGUAGE="language",t.LAYER="layer",t}({}),W=function(t){return t.BLOCKER="blocker",t.CRITICAL="critical",t.NORMAL="normal",t.MINOR="minor",t.TRIVIAL="trivial",t}({}),A=function(t){return t.TEXT="text/plain",t.XML="application/xml",t.HTML="text/html",t.CSV="text/csv",t.TSV="text/tab-separated-values",t.CSS="text/css",t.URI="text/uri-list",t.SVG="image/svg+xml",t.PNG="image/png",t.JSON="application/json",t.ZIP="application/zip",t.WEBM="video/webm",t.JPEG="image/jpeg",t.MP4="video/mp4",t.IMAGEDIFF="application/vnd.allure.image.diff",t}({}),E=function(t){return t.DEFAULT="link",t.ISSUE="issue",t.TMS="tms",t}({});function G(t,e,s,r,a,n,i){try{var u=t[n](i),o=u.value}catch(m){return void s(m)}u.done?e(o):Promise.resolve(o).then(r,a)}function c(t){return function(){var e=this,s=arguments;return new Promise(function(r,a){var n=t.apply(e,s);function i(o){G(n,r,a,i,u,"next",o)}function u(o){G(n,r,a,i,u,"throw",o)}i(void 0)})}}var b=class{attachment(){var e=this;return c(function*(){yield e.warning()})()}attachmentFromPath(){var e=this;return c(function*(){yield e.warning()})()}description(){var e=this;return c(function*(){yield e.warning()})()}descriptionHtml(){var e=this;return c(function*(){yield e.warning()})()}displayName(){var e=this;return c(function*(){yield e.warning()})()}historyId(){var e=this;return c(function*(){yield e.warning()})()}labels(){var e=this;return c(function*(){yield e.warning()})()}links(){var e=this;return c(function*(){yield e.warning()})()}parameter(){var e=this;return c(function*(){yield e.warning()})()}step(e,s){var r=this;return c(function*(){return yield r.warning(),s()})()}stepDisplayName(){var e=this;return c(function*(){yield e.warning()})()}stepParameter(){var e=this;return c(function*(){yield e.warning()})()}testCaseId(){var e=this;return c(function*(){yield e.warning()})()}warning(){return c(function*(){console.log("no test runtime is found. Please check test framework configuration")})()}},v=new b;var L="allureTestRuntime",P=t=>{globalThis[L]=()=>t},C=()=>globalThis?.[L],y=()=>{var t=C();if(t){var e;return(e=t())!==null&&e!==void 0?e:v}return v},w=()=>{var t=C();if(t){var e;return(e=t())!==null&&e!==void 0?e:v}if("_playwrightInstance"in globalThis)try{return(0,eval)("(() => import('allure-playwright/autoconfig'))()").then(()=>{var s,r;return(s=(r=C())===null||r===void 0?void 0:r())!==null&&s!==void 0?s:v})}catch(s){return console.log("can't execute allure-playwright/autoconfig",s),v}return v};function _(){_=function(n,i){return new s(n,void 0,i)};var t=RegExp.prototype,e=new WeakMap;function s(a,n,i){var u=RegExp(a,n);return e.set(u,i||e.get(a)),S(u,s.prototype)}function r(a,n){var i=e.get(n);return Object.keys(i).reduce(function(u,o){var m=i[o];if(typeof m=="number")u[o]=a[m];else{for(var f=0;a[m[f]]===void 0&&f+1<m.length;)f++;u[o]=a[m[f]]}return u},Object.create(null))}return $(s,RegExp),s.prototype.exec=function(a){var n=t.exec.call(this,a);if(n){n.groups=r(n,this);var i=n.indices;i&&(i.groups=r(i,this))}return n},s.prototype[Symbol.replace]=function(a,n){if(typeof n=="string"){var i=e.get(this);return t[Symbol.replace].call(this,a,n.replace(/\$<([^>]+)>/g,function(o,m){var f=i[m];return"$"+(Array.isArray(f)?f.join("$"):f)}))}if(typeof n=="function"){var u=this;return t[Symbol.replace].call(this,a,function(){var o=arguments;return typeof o[o.length-1]!="object"&&(o=[].slice.call(o)).push(r(o,u)),n.apply(this,o)})}return t[Symbol.replace].call(this,a,n)},_.apply(this,arguments)}function $(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&S(t,e)}function S(t,e){return S=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,r){return s.__proto__=r,s},S(t,e)}var Y=_(/@?allure.id[:=]([^\s]+)/,{id:1}),je=new RegExp(Y,"g"),Z=_(/@?allure.label.([^\s]+?)[:=]([^\s]+)/,{name:1,value:2}),Fe=new RegExp(Z,"g");var I=t=>t.some(e=>e.type==="step_start"||e.type==="step_stop"),J=t=>t.reduce((e,s)=>{if(s.type!=="step_start"&&s.type!=="step_stop")return e;if(s.type==="step_start")return e.push([s]),e;var r=e.findLastIndex(a=>a.length===1);return r===-1||e[r].push(s),e},[]),M=t=>{var e=J(t);return e.filter(s=>s.length===1)},D=t=>!!t&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function";var l=function(e){for(var s=arguments.length,r=new Array(s>1?s-1:0),a=1;a<s;a++)r[a-1]=arguments[a];var n=w();return D(n)?n.then(i=>i[e](...r)):n[e](...r)},g=(t,e)=>l("labels",{name:t,value:e}),q=function(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return l("labels",...s)},O=(t,e,s)=>l("links",{url:t,type:s,name:e}),X=function(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return l("links",...s)},Q=(t,e,s)=>l("parameter",t,e,s),ee=t=>l("description",t),te=t=>l("descriptionHtml",t),se=t=>l("displayName",t),re=t=>l("historyId",t),ae=t=>l("testCaseId",t),ne=(t,e,s)=>{var r=typeof s=="string"?{contentType:s}:s;return l("attachment",t,e,r)},ie=(t,e,s)=>{var r=typeof s=="string"?{contentType:s}:s;return l("attachmentFromPath",t,e,r)},oe=()=>({displayName:t=>l("stepDisplayName",t),parameter:(t,e,s)=>l("stepParameter",t,e,s)}),ue=(t,e)=>l("step",t,()=>e(oe())),pe=(t,e)=>O(t,e,E.ISSUE),le=(t,e)=>O(t,e,E.TMS),de=t=>g(d.ALLURE_ID,t),ce=t=>g(d.EPIC,t),me=t=>g(d.FEATURE,t),ye=t=>g(d.STORY,t),ge=t=>g(d.SUITE,t),fe=t=>g(d.PARENT_SUITE,t),he=t=>g(d.SUB_SUITE,t),ve=t=>g(d.OWNER,t),Ee=t=>g(d.SEVERITY,t),_e=t=>g(d.LAYER,t),Se=t=>g(d.TAG,t),Me=function(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return l("labels",...s.map(a=>({name:d.TAG,value:a})))};var x="__allure_report_shutdown_hook__",R="__allure_report_step_command__";var j=t=>Array.isArray(t)||t.buffer?btoa(String.fromCharCode.apply(null,t)):t,F=(t,e)=>Array.isArray(t)||t.buffer?"base64":e,k=t=>{let e=[],s=t.parent;for(;s;)s.title&&e.unshift(s.title),s=s.parent;return e},N=t=>t.attributes.name==="task"&&t.attributes.args[0]==="allureReportTest"||t.attributes.name==="then"||t.attributes.name==="wrap"&&t.attributes.args[0]===R,H=t=>{let e=[];for(let s=t.length-1;s>=0;s--)e.push(t[s]);return e},T=t=>/(before|after) all/.test(t),B=t=>t.includes("before")?"before":"after";var U=class{labels(...e){return this.sendMessageAsync({type:"metadata",data:{labels:e}})}links(...e){return this.sendMessageAsync({type:"metadata",data:{links:e}})}parameter(e,s,r){return this.sendMessageAsync({type:"metadata",data:{parameters:[{name:e,value:s,...r}]}})}description(e){return this.sendMessageAsync({type:"metadata",data:{description:e}})}descriptionHtml(e){return this.sendMessageAsync({type:"metadata",data:{descriptionHtml:e}})}displayName(e){return this.sendMessageAsync({type:"metadata",data:{displayName:e}})}historyId(e){return this.sendMessageAsync({type:"metadata",data:{historyId:e}})}testCaseId(e){return this.sendMessageAsync({type:"metadata",data:{testCaseId:e}})}attachment(e,s,r){let a=s?.type==="Buffer"?s.data:s,n=s instanceof Buffer?"base64":"utf-8",i=F(a,n),u=j(a);return this.sendMessageAsync({type:"attachment_content",data:{name:e,content:u,encoding:i,contentType:r.contentType,fileExtension:r.fileExtension}})}attachmentFromPath(e,s,r){return this.sendMessageAsync({type:"attachment_path",data:{name:e,path:s,contentType:r.contentType,fileExtension:r.fileExtension}})}step(e,s){return cy.wrap(R,{log:!1}).then(()=>(this.sendMessage({type:"step_start",data:{name:e,start:Date.now()}}),Cypress.Promise.resolve(s()))).then(r=>this.sendMessageAsync({type:"step_stop",data:{status:p.PASSED,stop:Date.now()}}).then(()=>r))}stepDisplayName(e){return this.sendMessageAsync({type:"step_metadata",data:{name:e}})}stepParameter(e,s,r){return this.sendMessageAsync({type:"step_metadata",data:{parameters:[{name:e,value:s,mode:r}]}})}sendMessage(e){let s=Cypress.env("allureRuntimeMessages")||[];Cypress.env("allureRuntimeMessages",s.concat(e))}sendMessageAsync({type:e,data:s}){return this.sendMessage({type:e,data:{...s,cypressTestId:Cypress.state("test")?.id??""}}),Cypress.Promise.resolve()}},{EVENT_RUN_BEGIN:Te,EVENT_RUN_END:Ae,EVENT_TEST_BEGIN:be,EVENT_TEST_FAIL:Ce,EVENT_TEST_PASS:Pe,EVENT_SUITE_BEGIN:we,EVENT_SUITE_END:Ie,EVENT_HOOK_BEGIN:De,EVENT_HOOK_END:Oe}=Mocha.Runner.constants,ke=()=>{Cypress.env("allureInitialized")||(Cypress.env("allureInitialized",!0),Cypress.mocha.getRunner().on(Te,()=>{let e=new U;Cypress.env("allureRuntimeMessages",[]),P(e)}).on(De,e=>{if(e.title.includes(x))return;let s=y(),r=Cypress.state()?.test?.id;s.sendMessageAsync({type:"cypress_hook_start",data:{id:r?`${r}:${e.hookId}`:"",parentId:e.parent.id,name:e.title,type:B(e.title),start:Date.now(),global:T(e.title)}})}).on(Oe,e=>{if(e.title.includes(x))return;let s=y(),r=Cypress.env("allureRuntimeMessages"),a=H(r).find(({type:n})=>n==="cypress_hook_start");return a.data.id||(a.data.id=`${e.id}:${e.hookId}`),s.sendMessageAsync({type:"cypress_hook_end",data:{id:a.data.id,parentId:e.parent.id,status:p.PASSED,stop:a.data.start+(e.duration??0),global:T(e.title)}})}).on(we,e=>y().sendMessageAsync({type:"cypress_suite_start",data:{id:e.titlePath().join(" "),name:e.title}})).on(Ie,e=>y().sendMessageAsync({type:"cypress_suite_end",data:{id:e.titlePath().join(" ")}})).on(be,e=>{y().sendMessage({type:"cypress_test_start",data:{id:e.id,specPath:k(e).concat(e.title),filename:Cypress.spec.relative,start:e.wallClockStartedAt?.getTime()||Date.now()}})}).on(Pe,e=>{let s=y(),r=Cypress.env("allureRuntimeMessages");M(r).forEach(()=>{s.sendMessage({type:"step_stop",data:{status:p.PASSED,stop:Date.now()}})}),s.sendMessage({type:"cypress_test_end",data:{id:e.id,status:p.PASSED,stop:Date.now()}})}).on(Ce,(e,s)=>{let r=y(),a=Cypress.env("allureRuntimeMessages"),n=a.toReversed().findIndex(({type:h})=>h==="cypress_command_start"),i=a.toReversed().findIndex(({type:h})=>h==="cypress_command_end"),u=n>i,o=s.constructor.name==="AssertionError"?p.FAILED:p.BROKEN,m={message:s.message,trace:s.stack};if(u&&r.sendMessage({type:"cypress_command_end",data:{id:a[n].data.id,status:o,statusDetails:m}}),e.hookName){let h=a.toReversed().find(({type:K})=>K==="cypress_hook_start");return r.sendMessageAsync({type:"cypress_hook_end",data:{id:h.data.id,status:o,statusDetails:m,stop:h.data.start+(e.duration??0),parentId:h.data.parentId,global:T(e.hookName)}})}!e.hookName&&e.wallClockStartedAt===void 0&&r.sendMessage({type:"cypress_test_start",data:{id:e.id,specPath:k(e).concat(e.title),filename:Cypress.spec.relative,start:Date.now()}});let f=H(a).find(({type:h})=>h==="cypress_test_start");r.sendMessage({type:"cypress_test_end",data:{id:e.id,status:o,statusDetails:m,stop:f.data.start+(e.duration??0)}})}).on(Ae,()=>{Cypress.config("isInteractive")&&cy.task("allureReportSpec",{absolute:Cypress.spec.absolute})}),Cypress.Screenshot.defaults({onAfterScreenshot:(e,s)=>y().sendMessageAsync({type:"attachment_path",data:{path:s.path,name:s.name||"Screenshot",contentType:A.PNG}})}),Cypress.on("fail",e=>{let s=y(),r=Cypress.env("allureRuntimeMessages");if(!I(r))throw e;let n=M(r);if(n.length===0)throw e;let i=e.constructor.name==="AssertionError"?p.FAILED:p.BROKEN;throw n.forEach(()=>{s.sendMessage({type:"step_stop",data:{status:i,stop:Date.now(),statusDetails:{message:e.message,trace:e.stack}}})}),e}),Cypress.on("command:start",e=>N(e)?void 0:y().sendMessageAsync({type:"cypress_command_start",data:{id:e.attributes.id,name:`Command "${e.attributes.name}"`,args:e.attributes.args.map(r=>typeof r=="string"?r:JSON.stringify(r,null,2))}})),Cypress.on("command:end",e=>N(e)?void 0:y().sendMessageAsync({type:"cypress_command_end",data:{id:e.attributes.id,status:p.PASSED}})),after(x,()=>{let e=Cypress.env("allureRuntimeMessages");cy.task("allureReportTest",{absolutePath:Cypress.spec.absolute,messages:e??[]},{log:!1})}))};ke();export{U as AllureCypressTestRuntime,A as ContentType,d as LabelName,E as LinkType,W as Severity,z as Stage,p as Status,V as StatusByPriority,de as allureId,ne as attachment,ie as attachmentPath,ee as description,te as descriptionHtml,se as displayName,ce as epic,me as feature,re as historyId,pe as issue,g as label,q as labels,_e as layer,O as link,X as links,ve as owner,Q as parameter,fe as parentSuite,Ee as severity,ue as step,ye as story,he as subSuite,ge as suite,Se as tag,Me as tags,ae as testCaseId,le as tms};
2
2
  //# sourceMappingURL=index.js.map