allure-cucumberjs 2.0.0-beta.2 → 2.0.0-beta.21
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/LICENSE.txt +1 -1
- package/README.md +160 -43
- package/dist/index.d.ts +3 -0
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/src/CucumberAllureWorld.d.ts +77 -0
- package/dist/src/CucumberAllureWorld.js +220 -0
- package/dist/src/CucumberAllureWorld.js.map +1 -0
- package/dist/src/CucumberJSAllureReporter.d.ts +59 -0
- package/dist/src/CucumberJSAllureReporter.js +395 -283
- package/dist/src/CucumberJSAllureReporter.js.map +1 -1
- package/package.json +36 -14
- package/dist/declarations/index.d.ts +0 -2
- package/dist/declarations/src/CucumberAllureInterface.d.ts +0 -35
- package/dist/declarations/src/CucumberJSAllureReporter.d.ts +0 -75
- package/dist/declarations/src/events/Example.d.ts +0 -8
- package/dist/declarations/src/events/GherkinDocument.d.ts +0 -17
- package/dist/declarations/src/events/GherkinExample.d.ts +0 -15
- package/dist/declarations/src/events/GherkinStep.d.ts +0 -17
- package/dist/declarations/src/events/GherkinTestCase.d.ts +0 -18
- package/dist/declarations/src/events/Result.d.ts +0 -5
- package/dist/declarations/src/events/SourceLocation.d.ts +0 -11
- package/dist/declarations/src/events/TestHookDefinition.d.ts +0 -8
- package/dist/declarations/src/utilities.d.ts +0 -7
- package/dist/src/CucumberAllureInterface.js +0 -148
- package/dist/src/CucumberAllureInterface.js.map +0 -1
- package/dist/src/events/Example.js +0 -28
- package/dist/src/events/Example.js.map +0 -1
- package/dist/src/events/GherkinDocument.js +0 -10
- package/dist/src/events/GherkinDocument.js.map +0 -1
- package/dist/src/events/GherkinExample.js +0 -9
- package/dist/src/events/GherkinExample.js.map +0 -1
- package/dist/src/events/GherkinStep.js +0 -9
- package/dist/src/events/GherkinStep.js.map +0 -1
- package/dist/src/events/GherkinTestCase.js +0 -11
- package/dist/src/events/GherkinTestCase.js.map +0 -1
- package/dist/src/events/Result.js +0 -9
- package/dist/src/events/Result.js.map +0 -1
- package/dist/src/events/SourceLocation.js +0 -12
- package/dist/src/events/SourceLocation.js.map +0 -1
- package/dist/src/events/TestHookDefinition.js +0 -3
- package/dist/src/events/TestHookDefinition.js.map +0 -1
- package/dist/src/utilities.js +0 -49
- package/dist/src/utilities.js.map +0 -1
|
@@ -1,315 +1,427 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
22
|
+
var t = {};
|
|
23
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
24
|
+
t[p] = s[p];
|
|
25
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
26
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
27
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
28
|
+
t[p[i]] = s[p[i]];
|
|
29
|
+
}
|
|
30
|
+
return t;
|
|
31
|
+
};
|
|
32
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
34
|
};
|
|
26
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
exports
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}());
|
|
36
|
+
exports.CucumberJSAllureFormatter = exports.CucumberJSAllureFormatterConfig = exports.Allure = void 0;
|
|
37
|
+
const os_1 = __importDefault(require("os"));
|
|
38
|
+
const process_1 = __importDefault(require("process"));
|
|
39
|
+
const cucumber_1 = require("@cucumber/cucumber");
|
|
40
|
+
const messages = __importStar(require("@cucumber/messages"));
|
|
41
|
+
const messages_1 = require("@cucumber/messages");
|
|
42
|
+
const allure_js_commons_1 = require("allure-js-commons");
|
|
43
|
+
Object.defineProperty(exports, "Allure", { enumerable: true, get: function () { return allure_js_commons_1.Allure; } });
|
|
44
|
+
const internal_1 = require("allure-js-commons/internal");
|
|
45
|
+
const CucumberAllureWorld_1 = require("./CucumberAllureWorld");
|
|
46
|
+
class CucumberJSAllureFormatterConfig {
|
|
47
|
+
}
|
|
40
48
|
exports.CucumberJSAllureFormatterConfig = CucumberJSAllureFormatterConfig;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
49
|
+
const { ALLURE_HOST_NAME, ALLURE_THREAD_NAME } = process_1.default.env;
|
|
50
|
+
class CucumberJSAllureFormatter extends cucumber_1.Formatter {
|
|
51
|
+
constructor(options, allureRuntime, config) {
|
|
52
|
+
super(options);
|
|
53
|
+
this.allureRuntime = allureRuntime;
|
|
54
|
+
this.currentTestsMap = new Map();
|
|
55
|
+
this.hostname = ALLURE_HOST_NAME || os_1.default.hostname();
|
|
56
|
+
this.documentMap = new Map();
|
|
57
|
+
this.scenarioMap = new Map();
|
|
58
|
+
this.stepMap = new Map();
|
|
59
|
+
this.testStepMap = new Map();
|
|
60
|
+
this.pickleStepMap = new Map();
|
|
61
|
+
this.testCaseTestStepsResults = new Map();
|
|
62
|
+
this.pickleMap = new Map();
|
|
63
|
+
this.hookMap = new Map();
|
|
64
|
+
this.sourceMap = new Map();
|
|
65
|
+
this.testCaseMap = new Map();
|
|
66
|
+
this.testCaseStartedMap = new Map();
|
|
67
|
+
this.allureSteps = new Map();
|
|
68
|
+
this.convertStatus = (status) => {
|
|
69
|
+
switch (status) {
|
|
70
|
+
case messages_1.TestStepResultStatus.FAILED:
|
|
71
|
+
return allure_js_commons_1.Status.FAILED;
|
|
72
|
+
case messages_1.TestStepResultStatus.PASSED:
|
|
73
|
+
return allure_js_commons_1.Status.PASSED;
|
|
74
|
+
case messages_1.TestStepResultStatus.SKIPPED:
|
|
75
|
+
case messages_1.TestStepResultStatus.PENDING:
|
|
76
|
+
return allure_js_commons_1.Status.SKIPPED;
|
|
77
|
+
default:
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
options.eventBroadcaster.on("envelope", this.parseEnvelope.bind(this));
|
|
82
|
+
this.labelsMathers = config.labels || [];
|
|
83
|
+
this.linksMatchers = config.links || [];
|
|
84
|
+
this.exceptionFormatter = (message) => {
|
|
65
85
|
if (config.exceptionFormatter !== undefined) {
|
|
66
86
|
try {
|
|
67
87
|
return config.exceptionFormatter(message);
|
|
68
88
|
}
|
|
69
89
|
catch (e) {
|
|
70
|
-
console.warn(
|
|
90
|
+
console.warn(`Error in exceptionFormatter: ${e}`);
|
|
71
91
|
}
|
|
72
92
|
}
|
|
73
93
|
return message;
|
|
74
94
|
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
95
|
+
if (options.supportCodeLibrary.World === cucumber_1.World) {
|
|
96
|
+
options.supportCodeLibrary.World = CucumberAllureWorld_1.CucumberAllureWorld;
|
|
97
|
+
}
|
|
98
|
+
this.beforeHooks = options.supportCodeLibrary.beforeTestCaseHookDefinitions;
|
|
99
|
+
this.afterHooks = options.supportCodeLibrary.afterTestCaseHookDefinitions;
|
|
80
100
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
for (var _i = 0, _a = data.document.feature.children || []; _i < _a.length; _i++) {
|
|
89
|
-
var test = _a[_i];
|
|
90
|
-
test.stepMap = new Map();
|
|
91
|
-
if (test.type === "Background") {
|
|
92
|
-
data.document.stepMap = new Map();
|
|
93
|
-
for (var _b = 0, _c = test.steps; _b < _c.length; _b++) {
|
|
94
|
-
var step = _c[_b];
|
|
95
|
-
step.isBackground = true;
|
|
96
|
-
data.document.stepMap.set(step.location.line, step);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
for (var _d = 0, _e = test.steps; _d < _e.length; _d++) {
|
|
101
|
-
var step = _e[_d];
|
|
102
|
-
test.stepMap.set(step.location.line, step);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
if (test.type === "ScenarioOutline") {
|
|
106
|
-
for (var _f = 0, _g = Example_1.examplesToSensibleFormat(test.examples || []); _f < _g.length; _f++) {
|
|
107
|
-
var example = _g[_f];
|
|
108
|
-
var copy = __assign({}, test);
|
|
109
|
-
copy.example = example;
|
|
110
|
-
data.document.caseMap.set(example.line, copy);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
data.document.caseMap.set(test.location.line, test);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
101
|
+
get tagsIgnorePatterns() {
|
|
102
|
+
const { linksMatchers, labelsMathers } = this;
|
|
103
|
+
return [...linksMatchers, ...labelsMathers].flatMap(({ pattern }) => pattern);
|
|
104
|
+
}
|
|
105
|
+
parseEnvelope(envelope) {
|
|
106
|
+
if (envelope.gherkinDocument) {
|
|
107
|
+
this.onGherkinDocument(envelope.gherkinDocument);
|
|
117
108
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
CucumberJSAllureFormatter.prototype.onTestCasePrepared = function (data) {
|
|
121
|
-
this.stepsMap.clear();
|
|
122
|
-
this.stepsMap.set(SourceLocation_1.SourceLocation.toKey(data), data.steps);
|
|
123
|
-
this.currentBefore = null;
|
|
124
|
-
this.currentAfter = null;
|
|
125
|
-
};
|
|
126
|
-
CucumberJSAllureFormatter.prototype.onTestCaseStarted = function (data) {
|
|
127
|
-
var feature = this.featureMap.get(data.sourceLocation.uri);
|
|
128
|
-
if (feature === undefined || feature.feature === undefined) {
|
|
129
|
-
throw new Error("Unknown feature");
|
|
130
|
-
}
|
|
131
|
-
var test = feature.caseMap === undefined
|
|
132
|
-
? undefined : feature.caseMap.get(data.sourceLocation.line);
|
|
133
|
-
if (test === undefined) {
|
|
134
|
-
throw new Error("Unknown scenario");
|
|
135
|
-
}
|
|
136
|
-
this.currentGroup = this.allureRuntime.startGroup("");
|
|
137
|
-
this.currentTest =
|
|
138
|
-
this.currentGroup.startTest(utilities_1.applyExample(test.name || "Unnamed test", test.example));
|
|
139
|
-
var info = {
|
|
140
|
-
f: feature.feature.name,
|
|
141
|
-
t: test.name,
|
|
142
|
-
a: null
|
|
143
|
-
};
|
|
144
|
-
if (test.example !== undefined) {
|
|
145
|
-
info.a = test.example.arguments;
|
|
146
|
-
for (var prop in test.example.arguments) {
|
|
147
|
-
if (!test.example.arguments.hasOwnProperty(prop))
|
|
148
|
-
continue;
|
|
149
|
-
this.currentTest.addParameter(prop, test.example.arguments[prop]);
|
|
150
|
-
}
|
|
109
|
+
else if (envelope.pickle) {
|
|
110
|
+
this.onPickle(envelope.pickle);
|
|
151
111
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
this.currentTest.addLabel(allure_js_commons_1.LabelName.FEATURE, feature.feature.name);
|
|
155
|
-
this.currentTest.description = utilities_1.stripIndent(test.description || "");
|
|
156
|
-
for (var _i = 0, _a = (test.tags || []).concat(feature.feature.tags); _i < _a.length; _i++) {
|
|
157
|
-
var tag = _a[_i];
|
|
158
|
-
this.currentTest.addLabel(allure_js_commons_1.LabelName.TAG, tag.name);
|
|
159
|
-
for (var label in this.labels) {
|
|
160
|
-
if (!this.labels.hasOwnProperty(label))
|
|
161
|
-
continue;
|
|
162
|
-
for (var _b = 0, _c = this.labels[label]; _b < _c.length; _b++) {
|
|
163
|
-
var reg = _c[_b];
|
|
164
|
-
var match = tag.name.match(reg);
|
|
165
|
-
if (match != null && match.length > 1) {
|
|
166
|
-
this.currentTest.addLabel(label, match[1]);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
112
|
+
else if (envelope.testCase) {
|
|
113
|
+
this.onTestCase(envelope.testCase);
|
|
170
114
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
var location = (this.stepsMap.get(SourceLocation_1.SourceLocation.toKey(data.testCase)) || [])[data.index];
|
|
174
|
-
var feature = this.featureMap.get(data.testCase.sourceLocation.uri);
|
|
175
|
-
if (feature === undefined)
|
|
176
|
-
throw new Error("Unknown feature");
|
|
177
|
-
var test = feature.caseMap === undefined
|
|
178
|
-
? undefined : feature.caseMap.get(data.testCase.sourceLocation.line);
|
|
179
|
-
if (test === undefined)
|
|
180
|
-
throw new Error("Unknown scenario");
|
|
181
|
-
var step;
|
|
182
|
-
if (location.sourceLocation !== undefined && feature.stepMap !== undefined) {
|
|
183
|
-
step = test.stepMap.get(location.sourceLocation.line)
|
|
184
|
-
|| feature.stepMap.get(location.sourceLocation.line);
|
|
115
|
+
else if (envelope.testCaseStarted) {
|
|
116
|
+
this.onTestCaseStarted(envelope.testCaseStarted);
|
|
185
117
|
}
|
|
186
|
-
else {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
118
|
+
else if (envelope.testCaseFinished) {
|
|
119
|
+
this.onTestCaseFinished(envelope.testCaseFinished);
|
|
120
|
+
}
|
|
121
|
+
else if (envelope.attachment) {
|
|
122
|
+
this.onAttachment(envelope.attachment);
|
|
123
|
+
}
|
|
124
|
+
else if (envelope.hook) {
|
|
125
|
+
this.onHook(envelope.hook);
|
|
126
|
+
}
|
|
127
|
+
else if (envelope.source) {
|
|
128
|
+
this.onSource(envelope.source);
|
|
129
|
+
}
|
|
130
|
+
else if (envelope.testStepStarted) {
|
|
131
|
+
this.onTestStepStarted(envelope.testStepStarted);
|
|
132
|
+
}
|
|
133
|
+
else if (envelope.testStepFinished) {
|
|
134
|
+
this.onTestStepFinished(envelope.testStepFinished);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
parseTagsLabels(tags) {
|
|
138
|
+
const labels = [];
|
|
139
|
+
if (this.labelsMathers.length === 0) {
|
|
140
|
+
return labels;
|
|
141
|
+
}
|
|
142
|
+
this.labelsMathers.forEach((matcher) => {
|
|
143
|
+
const matchedTags = tags.filter((tag) => matcher.pattern.some((pattern) => pattern.test(tag.name)));
|
|
144
|
+
const matchedLabels = matchedTags.map((tag) => {
|
|
145
|
+
const tagValue = tag.name.replace(/^@\S+:/, "");
|
|
146
|
+
return {
|
|
147
|
+
name: matcher.name,
|
|
148
|
+
value: tagValue,
|
|
191
149
|
};
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
150
|
+
});
|
|
151
|
+
labels.push(...matchedLabels);
|
|
152
|
+
});
|
|
153
|
+
return labels;
|
|
154
|
+
}
|
|
155
|
+
parseTagsLinks(tags) {
|
|
156
|
+
const tagKeyRe = /^@\S+=/;
|
|
157
|
+
const links = [];
|
|
158
|
+
if (this.linksMatchers.length === 0) {
|
|
159
|
+
return links;
|
|
197
160
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
161
|
+
this.linksMatchers.forEach((matcher) => {
|
|
162
|
+
const matchedTags = tags.filter((tag) => matcher.pattern.some((pattern) => pattern.test(tag.name)));
|
|
163
|
+
const matchedLinks = matchedTags.map((tag) => {
|
|
164
|
+
const tagValue = tag.name.replace(tagKeyRe, "");
|
|
165
|
+
return {
|
|
166
|
+
url: matcher.urlTemplate.replace(/%s$/, tagValue) || tagValue,
|
|
167
|
+
type: matcher.type,
|
|
168
|
+
};
|
|
169
|
+
});
|
|
170
|
+
links.push(...matchedLinks);
|
|
207
171
|
});
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
172
|
+
return links;
|
|
173
|
+
}
|
|
174
|
+
onGherkinDocument(data) {
|
|
175
|
+
var _a, _b;
|
|
176
|
+
if (data.uri) {
|
|
177
|
+
this.documentMap.set(data.uri, data);
|
|
178
|
+
}
|
|
179
|
+
(_b = (_a = data.feature) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.forEach((fc) => {
|
|
180
|
+
if (fc.scenario) {
|
|
181
|
+
this.onScenario(fc.scenario);
|
|
182
|
+
}
|
|
214
183
|
});
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
184
|
+
}
|
|
185
|
+
onScenario(data) {
|
|
186
|
+
this.scenarioMap.set(data.id, data);
|
|
187
|
+
data.steps.forEach((step) => this.stepMap.set(step.id, step));
|
|
188
|
+
}
|
|
189
|
+
onPickle(data) {
|
|
190
|
+
this.pickleMap.set(data.id, data);
|
|
191
|
+
data.steps.forEach((ps) => this.pickleStepMap.set(ps.id, ps));
|
|
192
|
+
}
|
|
193
|
+
onTestCase(data) {
|
|
194
|
+
this.testCaseMap.set(data.id, data);
|
|
195
|
+
data.testSteps.forEach((ts) => this.testStepMap.set(ts.id, ts));
|
|
196
|
+
}
|
|
197
|
+
onTestCaseStarted(data) {
|
|
198
|
+
var _a, _b, _c;
|
|
199
|
+
const testCase = this.testCaseMap.get(data.testCaseId);
|
|
200
|
+
if (!testCase) {
|
|
201
|
+
console.error("onTestCaseStarted", "test case not found", data);
|
|
202
|
+
return;
|
|
218
203
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
204
|
+
const pickle = this.pickleMap.get(testCase.pickleId);
|
|
205
|
+
if (!pickle) {
|
|
206
|
+
console.error("onTestCaseStarted", "pickle not found", data);
|
|
207
|
+
return;
|
|
223
208
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
209
|
+
const doc = this.documentMap.get(pickle.uri);
|
|
210
|
+
const scenarioId = (_a = pickle === null || pickle === void 0 ? void 0 : pickle.astNodeIds) === null || _a === void 0 ? void 0 : _a[0];
|
|
211
|
+
const scenario = this.scenarioMap.get(scenarioId);
|
|
212
|
+
const labels = this.parseTagsLabels((scenario === null || scenario === void 0 ? void 0 : scenario.tags) || []);
|
|
213
|
+
const links = this.parseTagsLinks((scenario === null || scenario === void 0 ? void 0 : scenario.tags) || []);
|
|
214
|
+
const currentTest = new allure_js_commons_1.AllureTest(this.allureRuntime, Date.now());
|
|
215
|
+
const thread = data.workerId || ALLURE_THREAD_NAME || process_1.default.pid.toString();
|
|
216
|
+
this.testCaseStartedMap.set(data.id, data);
|
|
217
|
+
this.testCaseTestStepsResults.set(data.id, []);
|
|
218
|
+
this.currentTestsMap.set(data.id, currentTest);
|
|
219
|
+
const fullName = `${pickle.uri}#${pickle.name}`;
|
|
220
|
+
const testCaseId = (0, allure_js_commons_1.md5)(fullName);
|
|
221
|
+
currentTest.name = pickle.name;
|
|
222
|
+
currentTest.fullName = fullName;
|
|
223
|
+
currentTest.testCaseId = testCaseId;
|
|
224
|
+
currentTest.historyId = testCaseId;
|
|
225
|
+
currentTest.addLabel(allure_js_commons_1.LabelName.HOST, this.hostname);
|
|
226
|
+
currentTest.addLabel(allure_js_commons_1.LabelName.LANGUAGE, "javascript");
|
|
227
|
+
currentTest.addLabel(allure_js_commons_1.LabelName.FRAMEWORK, "cucumberjs");
|
|
228
|
+
currentTest.addLabel(allure_js_commons_1.LabelName.THREAD, thread);
|
|
229
|
+
labels.forEach((label) => currentTest.addLabel(label.name, label.value));
|
|
230
|
+
links.forEach((link) => currentTest.addLink(link.url, link.name, link.type));
|
|
231
|
+
if (doc === null || doc === void 0 ? void 0 : doc.feature) {
|
|
232
|
+
currentTest.addLabel(allure_js_commons_1.LabelName.FEATURE, doc.feature.name);
|
|
228
233
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
234
|
+
if (scenario) {
|
|
235
|
+
currentTest.addLabel(allure_js_commons_1.LabelName.SUITE, scenario.name);
|
|
236
|
+
}
|
|
237
|
+
if ((_b = pickle.tags) === null || _b === void 0 ? void 0 : _b.length) {
|
|
238
|
+
const filteredTags = pickle.tags.filter((tag) => !this.tagsIgnorePatterns.some((pattern) => pattern.test(tag.name)));
|
|
239
|
+
filteredTags.forEach((tag) => currentTest.addLabel(allure_js_commons_1.LabelName.TAG, tag.name));
|
|
240
|
+
}
|
|
241
|
+
if (!((_c = scenario === null || scenario === void 0 ? void 0 : scenario.examples) === null || _c === void 0 ? void 0 : _c.length)) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
scenario.examples.forEach((example) => {
|
|
245
|
+
var _a;
|
|
246
|
+
const csvDataTableHeader = ((_a = example === null || example === void 0 ? void 0 : example.tableHeader) === null || _a === void 0 ? void 0 : _a.cells.map((cell) => cell.value).join(",")) || "";
|
|
247
|
+
const csvDataTableBody = (example === null || example === void 0 ? void 0 : example.tableBody.map((row) => row.cells.map((cell) => cell.value).join(",")).join("\n")) ||
|
|
248
|
+
"";
|
|
249
|
+
if (!csvDataTableHeader && !csvDataTableBody) {
|
|
250
|
+
return;
|
|
245
251
|
}
|
|
252
|
+
const csvDataTable = `${csvDataTableHeader}\n${csvDataTableBody}\n`;
|
|
253
|
+
const attachmentFilename = this.allureRuntime.writeAttachment(csvDataTable, allure_js_commons_1.ContentType.CSV);
|
|
254
|
+
currentTest.addAttachment("Examples", {
|
|
255
|
+
contentType: allure_js_commons_1.ContentType.CSV,
|
|
256
|
+
}, attachmentFilename);
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
onAttachment(data) {
|
|
260
|
+
const currentTest = this.currentTestsMap.get((data === null || data === void 0 ? void 0 : data.testCaseStartedId) || "");
|
|
261
|
+
if (!currentTest) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
const currentStep = this.allureSteps.get((data === null || data === void 0 ? void 0 : data.testStepId) || "");
|
|
265
|
+
if (!data) {
|
|
266
|
+
console.error("onAttachment", "attachment can't be empty");
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
const { fileName = "attachment", body, mediaType, contentEncoding } = data;
|
|
270
|
+
if (mediaType === internal_1.ALLURE_METADATA_CONTENT_TYPE) {
|
|
271
|
+
this.handleAllureAttachment({
|
|
272
|
+
test: currentTest,
|
|
273
|
+
step: currentStep,
|
|
274
|
+
metadata: JSON.parse(body),
|
|
275
|
+
});
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
const encoding = Buffer.isEncoding(contentEncoding) ? contentEncoding : undefined;
|
|
279
|
+
const attachmentFilename = this.allureRuntime.writeAttachment(body, mediaType, encoding);
|
|
280
|
+
currentTest.addAttachment(fileName, {
|
|
281
|
+
contentType: mediaType,
|
|
282
|
+
}, attachmentFilename);
|
|
283
|
+
}
|
|
284
|
+
handleAllureAttachment(payload) {
|
|
285
|
+
const { labels = [], links = [], parameter = [], categories = [], step, description, descriptionHtml, environmentInfo, } = payload.metadata;
|
|
286
|
+
if (links.length > 0) {
|
|
287
|
+
links.forEach((link) => payload.test.addLink(link.url, link.type, link.name));
|
|
288
|
+
}
|
|
289
|
+
if (labels.length > 0) {
|
|
290
|
+
labels.forEach((label) => payload.test.addLabel(label.name, label.value));
|
|
291
|
+
}
|
|
292
|
+
if (parameter.length > 0) {
|
|
293
|
+
parameter.forEach(({ name, value, hidden, excluded }) => payload.test.addParameter(name, value, {
|
|
294
|
+
excluded,
|
|
295
|
+
hidden,
|
|
296
|
+
}));
|
|
297
|
+
}
|
|
298
|
+
if (categories.length > 0) {
|
|
299
|
+
this.allureRuntime.writeCategoriesDefinitions(categories);
|
|
300
|
+
}
|
|
301
|
+
if (description) {
|
|
302
|
+
payload.test.description = description;
|
|
303
|
+
}
|
|
304
|
+
if (descriptionHtml) {
|
|
305
|
+
payload.test.descriptionHtml = descriptionHtml;
|
|
306
|
+
}
|
|
307
|
+
if (environmentInfo) {
|
|
308
|
+
this.allureRuntime.writeEnvironmentInfo(environmentInfo);
|
|
309
|
+
}
|
|
310
|
+
if (step) {
|
|
311
|
+
this.handleAllureStep({
|
|
312
|
+
test: payload.test,
|
|
313
|
+
step: payload.step,
|
|
314
|
+
metadata: step,
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
handleAllureStep(payload) {
|
|
319
|
+
const _a = payload.metadata, { attachments: metadataAttachments } = _a, metadata = __rest(_a, ["attachments"]);
|
|
320
|
+
const attachments = metadataAttachments.map(({ name, type, content }) => {
|
|
321
|
+
const attachmentFilename = this.allureRuntime.writeAttachment(content, type, "base64");
|
|
322
|
+
return {
|
|
323
|
+
source: attachmentFilename,
|
|
324
|
+
name,
|
|
325
|
+
type,
|
|
326
|
+
};
|
|
327
|
+
});
|
|
328
|
+
const testStep = Object.assign(Object.assign({}, metadata), { attachments, steps: [] });
|
|
329
|
+
if (payload.step) {
|
|
330
|
+
payload.step.addStep(testStep);
|
|
331
|
+
return;
|
|
246
332
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
if (
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
this.
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
333
|
+
payload.test.addStep(testStep);
|
|
334
|
+
}
|
|
335
|
+
onTestCaseFinished(data) {
|
|
336
|
+
const currentTest = this.currentTestsMap.get(data.testCaseStartedId);
|
|
337
|
+
if (!currentTest) {
|
|
338
|
+
console.error("onTestCaseFinished", "current test not found", data);
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
const testCaseStarted = this.testCaseStartedMap.get(data.testCaseStartedId);
|
|
342
|
+
if (!testCaseStarted) {
|
|
343
|
+
console.error("onTestCaseFinished", "testCaseStarted event not found", data);
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
const testCase = this.testCaseMap.get(testCaseStarted.testCaseId);
|
|
347
|
+
if (!testCase) {
|
|
348
|
+
console.error("onTestCaseFinished", "testCase not found", data);
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
const pickle = this.pickleMap.get(testCase.pickleId);
|
|
352
|
+
if (!pickle) {
|
|
353
|
+
console.error("onTestCaseFinished", "pickle not found", data);
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
const testStepResults = this.testCaseTestStepsResults.get(testCaseStarted.id);
|
|
357
|
+
if (testStepResults === null || testStepResults === void 0 ? void 0 : testStepResults.length) {
|
|
358
|
+
const worstTestStepResult = messages.getWorstTestStepResult(testStepResults);
|
|
359
|
+
currentTest.status = this.convertStatus(worstTestStepResult.status);
|
|
360
|
+
currentTest.statusDetails = {
|
|
361
|
+
message: worstTestStepResult.message,
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
currentTest.status = allure_js_commons_1.Status.PASSED;
|
|
366
|
+
}
|
|
367
|
+
currentTest.endTest(Date.now());
|
|
368
|
+
this.currentTestsMap.delete(data.testCaseStartedId);
|
|
369
|
+
}
|
|
370
|
+
onHook(data) {
|
|
371
|
+
this.hookMap.set(data.id, data);
|
|
372
|
+
}
|
|
373
|
+
onSource(data) {
|
|
374
|
+
if (data.uri) {
|
|
375
|
+
this.sourceMap.set(data.uri, data);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
onTestStepStarted(data) {
|
|
379
|
+
const currentTest = this.currentTestsMap.get(data.testCaseStartedId);
|
|
380
|
+
if (!currentTest) {
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
const testStep = this.testStepMap.get(data.testStepId);
|
|
384
|
+
if (!testStep) {
|
|
385
|
+
console.error("onTestStepStarted", "can't find step", data);
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
if (testStep.pickleStepId) {
|
|
389
|
+
const ps = this.pickleStepMap.get(testStep.pickleStepId);
|
|
390
|
+
if (!ps) {
|
|
391
|
+
return;
|
|
283
392
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
393
|
+
const keyword = ps.astNodeIds
|
|
394
|
+
.map((astNodeId) => this.stepMap.get(astNodeId))
|
|
395
|
+
.map((step) => step === null || step === void 0 ? void 0 : step.keyword)
|
|
396
|
+
.find((kw) => kw !== undefined) || "";
|
|
397
|
+
const allureStep = currentTest.startStep(keyword + ps.text, Date.now());
|
|
398
|
+
this.allureSteps.set(data.testStepId, allureStep);
|
|
399
|
+
const { argument } = ps;
|
|
400
|
+
if (!(argument === null || argument === void 0 ? void 0 : argument.dataTable)) {
|
|
401
|
+
return;
|
|
288
402
|
}
|
|
403
|
+
const csvDataTable = argument.dataTable.rows.reduce((acc, row) => `${acc + row.cells.map((cell) => cell.value).join(",")}\n`, "");
|
|
404
|
+
const attachmentFilename = this.allureRuntime.writeAttachment(csvDataTable, allure_js_commons_1.ContentType.CSV);
|
|
405
|
+
allureStep.addAttachment("Data table", {
|
|
406
|
+
contentType: allure_js_commons_1.ContentType.CSV,
|
|
407
|
+
}, attachmentFilename);
|
|
289
408
|
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
return this.allureRuntime.writeAttachment(content, type);
|
|
308
|
-
};
|
|
309
|
-
CucumberJSAllureFormatter.prototype.getGlobalInfoWriter = function () {
|
|
310
|
-
return this.allureRuntime;
|
|
311
|
-
};
|
|
312
|
-
return CucumberJSAllureFormatter;
|
|
313
|
-
}(cucumber_1.Formatter));
|
|
409
|
+
}
|
|
410
|
+
onTestStepFinished(data) {
|
|
411
|
+
var _a;
|
|
412
|
+
const currentTest = this.currentTestsMap.get(data.testCaseStartedId);
|
|
413
|
+
(_a = this.testCaseTestStepsResults.get(data.testCaseStartedId)) === null || _a === void 0 ? void 0 : _a.push(data.testStepResult);
|
|
414
|
+
if (!currentTest) {
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
const allureStep = this.allureSteps.get(data.testStepId);
|
|
418
|
+
if (!allureStep) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
allureStep.detailsMessage = data.testStepResult.message;
|
|
422
|
+
allureStep.status = this.convertStatus(data.testStepResult.status);
|
|
423
|
+
allureStep.endStep(Date.now());
|
|
424
|
+
}
|
|
425
|
+
}
|
|
314
426
|
exports.CucumberJSAllureFormatter = CucumberJSAllureFormatter;
|
|
315
427
|
//# sourceMappingURL=CucumberJSAllureReporter.js.map
|