@dev-blinq/cucumber-js 1.0.104-dev → 1.0.104
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/bin/download-install.js +22 -2
- package/lib/configuration/axios_client.js +1 -1
- package/lib/configuration/axios_client.js.map +1 -1
- package/lib/formatter/api.js +7 -1
- package/lib/formatter/api.js.map +1 -1
- package/lib/formatter/bvt_analysis_formatter.d.ts +13 -1
- package/lib/formatter/bvt_analysis_formatter.js +159 -54
- package/lib/formatter/bvt_analysis_formatter.js.map +1 -1
- package/lib/formatter/feature_data_format.js +4 -1
- package/lib/formatter/feature_data_format.js.map +1 -1
- package/lib/formatter/helpers/constants.d.ts +50 -0
- package/lib/formatter/helpers/constants.js +60 -0
- package/lib/formatter/helpers/constants.js.map +1 -0
- package/lib/formatter/helpers/report_generator.d.ts +28 -13
- package/lib/formatter/helpers/report_generator.js +286 -71
- package/lib/formatter/helpers/report_generator.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.js +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
- package/lib/formatter/helpers/upload_serivce.d.ts +15 -3
- package/lib/formatter/helpers/upload_serivce.js +112 -37
- package/lib/formatter/helpers/upload_serivce.js.map +1 -1
- package/lib/formatter/helpers/uploader.d.ts +2 -1
- package/lib/formatter/helpers/uploader.js +16 -1
- package/lib/formatter/helpers/uploader.js.map +1 -1
- package/lib/formatter/summary_formatter.js +2 -0
- package/lib/formatter/summary_formatter.js.map +1 -1
- package/lib/runtime/test_case_runner.d.ts +1 -0
- package/lib/runtime/test_case_runner.js +10 -1
- package/lib/runtime/test_case_runner.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +4 -2
|
@@ -1,19 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
var _a, _b;
|
|
6
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
const messages = __importStar(require("@cucumber/messages"));
|
|
7
31
|
const fs_1 = __importDefault(require("fs"));
|
|
8
32
|
const path_1 = __importDefault(require("path"));
|
|
9
33
|
const upload_serivce_1 = require("./upload_serivce");
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
34
|
+
const fs_extra_1 = require("fs-extra");
|
|
35
|
+
// type JsonException = messages.Exception
|
|
36
|
+
const object_path_1 = __importDefault(require("object-path"));
|
|
37
|
+
const URL = process.env.NODE_ENV_BLINQ === "dev"
|
|
38
|
+
? "https://dev.api.blinq.io/api/runs"
|
|
39
|
+
: process.env.NODE_ENV_BLINQ === "local"
|
|
40
|
+
? "http://localhost:5001/api/runs"
|
|
41
|
+
: process.env.NODE_ENV_BLINQ === "stage"
|
|
42
|
+
? "https://stage.api.blinq.io/api/runs"
|
|
43
|
+
: process.env.NODE_ENV_BLINQ === "prod"
|
|
44
|
+
? "https://api.blinq.io/api/runs"
|
|
45
|
+
: !process.env.NODE_ENV_BLINQ
|
|
46
|
+
? "https://api.blinq.io/api/runs"
|
|
47
|
+
: `${process.env.NODE_ENV_BLINQ}/api/runs`;
|
|
17
48
|
const REPORT_SERVICE_URL = (_a = process.env.REPORT_SERVICE_URL) !== null && _a !== void 0 ? _a : URL;
|
|
18
49
|
const BATCH_SIZE = 10;
|
|
19
50
|
const MAX_RETRIES = 3;
|
|
@@ -22,12 +53,12 @@ class ReportGenerator {
|
|
|
22
53
|
constructor() {
|
|
23
54
|
this.report = {
|
|
24
55
|
result: {
|
|
25
|
-
status:
|
|
56
|
+
status: "UNKNOWN",
|
|
26
57
|
},
|
|
27
58
|
testCases: [],
|
|
28
59
|
env: {
|
|
29
|
-
name:
|
|
30
|
-
baseUrl:
|
|
60
|
+
name: "",
|
|
61
|
+
baseUrl: "",
|
|
31
62
|
},
|
|
32
63
|
};
|
|
33
64
|
this.gherkinDocumentMap = new Map();
|
|
@@ -40,72 +71,75 @@ class ReportGenerator {
|
|
|
40
71
|
this.scenarioIterationCountMap = new Map();
|
|
41
72
|
this.logs = [];
|
|
42
73
|
this.networkLog = [];
|
|
43
|
-
this.
|
|
74
|
+
this.stepLogs = [];
|
|
75
|
+
this.stepNetworkLogs = [];
|
|
76
|
+
this.runName = "";
|
|
77
|
+
this.ariaSnapshot = "";
|
|
78
|
+
this.initialAriaSnapshot = "";
|
|
44
79
|
this.reportFolder = null;
|
|
45
80
|
this.uploadService = new upload_serivce_1.RunUploadService(REPORT_SERVICE_URL, REPORT_SERVICE_TOKEN);
|
|
46
81
|
}
|
|
47
|
-
async handleMessage(envelope) {
|
|
48
|
-
if (envelope.meta && envelope.meta
|
|
82
|
+
async handleMessage(envelope, reRunId) {
|
|
83
|
+
if (envelope.meta && "runName" in envelope.meta) {
|
|
49
84
|
this.runName = envelope.meta.runName;
|
|
50
85
|
}
|
|
51
86
|
const type = Object.keys(envelope)[0];
|
|
52
87
|
switch (type) {
|
|
53
88
|
// case "meta": { break}
|
|
54
89
|
// case "source": { break}
|
|
55
|
-
case
|
|
90
|
+
case "parseError": {
|
|
56
91
|
const parseError = envelope[type];
|
|
57
92
|
this.handleParseError(parseError);
|
|
58
93
|
break;
|
|
59
94
|
}
|
|
60
|
-
case
|
|
95
|
+
case "gherkinDocument": {
|
|
61
96
|
const doc = envelope[type];
|
|
62
97
|
this.onGherkinDocument(doc);
|
|
63
98
|
break;
|
|
64
99
|
}
|
|
65
|
-
case
|
|
100
|
+
case "pickle": {
|
|
66
101
|
const pickle = envelope[type];
|
|
67
102
|
this.onPickle(pickle);
|
|
68
103
|
break;
|
|
69
104
|
}
|
|
70
105
|
// case "stepDefinition": { break}
|
|
71
106
|
// case "hook": { break} // Before Hook
|
|
72
|
-
case
|
|
107
|
+
case "testRunStarted": {
|
|
73
108
|
const testRunStarted = envelope[type];
|
|
74
109
|
this.onTestRunStarted(testRunStarted);
|
|
75
110
|
break;
|
|
76
111
|
}
|
|
77
|
-
case
|
|
112
|
+
case "testCase": {
|
|
78
113
|
const testCase = envelope[type];
|
|
79
114
|
this.onTestCase(testCase);
|
|
80
115
|
break;
|
|
81
116
|
}
|
|
82
|
-
case
|
|
117
|
+
case "testCaseStarted": {
|
|
83
118
|
const testCaseStarted = envelope[type];
|
|
84
119
|
this.onTestCaseStarted(testCaseStarted);
|
|
85
120
|
break;
|
|
86
121
|
}
|
|
87
|
-
case
|
|
122
|
+
case "testStepStarted": {
|
|
88
123
|
const testStepStarted = envelope[type];
|
|
89
124
|
this.onTestStepStarted(testStepStarted);
|
|
90
125
|
break;
|
|
91
126
|
}
|
|
92
|
-
case
|
|
127
|
+
case "attachment": {
|
|
93
128
|
const attachment = envelope[type];
|
|
94
129
|
this.onAttachment(attachment);
|
|
95
130
|
break;
|
|
96
131
|
}
|
|
97
|
-
case
|
|
132
|
+
case "testStepFinished": {
|
|
98
133
|
const testStepFinished = envelope[type];
|
|
99
134
|
this.onTestStepFinished(testStepFinished);
|
|
100
135
|
break;
|
|
101
136
|
}
|
|
102
|
-
case
|
|
137
|
+
case "testCaseFinished": {
|
|
103
138
|
const testCaseFinished = envelope[type];
|
|
104
|
-
await this.onTestCaseFinished(testCaseFinished);
|
|
105
|
-
break;
|
|
139
|
+
return await this.onTestCaseFinished(testCaseFinished, reRunId);
|
|
106
140
|
}
|
|
107
141
|
// case "hook": { break} // After Hook
|
|
108
|
-
case
|
|
142
|
+
case "testRunFinished": {
|
|
109
143
|
const testRunFinished = envelope[type];
|
|
110
144
|
this.onTestRunFinished(testRunFinished);
|
|
111
145
|
break;
|
|
@@ -121,7 +155,7 @@ class ReportGenerator {
|
|
|
121
155
|
const { message } = parseError;
|
|
122
156
|
const timestamp = new Date().getTime();
|
|
123
157
|
this.report.result = {
|
|
124
|
-
status:
|
|
158
|
+
status: "FAILED",
|
|
125
159
|
startTime: timestamp,
|
|
126
160
|
endTime: timestamp,
|
|
127
161
|
message: message,
|
|
@@ -164,7 +198,7 @@ class ReportGenerator {
|
|
|
164
198
|
}
|
|
165
199
|
onTestRunStarted(testRunStarted) {
|
|
166
200
|
this.report.result = {
|
|
167
|
-
status:
|
|
201
|
+
status: "STARTED",
|
|
168
202
|
startTime: this.getTimeStamp(testRunStarted.timestamp),
|
|
169
203
|
};
|
|
170
204
|
}
|
|
@@ -197,8 +231,7 @@ class ReportGenerator {
|
|
|
197
231
|
for (const tableRow of examples.tableBody) {
|
|
198
232
|
if (tableRow.id === exampleId) {
|
|
199
233
|
for (let i = 0; i < examples.tableHeader.cells.length; i++) {
|
|
200
|
-
parameters[examples.tableHeader.cells[i].value] =
|
|
201
|
-
tableRow.cells[i].value;
|
|
234
|
+
parameters[examples.tableHeader.cells[i].value] = tableRow.cells[i].value;
|
|
202
235
|
}
|
|
203
236
|
}
|
|
204
237
|
}
|
|
@@ -236,8 +269,12 @@ class ReportGenerator {
|
|
|
236
269
|
text: step.text,
|
|
237
270
|
commands: [],
|
|
238
271
|
result: {
|
|
239
|
-
status:
|
|
272
|
+
status: "UNKNOWN",
|
|
240
273
|
},
|
|
274
|
+
networkData: [],
|
|
275
|
+
webLog: [],
|
|
276
|
+
data: {},
|
|
277
|
+
ariaSnapshot: this.ariaSnapshot,
|
|
241
278
|
});
|
|
242
279
|
return this.stepReportMap.get(pickleStep.id);
|
|
243
280
|
});
|
|
@@ -249,11 +286,15 @@ class ReportGenerator {
|
|
|
249
286
|
parameters,
|
|
250
287
|
steps,
|
|
251
288
|
result: {
|
|
252
|
-
status:
|
|
289
|
+
status: "STARTED",
|
|
253
290
|
startTime: this.getTimeStamp(timestamp),
|
|
254
291
|
},
|
|
255
292
|
webLog: [],
|
|
256
293
|
networkLog: [],
|
|
294
|
+
env: {
|
|
295
|
+
name: this.report.env.name,
|
|
296
|
+
baseUrl: this.report.env.baseUrl,
|
|
297
|
+
},
|
|
257
298
|
});
|
|
258
299
|
this.report.testCases.push(this.testCaseReportMap.get(id));
|
|
259
300
|
}
|
|
@@ -266,48 +307,113 @@ class ReportGenerator {
|
|
|
266
307
|
return;
|
|
267
308
|
const stepProgess = this.stepReportMap.get(testStep.pickleStepId);
|
|
268
309
|
stepProgess.result = {
|
|
269
|
-
status:
|
|
310
|
+
status: "STARTED",
|
|
270
311
|
startTime: this.getTimeStamp(timestamp),
|
|
271
312
|
};
|
|
272
313
|
}
|
|
273
314
|
onAttachment(attachment) {
|
|
274
315
|
const { testStepId, body, mediaType } = attachment;
|
|
275
|
-
if (mediaType ===
|
|
276
|
-
this.reportFolder = body.replaceAll(
|
|
316
|
+
if (mediaType === "text/plain") {
|
|
317
|
+
this.reportFolder = body.replaceAll("\\", "/");
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
if (mediaType === "application/json+snapshot-before") {
|
|
321
|
+
this.initialAriaSnapshot = body;
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
if (mediaType === "application/json+snapshot-after") {
|
|
325
|
+
this.ariaSnapshot = body;
|
|
277
326
|
return;
|
|
278
327
|
}
|
|
279
|
-
if (mediaType ===
|
|
328
|
+
if (mediaType === "application/json+env") {
|
|
280
329
|
const data = JSON.parse(body);
|
|
281
330
|
this.report.env = data;
|
|
331
|
+
this.report.testCases.map((testCase) => {
|
|
332
|
+
testCase.env = data;
|
|
333
|
+
return testCase;
|
|
334
|
+
});
|
|
282
335
|
}
|
|
283
|
-
if (mediaType ===
|
|
336
|
+
if (mediaType === "application/json+log") {
|
|
284
337
|
const log = JSON.parse(body);
|
|
285
|
-
if (this.logs.length < 1000)
|
|
338
|
+
if (this.logs.length < 1000) {
|
|
286
339
|
this.logs.push(log);
|
|
340
|
+
this.stepLogs.push(log);
|
|
341
|
+
}
|
|
287
342
|
}
|
|
288
|
-
if (mediaType ===
|
|
343
|
+
if (mediaType === "application/json+network") {
|
|
289
344
|
const networkLog = JSON.parse(body);
|
|
290
345
|
if (this.networkLog.length < 1000)
|
|
291
346
|
this.networkLog.push(networkLog);
|
|
347
|
+
this.stepNetworkLogs.push(networkLog);
|
|
292
348
|
}
|
|
293
349
|
const testStep = this.testStepMap.get(testStepId);
|
|
294
350
|
if (testStep.pickleStepId === undefined)
|
|
295
351
|
return;
|
|
296
352
|
const stepProgess = this.stepReportMap.get(testStep.pickleStepId);
|
|
297
|
-
if (mediaType ===
|
|
353
|
+
if (mediaType === "application/json") {
|
|
298
354
|
const command = JSON.parse(body);
|
|
299
355
|
stepProgess.commands.push(command);
|
|
300
356
|
}
|
|
357
|
+
else if (mediaType === "application/json+trace") {
|
|
358
|
+
const data = JSON.parse(body);
|
|
359
|
+
stepProgess.traceFilePath = data.traceFilePath;
|
|
360
|
+
}
|
|
361
|
+
if (mediaType === "application/json+bruno") {
|
|
362
|
+
try {
|
|
363
|
+
const data = JSON.parse(body);
|
|
364
|
+
stepProgess.brunoData = data;
|
|
365
|
+
}
|
|
366
|
+
catch (error) {
|
|
367
|
+
console.error("Error parsing bruno data:", error);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
getFailedTestStepResult({ commands, startTime, endTime, result, }) {
|
|
372
|
+
for (const command of commands) {
|
|
373
|
+
if (command.result.status === "FAILED") {
|
|
374
|
+
return {
|
|
375
|
+
status: "FAILED",
|
|
376
|
+
message: command.result.message,
|
|
377
|
+
startTime,
|
|
378
|
+
endTime,
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
return {
|
|
383
|
+
status: "FAILED",
|
|
384
|
+
startTime,
|
|
385
|
+
endTime,
|
|
386
|
+
message: result.message,
|
|
387
|
+
};
|
|
301
388
|
}
|
|
302
389
|
onTestStepFinished(testStepFinished) {
|
|
303
390
|
const { testStepId, testStepResult, timestamp } = testStepFinished;
|
|
304
391
|
const testStep = this.testStepMap.get(testStepId);
|
|
305
392
|
if (testStep.pickleStepId === undefined) {
|
|
306
|
-
if (testStepResult.status ===
|
|
393
|
+
if (testStepResult.status === "FAILED") {
|
|
307
394
|
console.error(`Before/After hook failed with message: ${testStepResult.message}`);
|
|
308
395
|
}
|
|
309
396
|
return;
|
|
310
397
|
}
|
|
398
|
+
if (testStepResult.status === "UNDEFINED") {
|
|
399
|
+
const step = this.stepReportMap.get(testStep.pickleStepId);
|
|
400
|
+
const stepName = step ? step.keyword + " " + step.text : "Undefined step";
|
|
401
|
+
const undefinedCommand = {
|
|
402
|
+
testStepId: testStepId,
|
|
403
|
+
body: JSON.stringify({
|
|
404
|
+
type: "error",
|
|
405
|
+
text: "Undefined step: " + stepName,
|
|
406
|
+
result: {
|
|
407
|
+
status: "FAILED",
|
|
408
|
+
startTime: this.getTimeStamp(timestamp),
|
|
409
|
+
endTime: this.getTimeStamp(timestamp),
|
|
410
|
+
},
|
|
411
|
+
}),
|
|
412
|
+
mediaType: "application/json",
|
|
413
|
+
contentEncoding: messages.AttachmentContentEncoding.IDENTITY,
|
|
414
|
+
};
|
|
415
|
+
this.onAttachment(undefinedCommand);
|
|
416
|
+
}
|
|
311
417
|
const stepProgess = this.stepReportMap.get(testStep.pickleStepId);
|
|
312
418
|
const prevStepResult = stepProgess.result;
|
|
313
419
|
let data = {};
|
|
@@ -316,30 +422,85 @@ class ReportGenerator {
|
|
|
316
422
|
if (reportFolder === null) {
|
|
317
423
|
throw new Error('"reportFolder" is "null". Failed to run BVT hooks. Please retry after running "Generate All" or "Record Scenario" ');
|
|
318
424
|
}
|
|
319
|
-
if (fs_1.default.existsSync(path_1.default.join(reportFolder,
|
|
320
|
-
data = JSON.parse(fs_1.default.readFileSync(path_1.default.join(reportFolder,
|
|
425
|
+
if (fs_1.default.existsSync(path_1.default.join(reportFolder, "data.json"))) {
|
|
426
|
+
data = JSON.parse(fs_1.default.readFileSync(path_1.default.join(reportFolder, "data.json"), "utf8"));
|
|
321
427
|
}
|
|
322
428
|
}
|
|
323
429
|
catch (error) {
|
|
324
|
-
console.log(
|
|
430
|
+
console.log("Error reading data.json");
|
|
325
431
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
432
|
+
if (testStepResult.status === "FAILED") {
|
|
433
|
+
stepProgess.result = this.getFailedTestStepResult({
|
|
434
|
+
commands: stepProgess.commands,
|
|
435
|
+
startTime: prevStepResult.startTime,
|
|
436
|
+
endTime: this.getTimeStamp(timestamp),
|
|
437
|
+
result: testStepResult,
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
stepProgess.result = {
|
|
442
|
+
status: testStepResult.status,
|
|
443
|
+
startTime: prevStepResult.startTime,
|
|
444
|
+
endTime: this.getTimeStamp(timestamp),
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
stepProgess.webLog = this.stepLogs;
|
|
448
|
+
stepProgess.networkData = this.stepNetworkLogs;
|
|
449
|
+
stepProgess.ariaSnapshot = this.ariaSnapshot;
|
|
450
|
+
this.ariaSnapshot = "";
|
|
451
|
+
this.stepNetworkLogs = [];
|
|
452
|
+
this.stepLogs = [];
|
|
333
453
|
if (Object.keys(data).length > 0) {
|
|
334
454
|
stepProgess.data = data;
|
|
455
|
+
const id = testStepFinished.testCaseStartedId;
|
|
456
|
+
const parameters = this.testCaseReportMap.get(id).parameters;
|
|
457
|
+
const _parameters = {};
|
|
458
|
+
Object.keys(parameters).map((key) => {
|
|
459
|
+
if (parameters[key].startsWith("{{") && parameters[key].endsWith("}}")) {
|
|
460
|
+
const path = parameters[key].slice(2, -2).split(".");
|
|
461
|
+
let value = String(object_path_1.default.get(data, path));
|
|
462
|
+
if (value) {
|
|
463
|
+
if (value.startsWith("secret:")) {
|
|
464
|
+
value = "secret:****";
|
|
465
|
+
}
|
|
466
|
+
else if (value.startsWith("totp:")) {
|
|
467
|
+
value = "totp:****";
|
|
468
|
+
}
|
|
469
|
+
else if (value.startsWith("mask:")) {
|
|
470
|
+
value = "mask:****";
|
|
471
|
+
}
|
|
472
|
+
_parameters[key] = value;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
_parameters[key] = parameters[key];
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
this.report.testCases.find((testCase) => {
|
|
480
|
+
return testCase.id === id;
|
|
481
|
+
}).parameters = _parameters;
|
|
335
482
|
}
|
|
483
|
+
// if (process.env.TESTCASE_REPORT_FOLDER_PATH) {
|
|
484
|
+
// this.reportFolder = process.env.TESTCASE_REPORT_FOLDER_PATH
|
|
485
|
+
// if (!fs.existsSync(this.reportFolder)) {
|
|
486
|
+
// fs.mkdirSync(this.reportFolder)
|
|
487
|
+
// }
|
|
488
|
+
// const reportFilePath = path.join(
|
|
489
|
+
// this.reportFolder,
|
|
490
|
+
// `report.json`
|
|
491
|
+
// )
|
|
492
|
+
// writeFileSync(reportFilePath, JSON.stringify(this.report, null, 2))
|
|
493
|
+
// return undefined
|
|
494
|
+
// // } else {
|
|
495
|
+
// // return await this.uploadTestCase(testProgress, reRunId)
|
|
496
|
+
// }
|
|
336
497
|
}
|
|
337
498
|
getLogFileContent() {
|
|
338
499
|
let projectPath = process.cwd();
|
|
339
500
|
if (process.env.PROJECT_PATH) {
|
|
340
501
|
projectPath = process.env.PROJECT_PATH;
|
|
341
502
|
}
|
|
342
|
-
const logFolder = path_1.default.join(projectPath,
|
|
503
|
+
const logFolder = path_1.default.join(projectPath, "logs", "web");
|
|
343
504
|
if (!fs_1.default.existsSync(logFolder)) {
|
|
344
505
|
return [];
|
|
345
506
|
}
|
|
@@ -351,7 +512,7 @@ class ReportGenerator {
|
|
|
351
512
|
return [];
|
|
352
513
|
}
|
|
353
514
|
try {
|
|
354
|
-
const logFileContent = fs_1.default.readFileSync(path_1.default.join(logFolder, `${nextId - 1}.json`),
|
|
515
|
+
const logFileContent = fs_1.default.readFileSync(path_1.default.join(logFolder, `${nextId - 1}.json`), "utf8");
|
|
355
516
|
return JSON.parse(logFileContent);
|
|
356
517
|
}
|
|
357
518
|
catch (error) {
|
|
@@ -361,47 +522,69 @@ class ReportGenerator {
|
|
|
361
522
|
getTestCaseResult(steps) {
|
|
362
523
|
for (const step of steps) {
|
|
363
524
|
switch (step.result.status) {
|
|
364
|
-
case
|
|
525
|
+
case "FAILED":
|
|
365
526
|
return {
|
|
366
527
|
status: step.result.status,
|
|
367
528
|
message: step.result.message,
|
|
368
529
|
// exception: step.result.exception,
|
|
369
530
|
};
|
|
370
|
-
case
|
|
371
|
-
case
|
|
372
|
-
case
|
|
531
|
+
case "AMBIGUOUS":
|
|
532
|
+
case "UNDEFINED":
|
|
533
|
+
case "PENDING":
|
|
373
534
|
return {
|
|
374
|
-
status:
|
|
535
|
+
status: "FAILED",
|
|
375
536
|
message: `step "${step.text}" is ${step.result.status}`,
|
|
376
537
|
};
|
|
377
538
|
}
|
|
378
539
|
}
|
|
379
540
|
return {
|
|
380
|
-
status:
|
|
541
|
+
status: "PASSED",
|
|
381
542
|
};
|
|
382
543
|
}
|
|
383
|
-
async onTestCaseFinished(testCaseFinished) {
|
|
544
|
+
async onTestCaseFinished(testCaseFinished, reRunId) {
|
|
384
545
|
const { testCaseStartedId, timestamp } = testCaseFinished;
|
|
385
546
|
const testProgress = this.testCaseReportMap.get(testCaseStartedId);
|
|
386
547
|
const prevResult = testProgress.result;
|
|
387
548
|
const steps = Object.values(testProgress.steps);
|
|
388
549
|
const result = this.getTestCaseResult(steps);
|
|
550
|
+
const endTime = this.getTimeStamp(timestamp);
|
|
389
551
|
testProgress.result = {
|
|
390
552
|
...result,
|
|
391
553
|
startTime: prevResult.startTime,
|
|
392
|
-
endTime
|
|
554
|
+
endTime,
|
|
393
555
|
};
|
|
394
556
|
testProgress.webLog = this.logs;
|
|
395
557
|
testProgress.networkLog = this.networkLog;
|
|
558
|
+
testProgress.initialAriaSnapshot = this.initialAriaSnapshot;
|
|
559
|
+
this.initialAriaSnapshot = "";
|
|
396
560
|
this.networkLog = [];
|
|
397
561
|
this.logs = [];
|
|
398
|
-
|
|
562
|
+
if (process.env.TESTCASE_REPORT_FOLDER_PATH) {
|
|
563
|
+
this.reportFolder = process.env.TESTCASE_REPORT_FOLDER_PATH;
|
|
564
|
+
if (!fs_1.default.existsSync(this.reportFolder)) {
|
|
565
|
+
fs_1.default.mkdirSync(this.reportFolder);
|
|
566
|
+
}
|
|
567
|
+
const reportFilePath = path_1.default.join(this.reportFolder, `${endTime}_${testProgress.scenarioName}.json`);
|
|
568
|
+
(0, fs_extra_1.writeFileSync)(reportFilePath, JSON.stringify(testProgress, null, 2));
|
|
569
|
+
return undefined;
|
|
570
|
+
}
|
|
571
|
+
else {
|
|
572
|
+
return await this.uploadTestCase(testProgress, reRunId);
|
|
573
|
+
}
|
|
399
574
|
}
|
|
400
|
-
async uploadTestCase(testCase) {
|
|
401
|
-
let runId =
|
|
402
|
-
let projectId =
|
|
575
|
+
async uploadTestCase(testCase, rerunId) {
|
|
576
|
+
let runId = "";
|
|
577
|
+
let projectId = "";
|
|
578
|
+
if (!process.env.UPLOADING_TEST_CASE) {
|
|
579
|
+
process.env.UPLOADING_TEST_CASE = "[]";
|
|
580
|
+
}
|
|
581
|
+
const anyRemArr = JSON.parse(process.env.UPLOADING_TEST_CASE);
|
|
582
|
+
const randomID = Math.random().toString(36).substring(7);
|
|
583
|
+
anyRemArr.push(randomID);
|
|
584
|
+
let data;
|
|
585
|
+
process.env.UPLOADING_TEST_CASE = JSON.stringify(anyRemArr);
|
|
403
586
|
try {
|
|
404
|
-
if (process.env.RUN_ID && process.env.PROJECT_ID) {
|
|
587
|
+
if (process.env.RUN_ID && process.env.PROJECT_ID && !process.env.IGNORE_ENV_VARIABLES) {
|
|
405
588
|
runId = process.env.RUN_ID;
|
|
406
589
|
projectId = process.env.PROJECT_ID;
|
|
407
590
|
}
|
|
@@ -409,20 +592,52 @@ class ReportGenerator {
|
|
|
409
592
|
const runDoc = await this.uploadService.createRunDocument(this.runName);
|
|
410
593
|
runId = runDoc._id;
|
|
411
594
|
projectId = runDoc.project_id;
|
|
412
|
-
process.env.
|
|
413
|
-
|
|
595
|
+
if (!process.env.IGNORE_ENV_VARIABLES) {
|
|
596
|
+
process.env.RUN_ID = runId;
|
|
597
|
+
process.env.PROJECT_ID = projectId;
|
|
598
|
+
}
|
|
414
599
|
}
|
|
415
|
-
await this.uploadService.uploadTestCase(testCase, runId, projectId, this.reportFolder);
|
|
600
|
+
data = await this.uploadService.uploadTestCase(testCase, runId, projectId, this.reportFolder, rerunId);
|
|
601
|
+
this.writeTestCaseReportToDisk(testCase);
|
|
416
602
|
}
|
|
417
603
|
catch (e) {
|
|
418
|
-
console.error(
|
|
604
|
+
console.error("Error uploading test case:", e);
|
|
605
|
+
}
|
|
606
|
+
finally {
|
|
607
|
+
const arrRem = JSON.parse(process.env.UPLOADING_TEST_CASE);
|
|
608
|
+
arrRem.splice(arrRem.indexOf(randomID), 1);
|
|
609
|
+
process.env.UPLOADING_TEST_CASE = JSON.stringify(arrRem);
|
|
610
|
+
}
|
|
611
|
+
return data ? data : null;
|
|
612
|
+
}
|
|
613
|
+
writeTestCaseReportToDisk(testCase) {
|
|
614
|
+
var _a;
|
|
615
|
+
const reportFolder = (_a = this.reportFolder) !== null && _a !== void 0 ? _a : process.env.TESTCASE_REPORT_FOLDER_PATH;
|
|
616
|
+
if (!reportFolder) {
|
|
617
|
+
console.error("Report folder is not defined");
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
try {
|
|
621
|
+
let i = 0;
|
|
622
|
+
while (fs_1.default.existsSync(path_1.default.join(reportFolder, `${i}`))) {
|
|
623
|
+
i++;
|
|
624
|
+
}
|
|
625
|
+
fs_1.default.mkdirSync(path_1.default.join(reportFolder, `${i}`));
|
|
626
|
+
//exclude network log from the saved report
|
|
627
|
+
const networkLog = testCase.networkLog;
|
|
628
|
+
delete testCase.networkLog;
|
|
629
|
+
fs_1.default.writeFileSync(path_1.default.join(reportFolder, `${i}`, `report.json`), JSON.stringify(testCase, null, 2));
|
|
630
|
+
fs_1.default.writeFileSync(path_1.default.join(reportFolder, `${i}`, `network.json`), JSON.stringify(networkLog, null, 2));
|
|
631
|
+
}
|
|
632
|
+
catch (error) {
|
|
633
|
+
console.error("Error writing test case report to disk:", error);
|
|
419
634
|
}
|
|
420
635
|
}
|
|
421
636
|
onTestRunFinished(testRunFinished) {
|
|
422
637
|
const { timestamp, success, message } = testRunFinished;
|
|
423
638
|
const prevResult = this.report.result;
|
|
424
639
|
this.report.result = {
|
|
425
|
-
status: success ?
|
|
640
|
+
status: success ? "PASSED" : "FAILED",
|
|
426
641
|
startTime: prevResult.startTime,
|
|
427
642
|
endTime: this.getTimeStamp(timestamp),
|
|
428
643
|
message,
|