@dev-blinq/cucumber-js 1.0.98-dev → 1.0.98
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 +8 -0
- package/lib/configuration/axios_client.js +1 -1
- package/lib/configuration/axios_client.js.map +1 -1
- package/lib/formatter/bvt_analysis_formatter.d.ts +12 -1
- package/lib/formatter/bvt_analysis_formatter.js +169 -73
- 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 +44 -0
- package/lib/formatter/helpers/constants.js +50 -0
- package/lib/formatter/helpers/constants.js.map +1 -0
- package/lib/formatter/helpers/report_generator.d.ts +24 -2
- package/lib/formatter/helpers/report_generator.js +205 -13
- 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 +14 -0
- package/lib/formatter/helpers/upload_serivce.js +112 -0
- 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 +36 -7
- package/lib/formatter/helpers/uploader.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 +2 -2
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare const LOCAL: {
|
|
2
|
+
SSO: string;
|
|
3
|
+
WORKSPACE: string;
|
|
4
|
+
RUNS: string;
|
|
5
|
+
STORAGE: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const DEV: {
|
|
8
|
+
SSO: string;
|
|
9
|
+
WORKSPACE: string;
|
|
10
|
+
RUNS: string;
|
|
11
|
+
STORAGE: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const PROD: {
|
|
14
|
+
SSO: string;
|
|
15
|
+
WORKSPACE: string;
|
|
16
|
+
RUNS: string;
|
|
17
|
+
STORAGE: string;
|
|
18
|
+
};
|
|
19
|
+
export declare const STAGE: {
|
|
20
|
+
SSO: string;
|
|
21
|
+
WORKSPACE: string;
|
|
22
|
+
RUNS: string;
|
|
23
|
+
STORAGE: string;
|
|
24
|
+
};
|
|
25
|
+
export declare const SERVICES_URI: {
|
|
26
|
+
SSO: string;
|
|
27
|
+
WORKSPACE: string;
|
|
28
|
+
RUNS: string;
|
|
29
|
+
STORAGE: string;
|
|
30
|
+
};
|
|
31
|
+
export declare enum ActionEvents {
|
|
32
|
+
record_scenario = "record_scenario",
|
|
33
|
+
download_editor = "download_editor",
|
|
34
|
+
launch_editor = "launch_editor",
|
|
35
|
+
click_start_recording = "click_start_recording",
|
|
36
|
+
click_run_scenario = "click_run_scenario",
|
|
37
|
+
publish_scenario = "publish_scenario",
|
|
38
|
+
click_ai_generate = "click_ai_generate",
|
|
39
|
+
click_run_all = "click_run_all",
|
|
40
|
+
click_open_vscode = "click_open_vscode",
|
|
41
|
+
error_open_vscode = "error_open_vscode",
|
|
42
|
+
cli_run_tests = "cli_run_tests",
|
|
43
|
+
upload_report = "upload_report"
|
|
44
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ActionEvents = exports.SERVICES_URI = exports.STAGE = exports.PROD = exports.DEV = exports.LOCAL = void 0;
|
|
4
|
+
exports.LOCAL = {
|
|
5
|
+
SSO: 'http://localhost:5000/api/auth',
|
|
6
|
+
WORKSPACE: 'http://localhost:6000/api/workspace',
|
|
7
|
+
RUNS: 'http://localhost:5001/api/runs',
|
|
8
|
+
STORAGE: 'http://localhost:5050/api/storage',
|
|
9
|
+
};
|
|
10
|
+
exports.DEV = {
|
|
11
|
+
SSO: 'https://dev.api.blinq.io/api/auth',
|
|
12
|
+
WORKSPACE: 'https://dev.api.blinq.io/api/workspace',
|
|
13
|
+
RUNS: 'https://dev.api.blinq.io/api/runs',
|
|
14
|
+
STORAGE: 'https://dev.api.blinq.io/api/storage',
|
|
15
|
+
};
|
|
16
|
+
exports.PROD = {
|
|
17
|
+
SSO: 'https://api.blinq.io/api/auth',
|
|
18
|
+
WORKSPACE: 'https://api.blinq.io/api/workspace',
|
|
19
|
+
RUNS: 'https://api.blinq.io/api/runs',
|
|
20
|
+
STORAGE: 'https://api.blinq.io/api/storage',
|
|
21
|
+
};
|
|
22
|
+
exports.STAGE = {
|
|
23
|
+
SSO: 'https://stage.api.blinq.io/api/auth',
|
|
24
|
+
WORKSPACE: 'https://stage.api.blinq.io/api/workspace',
|
|
25
|
+
RUNS: 'https://stage.api.blinq.io/api/runs',
|
|
26
|
+
STORAGE: 'https://stage.api.blinq.io/api/storage',
|
|
27
|
+
};
|
|
28
|
+
exports.SERVICES_URI = process.env.NODE_ENV_BLINQ === 'local'
|
|
29
|
+
? exports.LOCAL // eslint-disable-line
|
|
30
|
+
: process.env.NODE_ENV_BLINQ === 'dev'
|
|
31
|
+
? exports.DEV // eslint-disable-line
|
|
32
|
+
: process.env.NODE_ENV_BLINQ === 'stage'
|
|
33
|
+
? exports.STAGE
|
|
34
|
+
: exports.PROD; // eslint-disable-line
|
|
35
|
+
var ActionEvents;
|
|
36
|
+
(function (ActionEvents) {
|
|
37
|
+
ActionEvents["record_scenario"] = "record_scenario";
|
|
38
|
+
ActionEvents["download_editor"] = "download_editor";
|
|
39
|
+
ActionEvents["launch_editor"] = "launch_editor";
|
|
40
|
+
ActionEvents["click_start_recording"] = "click_start_recording";
|
|
41
|
+
ActionEvents["click_run_scenario"] = "click_run_scenario";
|
|
42
|
+
ActionEvents["publish_scenario"] = "publish_scenario";
|
|
43
|
+
ActionEvents["click_ai_generate"] = "click_ai_generate";
|
|
44
|
+
ActionEvents["click_run_all"] = "click_run_all";
|
|
45
|
+
ActionEvents["click_open_vscode"] = "click_open_vscode";
|
|
46
|
+
ActionEvents["error_open_vscode"] = "error_open_vscode";
|
|
47
|
+
ActionEvents["cli_run_tests"] = "cli_run_tests";
|
|
48
|
+
ActionEvents["upload_report"] = "upload_report";
|
|
49
|
+
})(ActionEvents = exports.ActionEvents || (exports.ActionEvents = {}));
|
|
50
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/formatter/helpers/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,KAAK,GAAG;IACnB,GAAG,EAAE,gCAAgC;IACrC,SAAS,EAAE,qCAAqC;IAChD,IAAI,EAAE,gCAAgC;IACtC,OAAO,EAAE,mCAAmC;CAC7C,CAAA;AACY,QAAA,GAAG,GAAG;IACjB,GAAG,EAAE,mCAAmC;IACxC,SAAS,EAAE,wCAAwC;IACnD,IAAI,EAAE,mCAAmC;IACzC,OAAO,EAAE,sCAAsC;CAChD,CAAA;AACY,QAAA,IAAI,GAAG;IAClB,GAAG,EAAE,+BAA+B;IACpC,SAAS,EAAE,oCAAoC;IAC/C,IAAI,EAAE,+BAA+B;IACrC,OAAO,EAAE,kCAAkC;CAC5C,CAAA;AACY,QAAA,KAAK,GAAG;IACnB,GAAG,EAAE,qCAAqC;IAC1C,SAAS,EAAE,0CAA0C;IACrD,IAAI,EAAE,qCAAqC;IAC3C,OAAO,EAAE,wCAAwC;CAClD,CAAA;AAEY,QAAA,YAAY,GACvB,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,OAAO;IACpC,CAAC,CAAC,aAAK,CAAC,sBAAsB;IAC9B,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,KAAK;QACtC,CAAC,CAAC,WAAG,CAAC,sBAAsB;QAC5B,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,OAAO;YACxC,CAAC,CAAC,aAAK;YACP,CAAC,CAAC,YAAI,CAAA,CAAC,sBAAsB;AAEjC,IAAY,YAaX;AAbD,WAAY,YAAY;IACtB,mDAAmC,CAAA;IACnC,mDAAmC,CAAA;IACnC,+CAA+B,CAAA;IAC/B,+DAA+C,CAAA;IAC/C,yDAAyC,CAAA;IACzC,qDAAqC,CAAA;IACrC,uDAAuC,CAAA;IACvC,+CAA+B,CAAA;IAC/B,uDAAuC,CAAA;IACvC,uDAAuC,CAAA;IACvC,+CAA+B,CAAA;IAC/B,+CAA+B,CAAA;AACjC,CAAC,EAbW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAavB","sourcesContent":["export const LOCAL = {\n SSO: 'http://localhost:5000/api/auth',\n WORKSPACE: 'http://localhost:6000/api/workspace',\n RUNS: 'http://localhost:5001/api/runs',\n STORAGE: 'http://localhost:5050/api/storage',\n}\nexport const DEV = {\n SSO: 'https://dev.api.blinq.io/api/auth',\n WORKSPACE: 'https://dev.api.blinq.io/api/workspace',\n RUNS: 'https://dev.api.blinq.io/api/runs',\n STORAGE: 'https://dev.api.blinq.io/api/storage',\n}\nexport const PROD = {\n SSO: 'https://api.blinq.io/api/auth',\n WORKSPACE: 'https://api.blinq.io/api/workspace',\n RUNS: 'https://api.blinq.io/api/runs',\n STORAGE: 'https://api.blinq.io/api/storage',\n}\nexport const STAGE = {\n SSO: 'https://stage.api.blinq.io/api/auth',\n WORKSPACE: 'https://stage.api.blinq.io/api/workspace',\n RUNS: 'https://stage.api.blinq.io/api/runs',\n STORAGE: 'https://stage.api.blinq.io/api/storage',\n}\n\nexport const SERVICES_URI =\n process.env.NODE_ENV_BLINQ === 'local'\n ? LOCAL // eslint-disable-line\n : process.env.NODE_ENV_BLINQ === 'dev'\n ? DEV // eslint-disable-line\n : process.env.NODE_ENV_BLINQ === 'stage'\n ? STAGE\n : PROD // eslint-disable-line\n\nexport enum ActionEvents {\n record_scenario = 'record_scenario',\n download_editor = 'download_editor',\n launch_editor = 'launch_editor',\n click_start_recording = 'click_start_recording',\n click_run_scenario = 'click_run_scenario',\n publish_scenario = 'publish_scenario',\n click_ai_generate = 'click_ai_generate',\n click_run_all = 'click_run_all',\n click_open_vscode = 'click_open_vscode',\n error_open_vscode = 'error_open_vscode',\n cli_run_tests = 'cli_run_tests',\n upload_report = 'upload_report',\n}\n"]}
|
|
@@ -48,7 +48,6 @@ type JsonCommand = {
|
|
|
48
48
|
text: string;
|
|
49
49
|
screenshotId?: string;
|
|
50
50
|
result: JsonCommandResult;
|
|
51
|
-
webLog?: webLog[];
|
|
52
51
|
netWorkLog?: any[];
|
|
53
52
|
};
|
|
54
53
|
type webLog = {
|
|
@@ -63,7 +62,10 @@ export type JsonStep = {
|
|
|
63
62
|
text: string;
|
|
64
63
|
commands: JsonCommand[];
|
|
65
64
|
result: JsonStepResult;
|
|
65
|
+
webLog: webLog[];
|
|
66
|
+
networkData: any[];
|
|
66
67
|
data?: any;
|
|
68
|
+
ariaSnapshot: string;
|
|
67
69
|
};
|
|
68
70
|
export type RetrainStats = {
|
|
69
71
|
result: JsonTestResult;
|
|
@@ -80,8 +82,13 @@ export type JsonTestProgress = {
|
|
|
80
82
|
steps: JsonStep[];
|
|
81
83
|
result: JsonTestResult;
|
|
82
84
|
retrainStats?: RetrainStats;
|
|
85
|
+
initialAriaSnapshot?: string;
|
|
83
86
|
webLog: any;
|
|
84
87
|
networkLog: any;
|
|
88
|
+
env: {
|
|
89
|
+
name: string;
|
|
90
|
+
baseUrl: string;
|
|
91
|
+
};
|
|
85
92
|
};
|
|
86
93
|
export type JsonReport = {
|
|
87
94
|
testCases: JsonTestProgress[];
|
|
@@ -91,6 +98,12 @@ export type JsonReport = {
|
|
|
91
98
|
baseUrl: string;
|
|
92
99
|
};
|
|
93
100
|
};
|
|
101
|
+
interface MetaMessage extends messages.Meta {
|
|
102
|
+
runName: string;
|
|
103
|
+
}
|
|
104
|
+
interface EnvelopeWithMetaMessage extends messages.Envelope {
|
|
105
|
+
meta: MetaMessage;
|
|
106
|
+
}
|
|
94
107
|
export default class ReportGenerator {
|
|
95
108
|
private report;
|
|
96
109
|
private gherkinDocumentMap;
|
|
@@ -103,8 +116,14 @@ export default class ReportGenerator {
|
|
|
103
116
|
private scenarioIterationCountMap;
|
|
104
117
|
private logs;
|
|
105
118
|
private networkLog;
|
|
119
|
+
private stepLogs;
|
|
120
|
+
private stepNetworkLogs;
|
|
121
|
+
private runName;
|
|
122
|
+
private ariaSnapshot;
|
|
123
|
+
private initialAriaSnapshot;
|
|
106
124
|
reportFolder: null | string;
|
|
107
|
-
|
|
125
|
+
private uploadService;
|
|
126
|
+
handleMessage(envelope: EnvelopeWithMetaMessage | messages.Envelope, reRunId?: string): Promise<any>;
|
|
108
127
|
getReport(): JsonReport;
|
|
109
128
|
private handleParseError;
|
|
110
129
|
private onGherkinDocument;
|
|
@@ -117,10 +136,13 @@ export default class ReportGenerator {
|
|
|
117
136
|
private onTestCaseStarted;
|
|
118
137
|
private onTestStepStarted;
|
|
119
138
|
private onAttachment;
|
|
139
|
+
private getFailedTestStepResult;
|
|
120
140
|
private onTestStepFinished;
|
|
121
141
|
getLogFileContent(): any;
|
|
122
142
|
private getTestCaseResult;
|
|
123
143
|
private onTestCaseFinished;
|
|
144
|
+
private uploadTestCase;
|
|
145
|
+
private writeTestCaseReportToDisk;
|
|
124
146
|
private onTestRunFinished;
|
|
125
147
|
}
|
|
126
148
|
export {};
|
|
@@ -1,10 +1,48 @@
|
|
|
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
|
};
|
|
28
|
+
var _a, _b;
|
|
5
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
const messages = __importStar(require("@cucumber/messages"));
|
|
6
31
|
const fs_1 = __importDefault(require("fs"));
|
|
7
32
|
const path_1 = __importDefault(require("path"));
|
|
33
|
+
const upload_serivce_1 = require("./upload_serivce");
|
|
34
|
+
const fs_extra_1 = require("fs-extra");
|
|
35
|
+
const URL = process.env.NODE_ENV_BLINQ === 'dev'
|
|
36
|
+
? 'https://dev.api.blinq.io/api/runs'
|
|
37
|
+
: process.env.NODE_ENV_BLINQ === 'local'
|
|
38
|
+
? 'http://localhost:5001/api/runs'
|
|
39
|
+
: process.env.NODE_ENV_BLINQ === 'stage'
|
|
40
|
+
? 'https://stage.api.blinq.io/api/runs'
|
|
41
|
+
: 'https://api.blinq.io/api/runs';
|
|
42
|
+
const REPORT_SERVICE_URL = (_a = process.env.REPORT_SERVICE_URL) !== null && _a !== void 0 ? _a : URL;
|
|
43
|
+
const BATCH_SIZE = 10;
|
|
44
|
+
const MAX_RETRIES = 3;
|
|
45
|
+
const REPORT_SERVICE_TOKEN = (_b = process.env.TOKEN) !== null && _b !== void 0 ? _b : process.env.REPORT_SERVICE_TOKEN;
|
|
8
46
|
class ReportGenerator {
|
|
9
47
|
constructor() {
|
|
10
48
|
this.report = {
|
|
@@ -27,9 +65,18 @@ class ReportGenerator {
|
|
|
27
65
|
this.scenarioIterationCountMap = new Map();
|
|
28
66
|
this.logs = [];
|
|
29
67
|
this.networkLog = [];
|
|
68
|
+
this.stepLogs = [];
|
|
69
|
+
this.stepNetworkLogs = [];
|
|
70
|
+
this.runName = '';
|
|
71
|
+
this.ariaSnapshot = '';
|
|
72
|
+
this.initialAriaSnapshot = '';
|
|
30
73
|
this.reportFolder = null;
|
|
74
|
+
this.uploadService = new upload_serivce_1.RunUploadService(REPORT_SERVICE_URL, REPORT_SERVICE_TOKEN);
|
|
31
75
|
}
|
|
32
|
-
handleMessage(envelope) {
|
|
76
|
+
async handleMessage(envelope, reRunId) {
|
|
77
|
+
if (envelope.meta && 'runName' in envelope.meta) {
|
|
78
|
+
this.runName = envelope.meta.runName;
|
|
79
|
+
}
|
|
33
80
|
const type = Object.keys(envelope)[0];
|
|
34
81
|
switch (type) {
|
|
35
82
|
// case "meta": { break}
|
|
@@ -83,8 +130,7 @@ class ReportGenerator {
|
|
|
83
130
|
}
|
|
84
131
|
case 'testCaseFinished': {
|
|
85
132
|
const testCaseFinished = envelope[type];
|
|
86
|
-
this.onTestCaseFinished(testCaseFinished);
|
|
87
|
-
break;
|
|
133
|
+
return await this.onTestCaseFinished(testCaseFinished, reRunId);
|
|
88
134
|
}
|
|
89
135
|
// case "hook": { break} // After Hook
|
|
90
136
|
case 'testRunFinished': {
|
|
@@ -220,6 +266,10 @@ class ReportGenerator {
|
|
|
220
266
|
result: {
|
|
221
267
|
status: 'UNKNOWN',
|
|
222
268
|
},
|
|
269
|
+
networkData: [],
|
|
270
|
+
webLog: [],
|
|
271
|
+
data: {},
|
|
272
|
+
ariaSnapshot: this.ariaSnapshot,
|
|
223
273
|
});
|
|
224
274
|
return this.stepReportMap.get(pickleStep.id);
|
|
225
275
|
});
|
|
@@ -236,6 +286,10 @@ class ReportGenerator {
|
|
|
236
286
|
},
|
|
237
287
|
webLog: [],
|
|
238
288
|
networkLog: [],
|
|
289
|
+
env: {
|
|
290
|
+
name: this.report.env.name,
|
|
291
|
+
baseUrl: this.report.env.baseUrl,
|
|
292
|
+
},
|
|
239
293
|
});
|
|
240
294
|
this.report.testCases.push(this.testCaseReportMap.get(id));
|
|
241
295
|
}
|
|
@@ -258,19 +312,34 @@ class ReportGenerator {
|
|
|
258
312
|
this.reportFolder = body.replaceAll('\\', '/');
|
|
259
313
|
return;
|
|
260
314
|
}
|
|
315
|
+
if (mediaType === 'application/json+snapshot-before') {
|
|
316
|
+
this.initialAriaSnapshot = body;
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
if (mediaType === 'application/json+snapshot-after') {
|
|
320
|
+
this.ariaSnapshot = body;
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
261
323
|
if (mediaType === 'application/json+env') {
|
|
262
324
|
const data = JSON.parse(body);
|
|
263
325
|
this.report.env = data;
|
|
326
|
+
this.report.testCases.map((testCase) => {
|
|
327
|
+
testCase.env = data;
|
|
328
|
+
return testCase;
|
|
329
|
+
});
|
|
264
330
|
}
|
|
265
331
|
if (mediaType === 'application/json+log') {
|
|
266
332
|
const log = JSON.parse(body);
|
|
267
|
-
if (this.logs.length < 1000)
|
|
333
|
+
if (this.logs.length < 1000) {
|
|
268
334
|
this.logs.push(log);
|
|
335
|
+
this.stepLogs.push(log);
|
|
336
|
+
}
|
|
269
337
|
}
|
|
270
338
|
if (mediaType === 'application/json+network') {
|
|
271
339
|
const networkLog = JSON.parse(body);
|
|
272
340
|
if (this.networkLog.length < 1000)
|
|
273
341
|
this.networkLog.push(networkLog);
|
|
342
|
+
this.stepNetworkLogs.push(networkLog);
|
|
274
343
|
}
|
|
275
344
|
const testStep = this.testStepMap.get(testStepId);
|
|
276
345
|
if (testStep.pickleStepId === undefined)
|
|
@@ -281,6 +350,24 @@ class ReportGenerator {
|
|
|
281
350
|
stepProgess.commands.push(command);
|
|
282
351
|
}
|
|
283
352
|
}
|
|
353
|
+
getFailedTestStepResult({ commands, startTime, endTime, result, }) {
|
|
354
|
+
for (const command of commands) {
|
|
355
|
+
if (command.result.status === 'FAILED') {
|
|
356
|
+
return {
|
|
357
|
+
status: 'FAILED',
|
|
358
|
+
message: command.result.message,
|
|
359
|
+
startTime,
|
|
360
|
+
endTime,
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
return {
|
|
365
|
+
status: 'FAILED',
|
|
366
|
+
startTime,
|
|
367
|
+
endTime,
|
|
368
|
+
message: result.message,
|
|
369
|
+
};
|
|
370
|
+
}
|
|
284
371
|
onTestStepFinished(testStepFinished) {
|
|
285
372
|
const { testStepId, testStepResult, timestamp } = testStepFinished;
|
|
286
373
|
const testStep = this.testStepMap.get(testStepId);
|
|
@@ -290,6 +377,25 @@ class ReportGenerator {
|
|
|
290
377
|
}
|
|
291
378
|
return;
|
|
292
379
|
}
|
|
380
|
+
if (testStepResult.status === 'UNDEFINED') {
|
|
381
|
+
const step = this.stepReportMap.get(testStep.pickleStepId);
|
|
382
|
+
const stepName = step ? step.keyword + ' ' + step.text : 'Undefined step';
|
|
383
|
+
const undefinedCommand = {
|
|
384
|
+
testStepId: testStepId,
|
|
385
|
+
body: JSON.stringify({
|
|
386
|
+
type: 'error',
|
|
387
|
+
text: 'Undefined step: ' + stepName,
|
|
388
|
+
result: {
|
|
389
|
+
status: 'FAILED',
|
|
390
|
+
startTime: this.getTimeStamp(timestamp),
|
|
391
|
+
endTime: this.getTimeStamp(timestamp),
|
|
392
|
+
},
|
|
393
|
+
}),
|
|
394
|
+
mediaType: 'application/json',
|
|
395
|
+
contentEncoding: messages.AttachmentContentEncoding.IDENTITY,
|
|
396
|
+
};
|
|
397
|
+
this.onAttachment(undefinedCommand);
|
|
398
|
+
}
|
|
293
399
|
const stepProgess = this.stepReportMap.get(testStep.pickleStepId);
|
|
294
400
|
const prevStepResult = stepProgess.result;
|
|
295
401
|
let data = {};
|
|
@@ -305,13 +411,27 @@ class ReportGenerator {
|
|
|
305
411
|
catch (error) {
|
|
306
412
|
console.log('Error reading data.json');
|
|
307
413
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
414
|
+
if (testStepResult.status === 'FAILED') {
|
|
415
|
+
stepProgess.result = this.getFailedTestStepResult({
|
|
416
|
+
commands: stepProgess.commands,
|
|
417
|
+
startTime: prevStepResult.startTime,
|
|
418
|
+
endTime: this.getTimeStamp(timestamp),
|
|
419
|
+
result: testStepResult,
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
stepProgess.result = {
|
|
424
|
+
status: testStepResult.status,
|
|
425
|
+
startTime: prevStepResult.startTime,
|
|
426
|
+
endTime: this.getTimeStamp(timestamp),
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
stepProgess.webLog = this.stepLogs;
|
|
430
|
+
stepProgess.networkData = this.stepNetworkLogs;
|
|
431
|
+
stepProgess.ariaSnapshot = this.ariaSnapshot;
|
|
432
|
+
this.ariaSnapshot = '';
|
|
433
|
+
this.stepNetworkLogs = [];
|
|
434
|
+
this.stepLogs = [];
|
|
315
435
|
if (Object.keys(data).length > 0) {
|
|
316
436
|
stepProgess.data = data;
|
|
317
437
|
}
|
|
@@ -362,21 +482,93 @@ class ReportGenerator {
|
|
|
362
482
|
status: 'PASSED',
|
|
363
483
|
};
|
|
364
484
|
}
|
|
365
|
-
onTestCaseFinished(testCaseFinished) {
|
|
485
|
+
async onTestCaseFinished(testCaseFinished, reRunId) {
|
|
366
486
|
const { testCaseStartedId, timestamp } = testCaseFinished;
|
|
367
487
|
const testProgress = this.testCaseReportMap.get(testCaseStartedId);
|
|
368
488
|
const prevResult = testProgress.result;
|
|
369
489
|
const steps = Object.values(testProgress.steps);
|
|
370
490
|
const result = this.getTestCaseResult(steps);
|
|
491
|
+
const endTime = this.getTimeStamp(timestamp);
|
|
371
492
|
testProgress.result = {
|
|
372
493
|
...result,
|
|
373
494
|
startTime: prevResult.startTime,
|
|
374
|
-
endTime
|
|
495
|
+
endTime,
|
|
375
496
|
};
|
|
376
497
|
testProgress.webLog = this.logs;
|
|
377
498
|
testProgress.networkLog = this.networkLog;
|
|
499
|
+
testProgress.initialAriaSnapshot = this.initialAriaSnapshot;
|
|
500
|
+
this.initialAriaSnapshot = '';
|
|
378
501
|
this.networkLog = [];
|
|
379
502
|
this.logs = [];
|
|
503
|
+
if (process.env.TESTCASE_REPORT_FOLDER_PATH) {
|
|
504
|
+
this.reportFolder = process.env.TESTCASE_REPORT_FOLDER_PATH;
|
|
505
|
+
if (!fs_1.default.existsSync(this.reportFolder)) {
|
|
506
|
+
fs_1.default.mkdirSync(this.reportFolder);
|
|
507
|
+
}
|
|
508
|
+
const reportFilePath = path_1.default.join(this.reportFolder, `${endTime}_${testProgress.scenarioName}.json`);
|
|
509
|
+
(0, fs_extra_1.writeFileSync)(reportFilePath, JSON.stringify(testProgress, null, 2));
|
|
510
|
+
return undefined;
|
|
511
|
+
}
|
|
512
|
+
else {
|
|
513
|
+
return await this.uploadTestCase(testProgress, reRunId);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
async uploadTestCase(testCase, rerunId) {
|
|
517
|
+
let runId = '';
|
|
518
|
+
let projectId = '';
|
|
519
|
+
if (!process.env.UPLOADING_TEST_CASE) {
|
|
520
|
+
process.env.UPLOADING_TEST_CASE = '[]';
|
|
521
|
+
}
|
|
522
|
+
const anyRemArr = JSON.parse(process.env.UPLOADING_TEST_CASE);
|
|
523
|
+
const randomID = Math.random().toString(36).substring(7);
|
|
524
|
+
anyRemArr.push(randomID);
|
|
525
|
+
let data;
|
|
526
|
+
process.env.UPLOADING_TEST_CASE = JSON.stringify(anyRemArr);
|
|
527
|
+
try {
|
|
528
|
+
if (process.env.RUN_ID &&
|
|
529
|
+
process.env.PROJECT_ID &&
|
|
530
|
+
!process.env.IGNORE_ENV_VARIABLES) {
|
|
531
|
+
runId = process.env.RUN_ID;
|
|
532
|
+
projectId = process.env.PROJECT_ID;
|
|
533
|
+
}
|
|
534
|
+
else {
|
|
535
|
+
const runDoc = await this.uploadService.createRunDocument(this.runName);
|
|
536
|
+
runId = runDoc._id;
|
|
537
|
+
projectId = runDoc.project_id;
|
|
538
|
+
if (!process.env.IGNORE_ENV_VARIABLES) {
|
|
539
|
+
process.env.RUN_ID = runId;
|
|
540
|
+
process.env.PROJECT_ID = projectId;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
data = await this.uploadService.uploadTestCase(testCase, runId, projectId, this.reportFolder, rerunId);
|
|
544
|
+
this.writeTestCaseReportToDisk(testCase);
|
|
545
|
+
}
|
|
546
|
+
catch (e) {
|
|
547
|
+
console.error('Error uploading test case:', e);
|
|
548
|
+
}
|
|
549
|
+
finally {
|
|
550
|
+
const arrRem = JSON.parse(process.env.UPLOADING_TEST_CASE);
|
|
551
|
+
arrRem.splice(arrRem.indexOf(randomID), 1);
|
|
552
|
+
process.env.UPLOADING_TEST_CASE = JSON.stringify(arrRem);
|
|
553
|
+
}
|
|
554
|
+
return data ? data : null;
|
|
555
|
+
}
|
|
556
|
+
writeTestCaseReportToDisk(testCase) {
|
|
557
|
+
try {
|
|
558
|
+
let i = 0;
|
|
559
|
+
while (fs_1.default.existsSync(path_1.default.join(this.reportFolder, `${i}`))) {
|
|
560
|
+
i++;
|
|
561
|
+
}
|
|
562
|
+
fs_1.default.mkdirSync(path_1.default.join(this.reportFolder, `${i}`));
|
|
563
|
+
//exclude network log from the saved report
|
|
564
|
+
const networkLog = testCase.networkLog;
|
|
565
|
+
delete testCase.networkLog;
|
|
566
|
+
fs_1.default.writeFileSync(path_1.default.join(this.reportFolder, `${i}`, `report.json`), JSON.stringify(testCase, null, 2));
|
|
567
|
+
fs_1.default.writeFileSync(path_1.default.join(this.reportFolder, `${i}`, `network.json`), JSON.stringify(networkLog, null, 2));
|
|
568
|
+
}
|
|
569
|
+
catch (error) {
|
|
570
|
+
console.error('Error writing test case report to disk:', error);
|
|
571
|
+
}
|
|
380
572
|
}
|
|
381
573
|
onTestRunFinished(testRunFinished) {
|
|
382
574
|
const { timestamp, success, message } = testRunFinished;
|