allure-cypress 3.0.0-beta.8 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +181 -147
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +4 -4
- package/dist/cjs/model.js.map +1 -1
- package/dist/cjs/reporter.js +557 -202
- package/dist/cjs/reporter.js.map +1 -1
- package/dist/cjs/runtime.js +649 -0
- package/dist/cjs/runtime.js.map +1 -0
- package/dist/cjs/state.js +56 -0
- package/dist/cjs/state.js.map +1 -0
- package/dist/cjs/utils.js +136 -37
- package/dist/cjs/utils.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +4 -4
- package/dist/esm/model.js.map +1 -1
- package/dist/esm/reporter.js +560 -205
- package/dist/esm/reporter.js.map +1 -1
- package/dist/esm/runtime.js +620 -0
- package/dist/esm/runtime.js.map +1 -0
- package/dist/esm/state.js +38 -0
- package/dist/esm/state.js.map +1 -0
- package/dist/esm/utils.js +126 -35
- package/dist/esm/utils.js.map +1 -1
- package/dist/types/index.d.ts +0 -22
- package/dist/types/model.d.ts +95 -45
- package/dist/types/reporter.d.ts +75 -9
- package/dist/types/runtime.d.ts +50 -0
- package/dist/types/state.d.ts +18 -0
- package/dist/types/utils.d.ts +48 -10
- package/package.json +4 -4
package/dist/esm/reporter.js
CHANGED
|
@@ -1,242 +1,597 @@
|
|
|
1
|
-
var _excluded = ["
|
|
1
|
+
var _excluded = ["fullNameSuffix"],
|
|
2
|
+
_excluded2 = ["labels"],
|
|
3
|
+
_excluded3 = ["fullNameSuffix", "suites", "duration", "retries"],
|
|
4
|
+
_excluded4 = ["resultsDir", "videoOnFailOnly"];
|
|
2
5
|
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; }
|
|
3
6
|
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; }
|
|
4
7
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
5
8
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
|
|
9
|
+
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
|
|
10
|
+
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
6
11
|
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; }
|
|
7
12
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
8
13
|
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); }
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
14
|
+
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
15
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
16
|
+
import { ContentType, Stage, Status } from "allure-js-commons";
|
|
17
|
+
import { ReporterRuntime, createDefaultWriter, getEnvironmentLabels, getFrameworkLabel, getHostLabel, getLanguageLabel, getPackageLabel, getPosixPath, getProjectRoot, getRelativePath, getSuiteLabels, getThreadLabel, parseTestPlan } from "allure-js-commons/sdk/reporter";
|
|
18
|
+
import { DEFAULT_RUNTIME_CONFIG, last } from "./utils.js";
|
|
19
|
+
var _endAllSpecs = /*#__PURE__*/new WeakMap();
|
|
20
|
+
var _applyAllureCypressMessages = /*#__PURE__*/new WeakMap();
|
|
21
|
+
var _startRun = /*#__PURE__*/new WeakMap();
|
|
22
|
+
var _startSuite = /*#__PURE__*/new WeakMap();
|
|
23
|
+
var _pushNewSuiteScope = /*#__PURE__*/new WeakMap();
|
|
24
|
+
var _stopSuite = /*#__PURE__*/new WeakMap();
|
|
25
|
+
var _writeLastSuiteScope = /*#__PURE__*/new WeakMap();
|
|
26
|
+
var _startHook = /*#__PURE__*/new WeakMap();
|
|
27
|
+
var _stopHook = /*#__PURE__*/new WeakMap();
|
|
28
|
+
var _startTest = /*#__PURE__*/new WeakMap();
|
|
29
|
+
var _addNewTestResult = /*#__PURE__*/new WeakMap();
|
|
30
|
+
var _failHookAndTest = /*#__PURE__*/new WeakMap();
|
|
31
|
+
var _passTest = /*#__PURE__*/new WeakMap();
|
|
32
|
+
var _skipTest = /*#__PURE__*/new WeakMap();
|
|
33
|
+
var _addSkippedTest = /*#__PURE__*/new WeakMap();
|
|
34
|
+
var _stopTest = /*#__PURE__*/new WeakMap();
|
|
35
|
+
var _stopExistingTestResult = /*#__PURE__*/new WeakMap();
|
|
36
|
+
var _startCommand = /*#__PURE__*/new WeakMap();
|
|
37
|
+
var _stopCommand = /*#__PURE__*/new WeakMap();
|
|
38
|
+
var _applyRuntimeApiMessages = /*#__PURE__*/new WeakMap();
|
|
39
|
+
var _emitPreviousTestScope = /*#__PURE__*/new WeakMap();
|
|
40
|
+
var _resolveRootUuid = /*#__PURE__*/new WeakMap();
|
|
41
|
+
var _attachSpecVideo = /*#__PURE__*/new WeakMap();
|
|
42
|
+
var _emitRemainingScopes = /*#__PURE__*/new WeakMap();
|
|
43
|
+
var _initializeSpecContext = /*#__PURE__*/new WeakMap();
|
|
13
44
|
export class AllureCypress {
|
|
14
|
-
constructor(
|
|
45
|
+
constructor() {
|
|
46
|
+
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
15
47
|
_defineProperty(this, "allureRuntime", void 0);
|
|
16
|
-
_defineProperty(this, "
|
|
17
|
-
_defineProperty(this, "runContextByAbsolutePath", new Map());
|
|
18
|
-
_defineProperty(this, "globalHooksMessages", []);
|
|
48
|
+
_defineProperty(this, "specContextByAbsolutePath", new Map());
|
|
19
49
|
_defineProperty(this, "videoOnFailOnly", false);
|
|
20
|
-
|
|
21
|
-
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
50
|
+
_defineProperty(this, "attachToCypress", on => {
|
|
51
|
+
on("task", {
|
|
52
|
+
reportAllureCypressSpecMessages: args => {
|
|
53
|
+
_classPrivateFieldGet(_applyAllureCypressMessages, this).call(this, args);
|
|
54
|
+
return null;
|
|
55
|
+
},
|
|
56
|
+
reportFinalAllureCypressSpecMessages: args => {
|
|
57
|
+
_classPrivateFieldGet(_applyAllureCypressMessages, this).call(this, args);
|
|
58
|
+
if (args.isInteractive) {
|
|
59
|
+
// In non-interactive mode the spec is ended via the 'after:spec' event instead
|
|
60
|
+
// to get the spec's video.
|
|
61
|
+
this.endSpec(args.absolutePath);
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Emits the remaining fixtures and writes the video of the spec.
|
|
68
|
+
// In interactive mode it's invoked through the `reportFinalAllureCypressSpecMessages` task.
|
|
69
|
+
on("after:spec", this.onAfterSpec);
|
|
70
|
+
|
|
71
|
+
// Emits the categories and env info. Doesn't work in interactive mode unless
|
|
72
|
+
// `experimentalInteractiveRunEvents` is set.
|
|
73
|
+
on("after:run", this.onAfterRun);
|
|
39
74
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Forward the `after:spec` event into Allure Cypress using this function if
|
|
77
|
+
* you need to define your own handler or combine Allure Cypress with other
|
|
78
|
+
* plugins. More info [here](https://github.com/allure-framework/allure-js/blob/main/packages/allure-cypress/README.md#setupnodeevents-limitations).
|
|
79
|
+
* @param spec The first argument of the `after:spec` event.
|
|
80
|
+
* @param results The second argument of the `after:spec` event. It's `undefined` in interactive mode.
|
|
81
|
+
* @example
|
|
82
|
+
* ```javascript
|
|
83
|
+
* import { defineConfig } from "cypress";
|
|
84
|
+
* import { allureCypress } from "allure-cypress/reporter";
|
|
85
|
+
*
|
|
86
|
+
* export default defineConfig({
|
|
87
|
+
* setupNodeEvents: (on, config) => {
|
|
88
|
+
* const allureReporter = allureCypress(on, config);
|
|
89
|
+
* on("after:spec", (spec, results) => {
|
|
90
|
+
* allureReporter.onAfterSpec(spec, results);
|
|
91
|
+
* });
|
|
92
|
+
* return config;
|
|
93
|
+
* }
|
|
94
|
+
* // ...
|
|
95
|
+
* });
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
_defineProperty(this, "onAfterSpec", (spec, results) => {
|
|
99
|
+
var _results$video;
|
|
100
|
+
this.endSpec(spec.absolute, (_results$video = results === null || results === void 0 ? void 0 : results.video) !== null && _results$video !== void 0 ? _results$video : undefined);
|
|
101
|
+
});
|
|
102
|
+
/**
|
|
103
|
+
* Forward the `after:run` event into Allure Cypress using this function if
|
|
104
|
+
* you need to define your own handler or combine Allure Cypress with other
|
|
105
|
+
* plugins. More info [here](https://github.com/allure-framework/allure-js/blob/main/packages/allure-cypress/README.md#setupnodeevents-limitations).
|
|
106
|
+
* @param results The argument of the `after:run` event. It's `undefined` in interactive mode.
|
|
107
|
+
* @example
|
|
108
|
+
* ```javascript
|
|
109
|
+
* import { defineConfig } from "cypress";
|
|
110
|
+
* import { allureCypress } from "allure-cypress/reporter";
|
|
111
|
+
*
|
|
112
|
+
* export default defineConfig({
|
|
113
|
+
* setupNodeEvents: (on, config) => {
|
|
114
|
+
* const allureReporter = allureCypress(on, config);
|
|
115
|
+
* on("after:run", (results) => {
|
|
116
|
+
* allureReporter.onAfterRun(results);
|
|
117
|
+
* });
|
|
118
|
+
* return config;
|
|
119
|
+
* }
|
|
120
|
+
* // ...
|
|
121
|
+
* });
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
_defineProperty(this, "onAfterRun", results => {
|
|
125
|
+
this.endRun();
|
|
126
|
+
});
|
|
127
|
+
_defineProperty(this, "endRun", () => {
|
|
128
|
+
_classPrivateFieldGet(_endAllSpecs, this).call(this);
|
|
129
|
+
this.allureRuntime.writeEnvironmentInfo();
|
|
130
|
+
this.allureRuntime.writeCategoriesDefinitions();
|
|
131
|
+
});
|
|
132
|
+
_defineProperty(this, "endSpec", (specAbsolutePath, cypressVideoPath) => {
|
|
133
|
+
var specContext = this.specContextByAbsolutePath.get(specAbsolutePath);
|
|
134
|
+
if (specContext) {
|
|
135
|
+
_classPrivateFieldGet(_attachSpecVideo, this).call(this, specContext, cypressVideoPath);
|
|
136
|
+
_classPrivateFieldGet(_emitRemainingScopes, this).call(this, specContext);
|
|
137
|
+
this.specContextByAbsolutePath.delete(specAbsolutePath);
|
|
59
138
|
}
|
|
60
139
|
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
this.endSpec(run.spec, run.video || undefined);
|
|
140
|
+
_classPrivateFieldInitSpec(this, _endAllSpecs, () => {
|
|
141
|
+
for (var specAbsolutePath of this.specContextByAbsolutePath.keys()) {
|
|
142
|
+
this.endSpec(specAbsolutePath);
|
|
143
|
+
}
|
|
66
144
|
});
|
|
67
|
-
this
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
145
|
+
_classPrivateFieldInitSpec(this, _applyAllureCypressMessages, _ref => {
|
|
146
|
+
var {
|
|
147
|
+
messages,
|
|
148
|
+
absolutePath
|
|
149
|
+
} = _ref;
|
|
150
|
+
messages.forEach(message => {
|
|
151
|
+
if (message.type === "cypress_run_start") {
|
|
152
|
+
_classPrivateFieldGet(_startRun, this).call(this, absolutePath);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
var context = this.specContextByAbsolutePath.get(absolutePath);
|
|
156
|
+
if (!context) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
switch (message.type) {
|
|
160
|
+
case "cypress_suite_start":
|
|
161
|
+
_classPrivateFieldGet(_startSuite, this).call(this, context, message);
|
|
162
|
+
break;
|
|
163
|
+
case "cypress_suite_end":
|
|
164
|
+
_classPrivateFieldGet(_stopSuite, this).call(this, context, message);
|
|
165
|
+
break;
|
|
166
|
+
case "cypress_hook_start":
|
|
167
|
+
_classPrivateFieldGet(_startHook, this).call(this, context, message);
|
|
168
|
+
break;
|
|
169
|
+
case "cypress_hook_end":
|
|
170
|
+
_classPrivateFieldGet(_stopHook, this).call(this, context, message);
|
|
171
|
+
break;
|
|
172
|
+
case "cypress_test_start":
|
|
173
|
+
_classPrivateFieldGet(_startTest, this).call(this, context, message);
|
|
174
|
+
break;
|
|
175
|
+
case "cypress_test_pass":
|
|
176
|
+
_classPrivateFieldGet(_passTest, this).call(this, context);
|
|
177
|
+
break;
|
|
178
|
+
case "cypress_fail":
|
|
179
|
+
_classPrivateFieldGet(_failHookAndTest, this).call(this, context, message);
|
|
180
|
+
break;
|
|
181
|
+
case "cypress_test_skip":
|
|
182
|
+
_classPrivateFieldGet(_skipTest, this).call(this, context, message);
|
|
183
|
+
break;
|
|
184
|
+
case "cypress_skipped_test":
|
|
185
|
+
_classPrivateFieldGet(_addSkippedTest, this).call(this, context, message);
|
|
186
|
+
break;
|
|
187
|
+
case "cypress_test_end":
|
|
188
|
+
_classPrivateFieldGet(_stopTest, this).call(this, context, message);
|
|
189
|
+
break;
|
|
190
|
+
case "cypress_command_start":
|
|
191
|
+
_classPrivateFieldGet(_startCommand, this).call(this, context, message);
|
|
192
|
+
break;
|
|
193
|
+
case "cypress_command_end":
|
|
194
|
+
_classPrivateFieldGet(_stopCommand, this).call(this, context, message);
|
|
195
|
+
break;
|
|
196
|
+
default:
|
|
197
|
+
_classPrivateFieldGet(_applyRuntimeApiMessages, this).call(this, context, message);
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
86
200
|
});
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
201
|
+
});
|
|
202
|
+
_classPrivateFieldInitSpec(this, _startRun, absolutePath => {
|
|
203
|
+
// This function is executed once on `cypress run`, but it can be executed
|
|
204
|
+
// multiple times during an interactive session (`cypress open`). Ideally,
|
|
205
|
+
// in that case, we should remove previous result objects that haven't been
|
|
206
|
+
// written yet, but it would've required support in ReporterRuntime.
|
|
207
|
+
// Currently, we're discarding the entire spec context.
|
|
208
|
+
_classPrivateFieldGet(_initializeSpecContext, this).call(this, absolutePath);
|
|
209
|
+
});
|
|
210
|
+
_classPrivateFieldInitSpec(this, _startSuite, (context, _ref2) => {
|
|
211
|
+
var {
|
|
212
|
+
data: {
|
|
213
|
+
id,
|
|
214
|
+
name,
|
|
215
|
+
root
|
|
216
|
+
}
|
|
217
|
+
} = _ref2;
|
|
218
|
+
_classPrivateFieldGet(_pushNewSuiteScope, this).call(this, context, id);
|
|
219
|
+
if (!root) {
|
|
220
|
+
_classPrivateFieldGet(_emitPreviousTestScope, this).call(this, context);
|
|
221
|
+
context.suiteNames.push(name);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
_classPrivateFieldInitSpec(this, _pushNewSuiteScope, (context, suiteId) => {
|
|
225
|
+
var scope = this.allureRuntime.startScope();
|
|
226
|
+
context.suiteScopes.push(scope);
|
|
227
|
+
context.suiteIdToScope.set(suiteId, scope);
|
|
228
|
+
context.suiteScopeToId.set(scope, suiteId);
|
|
229
|
+
return scope;
|
|
230
|
+
});
|
|
231
|
+
_classPrivateFieldInitSpec(this, _stopSuite, (context, _ref3) => {
|
|
232
|
+
var {
|
|
233
|
+
data: {
|
|
234
|
+
root
|
|
235
|
+
}
|
|
236
|
+
} = _ref3;
|
|
237
|
+
_classPrivateFieldGet(_emitPreviousTestScope, this).call(this, context);
|
|
238
|
+
if (!root) {
|
|
239
|
+
context.suiteNames.pop();
|
|
240
|
+
}
|
|
241
|
+
_classPrivateFieldGet(_writeLastSuiteScope, this).call(this, context);
|
|
242
|
+
});
|
|
243
|
+
_classPrivateFieldInitSpec(this, _writeLastSuiteScope, context => {
|
|
244
|
+
var scope = context.suiteScopes.pop();
|
|
245
|
+
if (scope) {
|
|
246
|
+
var suiteId = context.suiteScopeToId.get(scope);
|
|
247
|
+
if (suiteId) {
|
|
248
|
+
context.suiteScopeToId.delete(scope);
|
|
249
|
+
context.suiteIdToScope.delete(suiteId);
|
|
250
|
+
}
|
|
251
|
+
this.allureRuntime.writeScope(scope);
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
_classPrivateFieldInitSpec(this, _startHook, (context, _ref4) => {
|
|
255
|
+
var {
|
|
256
|
+
data: {
|
|
257
|
+
name,
|
|
258
|
+
scopeType,
|
|
259
|
+
position,
|
|
260
|
+
start
|
|
261
|
+
}
|
|
262
|
+
} = _ref4;
|
|
263
|
+
var isEach = scopeType === "each";
|
|
264
|
+
var isAfterEach = position === "after" && isEach;
|
|
265
|
+
if (!isAfterEach) {
|
|
266
|
+
_classPrivateFieldGet(_emitPreviousTestScope, this).call(this, context);
|
|
267
|
+
}
|
|
268
|
+
var scope = isEach ? context.testScope : last(context.suiteScopes);
|
|
269
|
+
if (scope) {
|
|
270
|
+
context.fixture = this.allureRuntime.startFixture(scope, position, {
|
|
271
|
+
name,
|
|
272
|
+
start,
|
|
273
|
+
status: undefined
|
|
105
274
|
});
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
_classPrivateFieldInitSpec(this, _stopHook, (context, _ref5) => {
|
|
278
|
+
var {
|
|
279
|
+
data: {
|
|
280
|
+
duration
|
|
281
|
+
}
|
|
282
|
+
} = _ref5;
|
|
283
|
+
var fixtureUuid = context.fixture;
|
|
284
|
+
if (fixtureUuid) {
|
|
285
|
+
this.allureRuntime.updateFixture(fixtureUuid, fixture => {
|
|
286
|
+
var _fixture$status;
|
|
287
|
+
(_fixture$status = fixture.status) !== null && _fixture$status !== void 0 ? _fixture$status : fixture.status = Status.PASSED;
|
|
288
|
+
});
|
|
289
|
+
this.allureRuntime.stopFixture(fixtureUuid, {
|
|
290
|
+
duration
|
|
122
291
|
});
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
var testUuid = this.allureRuntime.startTest({
|
|
131
|
-
name: titleMetadata.cleanTitle || testTitle,
|
|
132
|
-
start: message.data.start,
|
|
133
|
-
fullName: "".concat(message.data.filename, "#").concat(message.data.specPath.join(" ")),
|
|
134
|
-
stage: Stage.RUNNING,
|
|
135
|
-
labels: [{
|
|
136
|
-
name: LabelName.LANGUAGE,
|
|
137
|
-
value: "javascript"
|
|
138
|
-
}, {
|
|
139
|
-
name: LabelName.FRAMEWORK,
|
|
140
|
-
value: "cypress"
|
|
141
|
-
}, ...suiteLabels, ...titleMetadata.labels, ...getEnvironmentLabels()]
|
|
142
|
-
}, runContext.scopes);
|
|
143
|
-
runContext.executables.push(testUuid);
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
if (message.type === "cypress_test_end") {
|
|
147
|
-
var _testUuid = runContext.executables.pop();
|
|
148
|
-
this.allureRuntime.updateTest(_testUuid, result => {
|
|
149
|
-
result.stage = Stage.FINISHED;
|
|
150
|
-
result.status = message.data.status;
|
|
151
|
-
if (message.data.retries > 0) {
|
|
152
|
-
result.parameters.push({
|
|
153
|
-
name: "Retry",
|
|
154
|
-
value: message.data.retries.toString()
|
|
155
|
-
});
|
|
292
|
+
context.fixture = undefined;
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
_classPrivateFieldInitSpec(this, _startTest, (context, _ref6) => {
|
|
296
|
+
var {
|
|
297
|
+
data: {
|
|
298
|
+
fullNameSuffix
|
|
156
299
|
}
|
|
157
|
-
|
|
158
|
-
|
|
300
|
+
} = _ref6,
|
|
301
|
+
testResultData = _objectWithoutProperties(_ref6.data, _excluded);
|
|
302
|
+
_classPrivateFieldGet(_emitPreviousTestScope, this).call(this, context);
|
|
303
|
+
var testScope = this.allureRuntime.startScope();
|
|
304
|
+
context.testScope = testScope;
|
|
305
|
+
context.test = _classPrivateFieldGet(_addNewTestResult, this).call(this, context, fullNameSuffix, testResultData, [context.videoScope, ...context.suiteScopes, testScope]);
|
|
306
|
+
});
|
|
307
|
+
_classPrivateFieldInitSpec(this, _addNewTestResult, (context, fullNameSuffix, _ref7, scopes) => {
|
|
308
|
+
var {
|
|
309
|
+
labels: metadataLabels = []
|
|
310
|
+
} = _ref7,
|
|
311
|
+
otherTestData = _objectWithoutProperties(_ref7, _excluded2);
|
|
312
|
+
return this.allureRuntime.startTest(_objectSpread({
|
|
313
|
+
stage: Stage.RUNNING,
|
|
314
|
+
labels: [getLanguageLabel(), getFrameworkLabel("cypress"), ...getSuiteLabels(context.suiteNames), ...metadataLabels, ...getEnvironmentLabels(), getHostLabel(), getThreadLabel(), getPackageLabel(context.specPath)],
|
|
315
|
+
fullName: "".concat(getPosixPath(context.specPath), "#").concat(fullNameSuffix)
|
|
316
|
+
}, otherTestData), scopes);
|
|
317
|
+
});
|
|
318
|
+
_classPrivateFieldInitSpec(this, _failHookAndTest, (context, _ref8) => {
|
|
319
|
+
var {
|
|
320
|
+
data: {
|
|
321
|
+
status,
|
|
322
|
+
statusDetails
|
|
323
|
+
}
|
|
324
|
+
} = _ref8;
|
|
325
|
+
var setError = result => Object.assign(result, {
|
|
326
|
+
status,
|
|
327
|
+
statusDetails
|
|
328
|
+
});
|
|
329
|
+
var fixtureUuid = context.fixture;
|
|
330
|
+
if (fixtureUuid) {
|
|
331
|
+
this.allureRuntime.updateFixture(fixtureUuid, setError);
|
|
332
|
+
}
|
|
333
|
+
var testUuid = context.test;
|
|
334
|
+
if (testUuid) {
|
|
335
|
+
this.allureRuntime.updateTest(testUuid, setError);
|
|
336
|
+
}
|
|
337
|
+
context.failed = true;
|
|
338
|
+
});
|
|
339
|
+
_classPrivateFieldInitSpec(this, _passTest, context => {
|
|
340
|
+
var testUuid = context.test;
|
|
341
|
+
if (testUuid) {
|
|
342
|
+
this.allureRuntime.updateTest(testUuid, testResult => {
|
|
343
|
+
testResult.status = Status.PASSED;
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
_classPrivateFieldInitSpec(this, _skipTest, (context, _ref9) => {
|
|
348
|
+
var {
|
|
349
|
+
data: {
|
|
350
|
+
statusDetails
|
|
351
|
+
}
|
|
352
|
+
} = _ref9;
|
|
353
|
+
var testUuid = context.test;
|
|
354
|
+
if (testUuid) {
|
|
355
|
+
this.allureRuntime.updateTest(testUuid, testResult => {
|
|
356
|
+
testResult.status = Status.SKIPPED;
|
|
357
|
+
if (statusDetails) {
|
|
358
|
+
testResult.statusDetails = statusDetails;
|
|
159
359
|
}
|
|
160
|
-
result.statusDetails = message.data.statusDetails;
|
|
161
360
|
});
|
|
162
|
-
this.allureRuntime.stopTest(_testUuid);
|
|
163
|
-
this.allureRuntime.writeTest(_testUuid);
|
|
164
|
-
return;
|
|
165
361
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
362
|
+
});
|
|
363
|
+
_classPrivateFieldInitSpec(this, _addSkippedTest, (context, _ref10) => {
|
|
364
|
+
var {
|
|
365
|
+
data: {
|
|
366
|
+
fullNameSuffix,
|
|
367
|
+
suites,
|
|
368
|
+
duration,
|
|
369
|
+
retries
|
|
370
|
+
}
|
|
371
|
+
} = _ref10,
|
|
372
|
+
testResultData = _objectWithoutProperties(_ref10.data, _excluded3);
|
|
373
|
+
// Tests skipped because of a hook error may share all suites of the current context
|
|
374
|
+
// or just a part thereof (if it's from a sibling suite).
|
|
375
|
+
var scopes = suites.map(s => context.suiteIdToScope.get(s)).filter(s => Boolean(s));
|
|
376
|
+
var testUuid = _classPrivateFieldGet(_addNewTestResult, this).call(this, context, fullNameSuffix, testResultData, [context.videoScope, ...scopes]);
|
|
377
|
+
_classPrivateFieldGet(_stopExistingTestResult, this).call(this, testUuid, {
|
|
378
|
+
duration,
|
|
379
|
+
retries
|
|
380
|
+
});
|
|
381
|
+
this.allureRuntime.writeTest(testUuid);
|
|
382
|
+
});
|
|
383
|
+
_classPrivateFieldInitSpec(this, _stopTest, (context, _ref11) => {
|
|
384
|
+
var {
|
|
385
|
+
data
|
|
386
|
+
} = _ref11;
|
|
387
|
+
var testUuid = context.test;
|
|
388
|
+
if (testUuid) {
|
|
389
|
+
_classPrivateFieldGet(_stopExistingTestResult, this).call(this, testUuid, data);
|
|
390
|
+
this.allureRuntime.writeTest(testUuid);
|
|
391
|
+
context.test = undefined;
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
_classPrivateFieldInitSpec(this, _stopExistingTestResult, (testUuid, _ref12) => {
|
|
395
|
+
var {
|
|
396
|
+
retries,
|
|
397
|
+
duration
|
|
398
|
+
} = _ref12;
|
|
399
|
+
this.allureRuntime.updateTest(testUuid, testResult => {
|
|
400
|
+
if (retries > 0) {
|
|
401
|
+
testResult.parameters.push({
|
|
402
|
+
name: "Retry",
|
|
403
|
+
value: retries.toString(),
|
|
404
|
+
excluded: true
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
testResult.stage = Stage.FINISHED;
|
|
408
|
+
});
|
|
409
|
+
this.allureRuntime.stopTest(testUuid, {
|
|
410
|
+
duration
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
_classPrivateFieldInitSpec(this, _startCommand, (context, _ref13) => {
|
|
414
|
+
var {
|
|
415
|
+
data: {
|
|
416
|
+
name,
|
|
417
|
+
args
|
|
418
|
+
}
|
|
419
|
+
} = _ref13;
|
|
420
|
+
var rootUuid = _classPrivateFieldGet(_resolveRootUuid, this).call(this, context);
|
|
421
|
+
if (rootUuid) {
|
|
422
|
+
var stepUuid = this.allureRuntime.startStep(rootUuid, undefined, {
|
|
423
|
+
name,
|
|
424
|
+
parameters: args.map((arg, j) => ({
|
|
177
425
|
name: "Argument [".concat(j, "]"),
|
|
178
426
|
value: arg
|
|
179
427
|
}))
|
|
180
428
|
});
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
429
|
+
if (stepUuid) {
|
|
430
|
+
context.commandSteps.push(stepUuid);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
_classPrivateFieldInitSpec(this, _stopCommand, (context, _ref14) => {
|
|
435
|
+
var {
|
|
436
|
+
data: {
|
|
437
|
+
status,
|
|
438
|
+
statusDetails,
|
|
439
|
+
stop
|
|
440
|
+
}
|
|
441
|
+
} = _ref14;
|
|
442
|
+
var stepUuid = context.commandSteps.pop();
|
|
443
|
+
if (stepUuid) {
|
|
444
|
+
this.allureRuntime.updateStep(stepUuid, r => {
|
|
445
|
+
r.status = status;
|
|
446
|
+
if (statusDetails) {
|
|
447
|
+
r.statusDetails = statusDetails;
|
|
190
448
|
}
|
|
191
449
|
});
|
|
192
|
-
this.allureRuntime.stopStep(
|
|
193
|
-
|
|
450
|
+
this.allureRuntime.stopStep(stepUuid, {
|
|
451
|
+
stop
|
|
452
|
+
});
|
|
194
453
|
}
|
|
195
|
-
this.allureRuntime.applyRuntimeMessages(last(runContext.executables), [message]);
|
|
196
454
|
});
|
|
197
|
-
|
|
198
|
-
var
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
455
|
+
_classPrivateFieldInitSpec(this, _applyRuntimeApiMessages, (context, message) => {
|
|
456
|
+
var rootUuid = _classPrivateFieldGet(_resolveRootUuid, this).call(this, context);
|
|
457
|
+
if (rootUuid) {
|
|
458
|
+
this.allureRuntime.applyRuntimeMessages(rootUuid, [message]);
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
/**
|
|
462
|
+
* We must defer emitting a test's scope until we receive all the test's `afterEach` hooks.
|
|
463
|
+
* At the same time, we should report it as early as we can. That means we should call this
|
|
464
|
+
* method in the following cases:
|
|
465
|
+
* - when an `after` hook of the test starts (`after` hooks are called later than `afterEach`)
|
|
466
|
+
* - when a `before` or `beforeEach` hook of the next test starts (in case the next test has `before`/`beforeEach` hooks)
|
|
467
|
+
* - when the next test starts (in case the next test doesn't have `before`/`beforeEach` hooks)
|
|
468
|
+
* - when the test's suite ends (in case the test is the last one in its suite, including the root suite of the spec)
|
|
469
|
+
* - when a nested suite starts
|
|
470
|
+
* - when the spec ends
|
|
471
|
+
*/
|
|
472
|
+
_classPrivateFieldInitSpec(this, _emitPreviousTestScope, context => {
|
|
473
|
+
var testScope = context.testScope;
|
|
474
|
+
|
|
475
|
+
// Checking the test allows us to tell `beforeEach` and `afterEach` apart.
|
|
476
|
+
// Here we're interested in `afterEach` only.
|
|
477
|
+
if (!context.test && testScope) {
|
|
478
|
+
this.allureRuntime.writeScope(testScope);
|
|
479
|
+
context.testScope = undefined;
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
_classPrivateFieldInitSpec(this, _resolveRootUuid, context => {
|
|
483
|
+
var _context$fixture;
|
|
484
|
+
return (_context$fixture = context.fixture) !== null && _context$fixture !== void 0 ? _context$fixture : context.test;
|
|
485
|
+
});
|
|
486
|
+
_classPrivateFieldInitSpec(this, _attachSpecVideo, (context, cypressVideoPath) => {
|
|
487
|
+
var shouldVideoBeAttached = (!this.videoOnFailOnly || context.failed) && cypressVideoPath;
|
|
488
|
+
if (shouldVideoBeAttached) {
|
|
489
|
+
var fixtureUuid = this.allureRuntime.startFixture(context.videoScope, "after", {
|
|
490
|
+
name: "Cypress video",
|
|
491
|
+
status: Status.PASSED,
|
|
492
|
+
stage: Stage.FINISHED
|
|
493
|
+
});
|
|
494
|
+
this.allureRuntime.writeAttachment(fixtureUuid, undefined, "Cypress video", cypressVideoPath, {
|
|
495
|
+
contentType: ContentType.MP4
|
|
496
|
+
});
|
|
497
|
+
this.allureRuntime.stopFixture(fixtureUuid);
|
|
498
|
+
this.allureRuntime.writeScope(context.videoScope);
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
_classPrivateFieldInitSpec(this, _emitRemainingScopes, context => {
|
|
502
|
+
_classPrivateFieldGet(_emitPreviousTestScope, this).call(this, context);
|
|
503
|
+
context.suiteScopes.forEach(scope => {
|
|
504
|
+
this.allureRuntime.writeScope(scope);
|
|
229
505
|
});
|
|
230
|
-
}
|
|
231
|
-
this
|
|
506
|
+
});
|
|
507
|
+
_classPrivateFieldInitSpec(this, _initializeSpecContext, absolutePath => {
|
|
508
|
+
var specPath = getRelativePath(absolutePath);
|
|
509
|
+
var context = {
|
|
510
|
+
specPath,
|
|
511
|
+
test: undefined,
|
|
512
|
+
fixture: undefined,
|
|
513
|
+
commandSteps: [],
|
|
514
|
+
videoScope: this.allureRuntime.startScope(),
|
|
515
|
+
suiteIdToScope: new Map(),
|
|
516
|
+
suiteScopeToId: new Map(),
|
|
517
|
+
suiteScopes: [],
|
|
518
|
+
testScope: undefined,
|
|
519
|
+
suiteNames: [],
|
|
520
|
+
failed: false
|
|
521
|
+
};
|
|
522
|
+
this.specContextByAbsolutePath.set(absolutePath, context);
|
|
523
|
+
});
|
|
524
|
+
var {
|
|
525
|
+
resultsDir,
|
|
526
|
+
videoOnFailOnly = false
|
|
527
|
+
} = config,
|
|
528
|
+
rest = _objectWithoutProperties(config, _excluded4);
|
|
529
|
+
this.videoOnFailOnly = videoOnFailOnly;
|
|
530
|
+
this.allureRuntime = new ReporterRuntime(_objectSpread({
|
|
531
|
+
writer: createDefaultWriter({
|
|
532
|
+
resultsDir
|
|
533
|
+
})
|
|
534
|
+
}, rest));
|
|
232
535
|
}
|
|
233
536
|
}
|
|
234
|
-
|
|
537
|
+
var createRuntimeState = allureConfig => ({
|
|
538
|
+
config: getRuntimeConfigDefaults(allureConfig),
|
|
539
|
+
initialized: false,
|
|
540
|
+
messages: [],
|
|
541
|
+
testPlan: parseTestPlan(),
|
|
542
|
+
projectDir: getProjectRoot()
|
|
543
|
+
});
|
|
544
|
+
var getRuntimeConfigDefaults = function getRuntimeConfigDefaults() {
|
|
545
|
+
var {
|
|
546
|
+
stepsFromCommands: {
|
|
547
|
+
maxArgumentLength = DEFAULT_RUNTIME_CONFIG.stepsFromCommands.maxArgumentLength,
|
|
548
|
+
maxArgumentDepth = DEFAULT_RUNTIME_CONFIG.stepsFromCommands.maxArgumentDepth
|
|
549
|
+
} = DEFAULT_RUNTIME_CONFIG.stepsFromCommands
|
|
550
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_RUNTIME_CONFIG;
|
|
551
|
+
return {
|
|
552
|
+
stepsFromCommands: {
|
|
553
|
+
maxArgumentDepth,
|
|
554
|
+
maxArgumentLength
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
};
|
|
558
|
+
var initializeRuntimeState = (cypressConfig, allureConfig) => {
|
|
559
|
+
cypressConfig.env.allure = createRuntimeState(allureConfig);
|
|
560
|
+
return cypressConfig;
|
|
561
|
+
};
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Sets up Allure Cypress.
|
|
565
|
+
* @param on The function used to subscribe to Cypress Node events (it's the first argument of `setupNodeEvents`).
|
|
566
|
+
* @param cypressConfig The Cypress configuration (the second argument of `setupNodeEvents`). If provided, the selective run feature will be enabled.
|
|
567
|
+
* @param allureConfig An Allure configuration object (optional).
|
|
568
|
+
* @example
|
|
569
|
+
* ```javascript
|
|
570
|
+
* import { defineConfig } from "cypress";
|
|
571
|
+
* import { allureCypress } from "allure-cypress/reporter";
|
|
572
|
+
*
|
|
573
|
+
* export default defineConfig({
|
|
574
|
+
* e2e: {
|
|
575
|
+
* setupNodeEvents: (on, config) => {
|
|
576
|
+
* allureCypress(on, config, { videoOnFailOnly: true });
|
|
577
|
+
* return config;
|
|
578
|
+
* },
|
|
579
|
+
* // ...
|
|
580
|
+
* }
|
|
581
|
+
* });
|
|
582
|
+
* ```
|
|
583
|
+
*/
|
|
584
|
+
export var allureCypress = (on, cypressConfig, allureConfig) => {
|
|
585
|
+
// Backward compatibility; mainly for JS users who have no type hints
|
|
586
|
+
if (!allureConfig && cypressConfig && !("env" in cypressConfig)) {
|
|
587
|
+
allureConfig = cypressConfig;
|
|
588
|
+
}
|
|
589
|
+
var hasCypressConfig = cypressConfig && "env" in cypressConfig;
|
|
235
590
|
var allureCypressReporter = new AllureCypress(allureConfig);
|
|
236
591
|
allureCypressReporter.attachToCypress(on);
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
592
|
+
if (hasCypressConfig) {
|
|
593
|
+
initializeRuntimeState(cypressConfig, allureConfig);
|
|
594
|
+
}
|
|
240
595
|
return allureCypressReporter;
|
|
241
596
|
};
|
|
242
597
|
//# sourceMappingURL=reporter.js.map
|