allure-cucumberjs 3.14.0 → 3.16.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 +2 -2
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/legacy.js +1 -0
- package/dist/cjs/legacy.js.map +1 -1
- package/dist/cjs/reporter.js +131 -40
- package/dist/cjs/reporter.js.map +1 -1
- package/dist/cjs/utils.js +4 -4
- package/dist/cjs/utils.js.map +1 -1
- package/dist/esm/index.js +5 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/legacy.js +1 -0
- package/dist/esm/legacy.js.map +1 -1
- package/dist/esm/reporter.js +135 -44
- package/dist/esm/reporter.js.map +1 -1
- package/dist/esm/utils.js +2 -3
- package/dist/esm/utils.js.map +1 -1
- package/dist/types/reporter.d.ts +8 -1
- package/dist/types/utils.d.ts +1 -0
- package/package.json +15 -14
package/dist/esm/reporter.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
var _excluded = ["resultsDir", "links", "labels"];
|
|
2
|
+
function _toArray(r) { return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest(); }
|
|
3
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
4
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
5
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
7
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
8
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
9
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
2
10
|
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
11
|
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
12
|
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], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
@@ -9,12 +17,12 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
9
17
|
import { extname } from "node:path";
|
|
10
18
|
import { Formatter, World } from "@cucumber/cucumber";
|
|
11
19
|
import { TimeConversion } from "@cucumber/messages";
|
|
12
|
-
import { AttachmentContentEncoding, TestStepResultStatus } from "@cucumber/messages";
|
|
20
|
+
import { AttachmentContentEncoding, StepDefinitionPatternType, TestStepResultStatus } from "@cucumber/messages";
|
|
13
21
|
import { ContentType, LabelName, Stage, Status } from "allure-js-commons";
|
|
14
|
-
import { getMessageAndTraceFromError, getStatusFromError, toGlobalErrorMessage } from "allure-js-commons/sdk";
|
|
15
|
-
import { ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE, ReporterRuntime, applyLinkTemplate, createDefaultWriter, createStepResult, getEnvironmentLabels, getFallbackTestCaseIdLabel, getFrameworkLabel, getHostLabel, getLanguageLabel, getPackageLabel, getProjectName, getThreadLabel, getWorstTestStepResult, md5 } from "allure-js-commons/sdk/reporter";
|
|
22
|
+
import { getMessageAndTraceFromError, getStatusFromError, hasLabel, toGlobalErrorMessage } from "allure-js-commons/sdk";
|
|
23
|
+
import { ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE, ReporterRuntime, applyLinkTemplate, createDefaultWriter, createStepResult, getEnvironmentLabels, getFallbackTestCaseIdLabel, getFrameworkLabel, getHostLabel, getLanguageLabel, getPackageLabel, getProjectName, getThreadLabel, getWorstTestStepResult, isUrl, md5 } from "allure-js-commons/sdk/reporter";
|
|
16
24
|
import { AllureCucumberWorld } from "./legacy.js";
|
|
17
|
-
import { getPathRelativeToProjectRoot, getPosixPathRelativeToProjectRoot } from "./utils.js";
|
|
25
|
+
import { getPathRelativeToProjectRoot, getPosixPathRelativeToProjectRoot, serializeCsvRow } from "./utils.js";
|
|
18
26
|
var UNDEFINED_STEP_MESSAGE = "The step doesn't have an implementation.";
|
|
19
27
|
var UNDEFINED_TEST_MESSAGE = "The test doesn't have an implementation.";
|
|
20
28
|
var PENDING_STEP_MESSAGE = "The step is pending.";
|
|
@@ -31,19 +39,23 @@ export default class AllureCucumberReporter extends Formatter {
|
|
|
31
39
|
_defineProperty(this, "scenarioMap", new Map());
|
|
32
40
|
_defineProperty(this, "stepMap", new Map());
|
|
33
41
|
_defineProperty(this, "testStepMap", new Map());
|
|
42
|
+
_defineProperty(this, "stepDefinitionMap", new Map());
|
|
34
43
|
_defineProperty(this, "pickleStepMap", new Map());
|
|
35
44
|
_defineProperty(this, "pickleMap", new Map());
|
|
36
45
|
_defineProperty(this, "testCaseMap", new Map());
|
|
37
|
-
_defineProperty(this, "
|
|
46
|
+
_defineProperty(this, "featureNamesByTestCaseStartedId", new Map());
|
|
38
47
|
_defineProperty(this, "testResultUuids", new Map());
|
|
39
48
|
_defineProperty(this, "scopeUuids", new Map());
|
|
40
49
|
_defineProperty(this, "fixtureUuids", new Map());
|
|
50
|
+
_defineProperty(this, "testRunHookTypes", new Map());
|
|
51
|
+
_defineProperty(this, "testRunHookStartedMap", new Map());
|
|
52
|
+
// executions of test run hooks running in this process, by hook id
|
|
53
|
+
_defineProperty(this, "runningTestRunHooks", new Map());
|
|
54
|
+
_defineProperty(this, "reportedTestRunHookStartedIds", new Set());
|
|
41
55
|
var _ref = options.parsedArgvOptions,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
labels
|
|
46
|
-
} = _ref,
|
|
56
|
+
resultsDir = _ref.resultsDir,
|
|
57
|
+
links = _ref.links,
|
|
58
|
+
labels = _ref.labels,
|
|
47
59
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
48
60
|
this.allureRuntime = new ReporterRuntime(_objectSpread({
|
|
49
61
|
writer: createDefaultWriter({
|
|
@@ -70,24 +82,21 @@ export default class AllureCucumberReporter extends Formatter {
|
|
|
70
82
|
}
|
|
71
83
|
}
|
|
72
84
|
get tagsIgnorePatterns() {
|
|
73
|
-
var
|
|
74
|
-
|
|
75
|
-
linksConfigs
|
|
76
|
-
} = this;
|
|
85
|
+
var labelsConfigs = this.labelsConfigs,
|
|
86
|
+
linksConfigs = this.linksConfigs;
|
|
77
87
|
var linkConfigEntries = Object.entries(linksConfigs).map(_ref2 => {
|
|
78
|
-
var
|
|
88
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
89
|
+
v = _ref3[1];
|
|
79
90
|
return v;
|
|
80
91
|
});
|
|
81
|
-
return [...labelsConfigs, ...linkConfigEntries].flatMap(
|
|
82
|
-
var
|
|
83
|
-
pattern
|
|
84
|
-
} = _ref3;
|
|
92
|
+
return [...labelsConfigs, ...linkConfigEntries].flatMap(_ref4 => {
|
|
93
|
+
var pattern = _ref4.pattern;
|
|
85
94
|
return pattern;
|
|
86
95
|
});
|
|
87
96
|
}
|
|
88
97
|
getHookName(hookId) {
|
|
89
|
-
var
|
|
90
|
-
return (
|
|
98
|
+
var _ref5, _this$beforeHooks$hoo, _this$beforeHooks$hoo2, _this$afterHooks$hook;
|
|
99
|
+
return (_ref5 = (_this$beforeHooks$hoo = (_this$beforeHooks$hoo2 = this.beforeHooks[hookId]) === null || _this$beforeHooks$hoo2 === void 0 ? void 0 : _this$beforeHooks$hoo2.name) !== null && _this$beforeHooks$hoo !== void 0 ? _this$beforeHooks$hoo : (_this$afterHooks$hook = this.afterHooks[hookId]) === null || _this$afterHooks$hook === void 0 ? void 0 : _this$afterHooks$hook.name) !== null && _ref5 !== void 0 ? _ref5 : "hook";
|
|
91
100
|
}
|
|
92
101
|
installTestRunHookGlobalErrorSupport(hooks, type) {
|
|
93
102
|
hooks.forEach(hook => {
|
|
@@ -96,34 +105,34 @@ export default class AllureCucumberReporter extends Formatter {
|
|
|
96
105
|
var runTestRunHook = this.runTestRunHook.bind(this);
|
|
97
106
|
var runCallbackTestRunHook = this.runCallbackTestRunHook.bind(this);
|
|
98
107
|
hook.code = originalCode.length > 0 ? function (callback) {
|
|
99
|
-
return runCallbackTestRunHook(hookName, originalCode, this, callback);
|
|
108
|
+
return runCallbackTestRunHook(hook.id, hookName, originalCode, this, callback);
|
|
100
109
|
} : function () {
|
|
101
|
-
return runTestRunHook(hookName, () => originalCode.call(this));
|
|
110
|
+
return runTestRunHook(hook.id, hookName, () => originalCode.call(this));
|
|
102
111
|
};
|
|
103
112
|
});
|
|
104
113
|
}
|
|
105
|
-
runTestRunHook(name, runHook) {
|
|
114
|
+
runTestRunHook(hookId, name, runHook) {
|
|
106
115
|
try {
|
|
107
116
|
var result = runHook();
|
|
108
117
|
if (isPromiseLike(result)) {
|
|
109
118
|
return result.then(value => value, error => {
|
|
110
|
-
this.emitTestRunHookGlobalError(name, error);
|
|
119
|
+
this.emitTestRunHookGlobalError(hookId, name, error);
|
|
111
120
|
return deferReject(error);
|
|
112
121
|
});
|
|
113
122
|
}
|
|
114
123
|
return result;
|
|
115
124
|
} catch (error) {
|
|
116
|
-
this.emitTestRunHookGlobalError(name, error);
|
|
125
|
+
this.emitTestRunHookGlobalError(hookId, name, error);
|
|
117
126
|
return deferReject(error);
|
|
118
127
|
}
|
|
119
128
|
}
|
|
120
|
-
runCallbackTestRunHook(name, originalCode, thisArg, callback) {
|
|
129
|
+
runCallbackTestRunHook(hookId, name, originalCode, thisArg, callback) {
|
|
121
130
|
var finished = false;
|
|
122
131
|
var finish = (error, result) => {
|
|
123
132
|
if (!finished) {
|
|
124
133
|
finished = true;
|
|
125
134
|
if (error) {
|
|
126
|
-
this.emitTestRunHookGlobalError(name, error);
|
|
135
|
+
this.emitTestRunHookGlobalError(hookId, name, error);
|
|
127
136
|
}
|
|
128
137
|
}
|
|
129
138
|
if (error) {
|
|
@@ -143,7 +152,12 @@ export default class AllureCucumberReporter extends Formatter {
|
|
|
143
152
|
throw error;
|
|
144
153
|
}
|
|
145
154
|
}
|
|
146
|
-
emitTestRunHookGlobalError(name, error) {
|
|
155
|
+
emitTestRunHookGlobalError(hookId, name, error) {
|
|
156
|
+
// the same execution is reported again with the testRunHookFinished message (Cucumber 12.3+)
|
|
157
|
+
var testRunHookStartedId = this.runningTestRunHooks.get(hookId);
|
|
158
|
+
if (testRunHookStartedId) {
|
|
159
|
+
this.reportedTestRunHookStartedIds.add(testRunHookStartedId);
|
|
160
|
+
}
|
|
147
161
|
this.allureRuntime.applyGlobalRuntimeMessages([toGlobalErrorMessage({
|
|
148
162
|
name,
|
|
149
163
|
details: getMessageAndTraceFromError(this.toError(error)),
|
|
@@ -158,6 +172,19 @@ export default class AllureCucumberReporter extends Formatter {
|
|
|
158
172
|
}
|
|
159
173
|
parseEnvelope(envelope) {
|
|
160
174
|
switch (true) {
|
|
175
|
+
case !!envelope.stepDefinition:
|
|
176
|
+
this.stepDefinitionMap.set(envelope.stepDefinition.id, envelope.stepDefinition);
|
|
177
|
+
break;
|
|
178
|
+
case !!envelope.hook:
|
|
179
|
+
this.testRunHookTypes.set(envelope.hook.id, envelope.hook.type);
|
|
180
|
+
break;
|
|
181
|
+
case !!envelope.testRunHookStarted:
|
|
182
|
+
this.testRunHookStartedMap.set(envelope.testRunHookStarted.id, envelope.testRunHookStarted.hookId);
|
|
183
|
+
this.runningTestRunHooks.set(envelope.testRunHookStarted.hookId, envelope.testRunHookStarted.id);
|
|
184
|
+
break;
|
|
185
|
+
case !!envelope.testRunHookFinished:
|
|
186
|
+
this.onTestRunHookFinished(envelope.testRunHookFinished);
|
|
187
|
+
break;
|
|
161
188
|
case !!envelope.gherkinDocument:
|
|
162
189
|
this.onGherkinDocument(envelope.gherkinDocument);
|
|
163
190
|
break;
|
|
@@ -217,14 +244,23 @@ export default class AllureCucumberReporter extends Formatter {
|
|
|
217
244
|
if (Object.keys(this.linksConfigs).length === 0) {
|
|
218
245
|
return links;
|
|
219
246
|
}
|
|
220
|
-
Object.entries(this.linksConfigs).forEach(
|
|
221
|
-
var
|
|
247
|
+
Object.entries(this.linksConfigs).forEach(_ref6 => {
|
|
248
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
|
249
|
+
type = _ref7[0],
|
|
250
|
+
matcher = _ref7[1];
|
|
222
251
|
var matchedTags = tags.filter(tag => matcher.pattern.some(pattern => pattern.test(tag.name)));
|
|
223
252
|
var matchedLinks = matchedTags.map(tag => {
|
|
224
253
|
var tagValue = tag.name.replace(tagKeyRe, "");
|
|
254
|
+
if (isUrl(tagValue)) {
|
|
255
|
+
return {
|
|
256
|
+
url: tagValue,
|
|
257
|
+
type
|
|
258
|
+
};
|
|
259
|
+
}
|
|
225
260
|
return {
|
|
226
261
|
url: applyLinkTemplate(matcher.urlTemplate, tagValue) || tagValue,
|
|
227
|
-
type
|
|
262
|
+
type,
|
|
263
|
+
name: matcher.nameTemplate !== undefined ? applyLinkTemplate(matcher.nameTemplate, tagValue) : undefined
|
|
228
264
|
};
|
|
229
265
|
});
|
|
230
266
|
links.push(...matchedLinks);
|
|
@@ -297,7 +333,9 @@ export default class AllureCucumberReporter extends Formatter {
|
|
|
297
333
|
var testCase = this.testCaseMap.get(data.testCaseId);
|
|
298
334
|
var pickle = this.pickleMap.get(testCase.pickleId);
|
|
299
335
|
var doc = this.documentMap.get(pickle.uri);
|
|
300
|
-
var
|
|
336
|
+
var _pickle$astNodeIds = _toArray(pickle.astNodeIds),
|
|
337
|
+
scenarioId = _pickle$astNodeIds[0],
|
|
338
|
+
astIds = _arrayLikeToArray(_pickle$astNodeIds).slice(1);
|
|
301
339
|
var scenario = this.scenarioMap.get(scenarioId);
|
|
302
340
|
var projectName = getProjectName();
|
|
303
341
|
var posixPath = getPosixPathRelativeToProjectRoot(pickle);
|
|
@@ -316,12 +354,6 @@ export default class AllureCucumberReporter extends Formatter {
|
|
|
316
354
|
};
|
|
317
355
|
result.labels.push(...getEnvironmentLabels());
|
|
318
356
|
result.labels.push(getLanguageLabel(), getFrameworkLabel("cucumberjs"), getPackageLabel(getPathRelativeToProjectRoot(pickle)), getFallbackTestCaseIdLabel(legacyTestCaseId), getHostLabel(), getThreadLabel(data.workerId));
|
|
319
|
-
if (doc !== null && doc !== void 0 && doc.feature) {
|
|
320
|
-
result.labels.push({
|
|
321
|
-
name: LabelName.FEATURE,
|
|
322
|
-
value: doc.feature.name
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
357
|
var pickleLabels = this.parsePickleTags(pickle.tags || []);
|
|
326
358
|
var featureLabels = this.parseTagsLabels((doc === null || doc === void 0 || (_doc$feature2 = doc.feature) === null || _doc$feature2 === void 0 ? void 0 : _doc$feature2.tags) || []);
|
|
327
359
|
var featureLinks = this.parseTagsLinks((doc === null || doc === void 0 || (_doc$feature3 = doc.feature) === null || _doc$feature3 === void 0 ? void 0 : _doc$feature3.tags) || []);
|
|
@@ -337,7 +369,9 @@ export default class AllureCucumberReporter extends Formatter {
|
|
|
337
369
|
this.scopeUuids.set(data.id, scopeUuid);
|
|
338
370
|
var testUuid = this.allureRuntime.startTest(result, [scopeUuid]);
|
|
339
371
|
this.testResultUuids.set(data.id, testUuid);
|
|
340
|
-
|
|
372
|
+
if (doc !== null && doc !== void 0 && doc.feature) {
|
|
373
|
+
this.featureNamesByTestCaseStartedId.set(data.id, doc.feature.name);
|
|
374
|
+
}
|
|
341
375
|
if (!(scenario !== null && scenario !== void 0 && scenario.examples)) {
|
|
342
376
|
return;
|
|
343
377
|
}
|
|
@@ -345,7 +379,7 @@ export default class AllureCucumberReporter extends Formatter {
|
|
|
345
379
|
var _example$tableHeader, _example$tableBody;
|
|
346
380
|
var exampleName = example !== null && example !== void 0 && example.name ? "Examples: ".concat(example.name) : "Examples";
|
|
347
381
|
var parameterNames = example === null || example === void 0 || (_example$tableHeader = example.tableHeader) === null || _example$tableHeader === void 0 ? void 0 : _example$tableHeader.cells.map(cell => cell.value);
|
|
348
|
-
var csvDataTableHeader =
|
|
382
|
+
var csvDataTableHeader = parameterNames ? serializeCsvRow(parameterNames) : "";
|
|
349
383
|
var currentRow = example === null || example === void 0 || (_example$tableBody = example.tableBody) === null || _example$tableBody === void 0 ? void 0 : _example$tableBody.find(tb => astIds.includes(tb.id));
|
|
350
384
|
if (currentRow) {
|
|
351
385
|
var parameters = currentRow.cells.map((cell, index) => {
|
|
@@ -358,7 +392,7 @@ export default class AllureCucumberReporter extends Formatter {
|
|
|
358
392
|
});
|
|
359
393
|
_this.allureRuntime.updateTest(testUuid, tr => tr.parameters = [...tr.parameters, ...parameters]);
|
|
360
394
|
}
|
|
361
|
-
var csvDataTableBody = (example === null || example === void 0 ? void 0 : example.tableBody.map(row => row.cells.map(cell => cell.value)
|
|
395
|
+
var csvDataTableBody = (example === null || example === void 0 ? void 0 : example.tableBody.map(row => serializeCsvRow(row.cells.map(cell => cell.value))).join("\n")) || "";
|
|
362
396
|
if (!csvDataTableHeader && !csvDataTableBody) {
|
|
363
397
|
return 1; // continue
|
|
364
398
|
}
|
|
@@ -400,6 +434,19 @@ export default class AllureCucumberReporter extends Formatter {
|
|
|
400
434
|
this.allureRuntime.stopTest(testUuid, {
|
|
401
435
|
stop: TimeConversion.timestampToMillisecondsSinceEpoch(data.timestamp)
|
|
402
436
|
});
|
|
437
|
+
var featureName = this.featureNamesByTestCaseStartedId.get(data.testCaseStartedId);
|
|
438
|
+
if (featureName !== undefined) {
|
|
439
|
+
this.featureNamesByTestCaseStartedId.delete(data.testCaseStartedId);
|
|
440
|
+
// Runtime and global metadata can supply the feature before the result is written.
|
|
441
|
+
this.allureRuntime.updateTest(testUuid, result => {
|
|
442
|
+
if (!hasLabel(result, LabelName.FEATURE)) {
|
|
443
|
+
result.labels.push({
|
|
444
|
+
name: LabelName.FEATURE,
|
|
445
|
+
value: featureName
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
}
|
|
403
450
|
this.allureRuntime.writeTest(testUuid);
|
|
404
451
|
this.testResultUuids.delete(data.testCaseStartedId);
|
|
405
452
|
var scopeUuid = this.scopeUuids.get(data.testCaseStartedId);
|
|
@@ -452,7 +499,7 @@ export default class AllureCucumberReporter extends Formatter {
|
|
|
452
499
|
if (!((_stepPickle$argument = stepPickle.argument) !== null && _stepPickle$argument !== void 0 && _stepPickle$argument.dataTable)) {
|
|
453
500
|
return;
|
|
454
501
|
}
|
|
455
|
-
var csvDataTable = stepPickle.argument.dataTable.rows.reduce((acc, row) => "".concat(acc + row.cells.map(cell => cell.value)
|
|
502
|
+
var csvDataTable = stepPickle.argument.dataTable.rows.reduce((acc, row) => "".concat(acc + serializeCsvRow(row.cells.map(cell => cell.value)), "\n"), "");
|
|
456
503
|
this.allureRuntime.writeAttachment(testUuid, stepUuid, "Data table", Buffer.from(csvDataTable, "utf-8"), {
|
|
457
504
|
contentType: ContentType.CSV,
|
|
458
505
|
fileExtension: ".csv"
|
|
@@ -515,7 +562,7 @@ export default class AllureCucumberReporter extends Formatter {
|
|
|
515
562
|
if (data.testStepResult.status === TestStepResultStatus.AMBIGUOUS) {
|
|
516
563
|
var _data$testStepResult$2;
|
|
517
564
|
r.statusDetails = {
|
|
518
|
-
message: (_data$testStepResult$2 = data.testStepResult.message) !== null && _data$testStepResult$2 !== void 0 ? _data$testStepResult$2 :
|
|
565
|
+
message: (_data$testStepResult$2 = data.testStepResult.message) !== null && _data$testStepResult$2 !== void 0 ? _data$testStepResult$2 : this.getAmbiguousStepMessage(step)
|
|
519
566
|
};
|
|
520
567
|
return;
|
|
521
568
|
}
|
|
@@ -583,10 +630,54 @@ export default class AllureCucumberReporter extends Formatter {
|
|
|
583
630
|
this.allureRuntime.applyGlobalRuntimeMessages(runtimeMessages);
|
|
584
631
|
}
|
|
585
632
|
}
|
|
633
|
+
|
|
634
|
+
// Cucumber 12.3+ reports test run hooks with messages. In parallel mode they run in workers,
|
|
635
|
+
// where the patched hook code isn't used, so the messages are the only source of their errors
|
|
636
|
+
onTestRunHookFinished(data) {
|
|
637
|
+
var _this$exceptionToErro, _data$result$exceptio, _data$result$message;
|
|
638
|
+
var hookId = this.testRunHookStartedMap.get(data.testRunHookStartedId);
|
|
639
|
+
if (hookId && this.runningTestRunHooks.get(hookId) === data.testRunHookStartedId) {
|
|
640
|
+
this.runningTestRunHooks.delete(hookId);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
// dry runs report every test run hook as skipped
|
|
644
|
+
if (!hookId || data.result.status !== TestStepResultStatus.FAILED || this.reportedTestRunHookStartedIds.has(data.testRunHookStartedId)) {
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
647
|
+
var name = this.testRunHookTypes.get(hookId) === "AFTER_TEST_RUN" ? "AfterAll hook" : "BeforeAll hook";
|
|
648
|
+
var error = (_this$exceptionToErro = this.exceptionToError((_data$result$exceptio = data.result.exception) === null || _data$result$exceptio === void 0 ? void 0 : _data$result$exceptio.message, data.result.exception)) !== null && _this$exceptionToErro !== void 0 ? _this$exceptionToErro : {
|
|
649
|
+
name: "Error",
|
|
650
|
+
message: (_data$result$message = data.result.message) !== null && _data$result$message !== void 0 ? _data$result$message : ""
|
|
651
|
+
};
|
|
652
|
+
this.allureRuntime.applyGlobalRuntimeMessages([toGlobalErrorMessage({
|
|
653
|
+
name,
|
|
654
|
+
details: getMessageAndTraceFromError(error),
|
|
655
|
+
status: getStatusFromError(error)
|
|
656
|
+
})]);
|
|
657
|
+
}
|
|
586
658
|
onTestRunFinished() {
|
|
587
659
|
this.allureRuntime.writeCategoriesDefinitions();
|
|
588
660
|
this.allureRuntime.writeEnvironmentInfo();
|
|
589
661
|
}
|
|
662
|
+
|
|
663
|
+
// Cucumber 13+ no longer puts the matching step definitions into the ambiguous step result
|
|
664
|
+
getAmbiguousStepMessage(step) {
|
|
665
|
+
var _step$stepDefinitionI;
|
|
666
|
+
var stepDefinitions = ((_step$stepDefinitionI = step.stepDefinitionIds) !== null && _step$stepDefinitionI !== void 0 ? _step$stepDefinitionI : []).map(id => this.stepDefinitionMap.get(id)).filter(stepDefinition => stepDefinition !== undefined);
|
|
667
|
+
if (stepDefinitions.length === 0) {
|
|
668
|
+
return AMBIGUOUS_STEP_MESSAGE;
|
|
669
|
+
}
|
|
670
|
+
var matches = stepDefinitions.map(_ref8 => {
|
|
671
|
+
var _sourceReference$loca;
|
|
672
|
+
var pattern = _ref8.pattern,
|
|
673
|
+
sourceReference = _ref8.sourceReference;
|
|
674
|
+
var patternText = pattern.type === StepDefinitionPatternType.REGULAR_EXPRESSION ? "/".concat(pattern.source, "/") : pattern.source;
|
|
675
|
+
var line = (_sourceReference$loca = sourceReference.location) === null || _sourceReference$loca === void 0 ? void 0 : _sourceReference$loca.line;
|
|
676
|
+
var location = sourceReference.uri ? "".concat(sourceReference.uri).concat(line !== undefined ? ":".concat(line) : "") : "";
|
|
677
|
+
return location ? " ".concat(patternText, " - ").concat(location) : " ".concat(patternText);
|
|
678
|
+
});
|
|
679
|
+
return ["Multiple step definitions match:", ...matches].join("\n");
|
|
680
|
+
}
|
|
590
681
|
exceptionToError(message, exception) {
|
|
591
682
|
if (!exception) {
|
|
592
683
|
return;
|