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