cucumberjs-qase-reporter 2.0.0-beta.1 → 2.0.0-beta.2
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/dist/reporter.d.ts +16 -1
- package/dist/reporter.js +101 -13
- package/package.json +2 -2
package/dist/reporter.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Formatter, IFormatterOptions, Status } from '@cucumber/cucumber';
|
|
2
|
-
import { ConfigType,
|
|
2
|
+
import { ConfigLoader, ConfigType, StepStatusEnum, TestStatusEnum } from 'qase-javascript-commons';
|
|
3
3
|
type TestStepResultStatus = (typeof Status)[keyof typeof Status];
|
|
4
4
|
export type CucumberQaseOptionsType = IFormatterOptions & {
|
|
5
5
|
qase?: ConfigType;
|
|
@@ -13,6 +13,10 @@ export declare class CucumberQaseReporter extends Formatter {
|
|
|
13
13
|
* @type {Record<TestStepResultStatus, TestStatusEnum | null>}
|
|
14
14
|
*/
|
|
15
15
|
static statusMap: Record<TestStepResultStatus, TestStatusEnum | null>;
|
|
16
|
+
/**
|
|
17
|
+
* @type {Record<TestStepResultStatus, StepStatusEnum>}
|
|
18
|
+
*/
|
|
19
|
+
static stepStatusMap: Record<TestStepResultStatus, StepStatusEnum>;
|
|
16
20
|
/**
|
|
17
21
|
* @type {RegExp}
|
|
18
22
|
*/
|
|
@@ -37,6 +41,11 @@ export declare class CucumberQaseReporter extends Formatter {
|
|
|
37
41
|
* @type {Record<string, >}
|
|
38
42
|
* @private
|
|
39
43
|
*/
|
|
44
|
+
/**
|
|
45
|
+
* @type {Record<string, TestStepFinished>}
|
|
46
|
+
* @private
|
|
47
|
+
*/
|
|
48
|
+
private testCaseStepsFinished;
|
|
40
49
|
private testCaseStartedResult;
|
|
41
50
|
/**
|
|
42
51
|
* @type {Record<string, string[]>}
|
|
@@ -77,10 +86,16 @@ export declare class CucumberQaseReporter extends Formatter {
|
|
|
77
86
|
* @private
|
|
78
87
|
*/
|
|
79
88
|
private bindEventListeners;
|
|
89
|
+
private convertSteps;
|
|
80
90
|
/**
|
|
81
91
|
* @returns {Promise<void>}
|
|
82
92
|
* @private
|
|
83
93
|
*/
|
|
84
94
|
private publishResults;
|
|
95
|
+
/**
|
|
96
|
+
* @returns {Promise<void>}
|
|
97
|
+
* @private
|
|
98
|
+
*/
|
|
99
|
+
private startTestRun;
|
|
85
100
|
}
|
|
86
101
|
export {};
|
package/dist/reporter.js
CHANGED
|
@@ -44,6 +44,11 @@ class CucumberQaseReporter extends cucumber_1.Formatter {
|
|
|
44
44
|
* @type {Record<string, >}
|
|
45
45
|
* @private
|
|
46
46
|
*/
|
|
47
|
+
/**
|
|
48
|
+
* @type {Record<string, TestStepFinished>}
|
|
49
|
+
* @private
|
|
50
|
+
*/
|
|
51
|
+
this.testCaseStepsFinished = {};
|
|
47
52
|
this.testCaseStartedResult = {};
|
|
48
53
|
/**
|
|
49
54
|
* @type {Record<string, string[]>}
|
|
@@ -65,7 +70,7 @@ class CucumberQaseReporter extends cucumber_1.Formatter {
|
|
|
65
70
|
* @private
|
|
66
71
|
*/
|
|
67
72
|
this.attachments = {};
|
|
68
|
-
this.reporter =
|
|
73
|
+
this.reporter = qase_javascript_commons_1.QaseReporter.getInstance({
|
|
69
74
|
...(0, qase_javascript_commons_1.composeOptions)(qase, config),
|
|
70
75
|
frameworkPackage: '@cucumber/cucumber',
|
|
71
76
|
frameworkName: 'cucumberjs',
|
|
@@ -94,6 +99,7 @@ class CucumberQaseReporter extends cucumber_1.Formatter {
|
|
|
94
99
|
caseIds: CucumberQaseReporter.getCaseIds(envelope.pickle.tags),
|
|
95
100
|
name: envelope.pickle.name,
|
|
96
101
|
lastAstNodeId: envelope.pickle.astNodeIds[envelope.pickle.astNodeIds.length - 1],
|
|
102
|
+
steps: envelope.pickle.steps,
|
|
97
103
|
};
|
|
98
104
|
}
|
|
99
105
|
else if (envelope.attachment) {
|
|
@@ -103,12 +109,15 @@ class CucumberQaseReporter extends cucumber_1.Formatter {
|
|
|
103
109
|
envelope.attachment.fileName;
|
|
104
110
|
}
|
|
105
111
|
}
|
|
112
|
+
else if (envelope.testRunStarted) {
|
|
113
|
+
this.startTestRun();
|
|
114
|
+
}
|
|
106
115
|
else if (envelope.testRunFinished) {
|
|
107
116
|
void this.publishResults();
|
|
108
117
|
}
|
|
109
118
|
else if (envelope.testCase) {
|
|
110
119
|
this.testCaseScenarioId[envelope.testCase.id] =
|
|
111
|
-
envelope.testCase
|
|
120
|
+
envelope.testCase;
|
|
112
121
|
}
|
|
113
122
|
else if (envelope.testCaseStarted) {
|
|
114
123
|
this.testCaseStarts[envelope.testCaseStarted.id] =
|
|
@@ -123,6 +132,7 @@ class CucumberQaseReporter extends cucumber_1.Formatter {
|
|
|
123
132
|
if (newStatus === null) {
|
|
124
133
|
return;
|
|
125
134
|
}
|
|
135
|
+
this.testCaseStepsFinished[stepFin.testStepId] = stepFin;
|
|
126
136
|
if (newStatus !== qase_javascript_commons_1.TestStatusEnum.passed) {
|
|
127
137
|
if (stepFin.testStepResult.message) {
|
|
128
138
|
const errors = this.testCaseStartedErrors[stepFin.testCaseStartedId] ?? [];
|
|
@@ -146,11 +156,11 @@ class CucumberQaseReporter extends cucumber_1.Formatter {
|
|
|
146
156
|
if (!tcs) {
|
|
147
157
|
return;
|
|
148
158
|
}
|
|
149
|
-
const
|
|
150
|
-
if (!
|
|
159
|
+
const testCase = this.testCaseScenarioId[tcs.testCaseId];
|
|
160
|
+
if (!testCase) {
|
|
151
161
|
return;
|
|
152
162
|
}
|
|
153
|
-
const info = this.pickleInfo[pickleId];
|
|
163
|
+
const info = this.pickleInfo[testCase.pickleId];
|
|
154
164
|
if (!info) {
|
|
155
165
|
return;
|
|
156
166
|
}
|
|
@@ -158,20 +168,79 @@ class CucumberQaseReporter extends cucumber_1.Formatter {
|
|
|
158
168
|
if (this.testCaseStartedErrors[tcs.id]?.length) {
|
|
159
169
|
error = new Error(this.testCaseStartedErrors[tcs.id]?.join('\n\n'));
|
|
160
170
|
}
|
|
161
|
-
|
|
171
|
+
let relations = null;
|
|
172
|
+
if (info.lastAstNodeId != undefined && this.scenarios[info.lastAstNodeId] != undefined) {
|
|
173
|
+
relations = {
|
|
174
|
+
suite: {
|
|
175
|
+
data: [
|
|
176
|
+
{
|
|
177
|
+
title: this.scenarios[info.lastAstNodeId] ?? '',
|
|
178
|
+
public_id: null,
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
void this.reporter.addTestResult({
|
|
185
|
+
attachments: [],
|
|
186
|
+
author: null,
|
|
187
|
+
execution: {
|
|
188
|
+
status: this.testCaseStartedResult[envelope.testCaseFinished.testCaseStartedId] ?? qase_javascript_commons_1.TestStatusEnum.passed,
|
|
189
|
+
start_time: null,
|
|
190
|
+
end_time: null,
|
|
191
|
+
duration: Math.abs(envelope.testCaseFinished.timestamp.seconds - tcs.timestamp.seconds),
|
|
192
|
+
stacktrace: error?.stack ?? null,
|
|
193
|
+
thread: null,
|
|
194
|
+
},
|
|
195
|
+
fields: {},
|
|
196
|
+
message: null,
|
|
197
|
+
muted: false,
|
|
198
|
+
params: {},
|
|
199
|
+
relations: relations,
|
|
200
|
+
run_id: null,
|
|
201
|
+
signature: '',
|
|
202
|
+
steps: this.convertSteps(info.steps, testCase),
|
|
203
|
+
testops_id: info.caseIds.length > 0 ? info.caseIds : null,
|
|
162
204
|
id: tcs.id,
|
|
163
|
-
testOpsId: info.caseIds,
|
|
164
205
|
title: info.name,
|
|
165
|
-
suiteTitle: info.lastAstNodeId && this.scenarios[info.lastAstNodeId],
|
|
166
|
-
status: this.testCaseStartedResult[envelope.testCaseFinished.testCaseStartedId] ?? qase_javascript_commons_1.TestStatusEnum.passed,
|
|
167
|
-
startTime: tcs.timestamp.seconds,
|
|
168
|
-
endTime: envelope.testCaseFinished.timestamp.seconds,
|
|
169
|
-
duration: Math.abs(envelope.testCaseFinished.timestamp.seconds - tcs.timestamp.seconds),
|
|
170
|
-
error,
|
|
206
|
+
// suiteTitle: info.lastAstNodeId && this.scenarios[info.lastAstNodeId],
|
|
171
207
|
});
|
|
172
208
|
}
|
|
173
209
|
});
|
|
174
210
|
}
|
|
211
|
+
convertSteps(steps, testCase) {
|
|
212
|
+
const results = [];
|
|
213
|
+
for (const s of testCase.testSteps) {
|
|
214
|
+
const finished = this.testCaseStepsFinished[s.id];
|
|
215
|
+
if (!finished) {
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
const step = steps.find((step) => step.id === s.pickleStepId);
|
|
219
|
+
if (!step) {
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
const result = {
|
|
223
|
+
id: s.id,
|
|
224
|
+
step_type: qase_javascript_commons_1.StepType.GHERKIN,
|
|
225
|
+
data: {
|
|
226
|
+
keyword: step.text,
|
|
227
|
+
name: step.text,
|
|
228
|
+
line: 0,
|
|
229
|
+
},
|
|
230
|
+
execution: {
|
|
231
|
+
status: CucumberQaseReporter.stepStatusMap[finished.testStepResult.status],
|
|
232
|
+
start_time: null,
|
|
233
|
+
end_time: null,
|
|
234
|
+
duration: finished.testStepResult.duration.seconds,
|
|
235
|
+
},
|
|
236
|
+
attachments: [],
|
|
237
|
+
steps: [],
|
|
238
|
+
parent_id: null,
|
|
239
|
+
};
|
|
240
|
+
results.push(result);
|
|
241
|
+
}
|
|
242
|
+
return results;
|
|
243
|
+
}
|
|
175
244
|
/**
|
|
176
245
|
* @returns {Promise<void>}
|
|
177
246
|
* @private
|
|
@@ -179,6 +248,13 @@ class CucumberQaseReporter extends cucumber_1.Formatter {
|
|
|
179
248
|
async publishResults() {
|
|
180
249
|
await this.reporter.publish();
|
|
181
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* @returns {Promise<void>}
|
|
253
|
+
* @private
|
|
254
|
+
*/
|
|
255
|
+
startTestRun() {
|
|
256
|
+
this.reporter.startTestRun();
|
|
257
|
+
}
|
|
182
258
|
}
|
|
183
259
|
exports.CucumberQaseReporter = CucumberQaseReporter;
|
|
184
260
|
/**
|
|
@@ -193,6 +269,18 @@ CucumberQaseReporter.statusMap = {
|
|
|
193
269
|
[cucumber_1.Status.UNDEFINED]: null,
|
|
194
270
|
[cucumber_1.Status.UNKNOWN]: null,
|
|
195
271
|
};
|
|
272
|
+
/**
|
|
273
|
+
* @type {Record<TestStepResultStatus, StepStatusEnum>}
|
|
274
|
+
*/
|
|
275
|
+
CucumberQaseReporter.stepStatusMap = {
|
|
276
|
+
[cucumber_1.Status.PASSED]: qase_javascript_commons_1.StepStatusEnum.passed,
|
|
277
|
+
[cucumber_1.Status.FAILED]: qase_javascript_commons_1.StepStatusEnum.failed,
|
|
278
|
+
[cucumber_1.Status.SKIPPED]: qase_javascript_commons_1.StepStatusEnum.blocked,
|
|
279
|
+
[cucumber_1.Status.AMBIGUOUS]: qase_javascript_commons_1.StepStatusEnum.blocked,
|
|
280
|
+
[cucumber_1.Status.PENDING]: qase_javascript_commons_1.StepStatusEnum.blocked,
|
|
281
|
+
[cucumber_1.Status.UNDEFINED]: qase_javascript_commons_1.StepStatusEnum.blocked,
|
|
282
|
+
[cucumber_1.Status.UNKNOWN]: qase_javascript_commons_1.StepStatusEnum.blocked,
|
|
283
|
+
};
|
|
196
284
|
/**
|
|
197
285
|
* @type {RegExp}
|
|
198
286
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cucumberjs-qase-reporter",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.2",
|
|
4
4
|
"description": "Qase TMS CucumberJS Reporter",
|
|
5
5
|
"homepage": "https://github.com/qase-tms/qase-javascript",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"license": "Apache-2.0",
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@cucumber/messages": "^22.0.0",
|
|
43
|
-
"qase-javascript-commons": "^2.0.0-beta.
|
|
43
|
+
"qase-javascript-commons": "^2.0.0-beta.8"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@cucumber/cucumber": ">=7.0.0"
|