-
Notifications
You must be signed in to change notification settings - Fork 0
/
reporter.js
83 lines (61 loc) · 2.51 KB
/
reporter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
var reporter = require('cucumber-html-reporter');
const cukemerge = require('cucumber-json-merge');
const fs = require('fs');
try{
if(fs.existsSync('test-results/cucumber_reportRerun.json')){
const jsonData = fs.readFileSync('test-results/cucumber_reportRerun.json', 'utf8');
const jsonArray = JSON.parse(jsonData);
const textToPrepend = ' Rerun_';
for (const obj of jsonArray) {
obj.name = textToPrepend + obj.name;
}
const updatedJsonData = JSON.stringify(jsonArray, null, 2);
fs.writeFileSync('test-results/cucumber_reportRerun.json', updatedJsonData, 'utf8');
}
let filenames = cukemerge.listJsonFiles('test-results', false);
const filenameSubstringsToRemove = [ 'merged_cucumber_report.json'];
filenames = filenames.filter((filename) => !filenameSubstringsToRemove.some((substring) => filename.includes(substring)));
const merged = cukemerge.mergeFiles(filenames);
cukemerge.writeMergedFile(`test-results/merged_cucumber_report.json`, merged, 'test-results');
const options = {
theme: 'bootstrap',
jsonFile: 'test-results/merged_cucumber_report.json',
output: 'test-results/merged_cucumber_report.html',
reportSuiteAsScenarios: true,
scenarioTimestamp: true,
launchReport: true,
metadata: {
"App Version":"0.3.2",
"Test Environment": "STAGING",
"Browser": "Chrome 54.0.2840.98",
"Platform": "Windows 10",
'Test executed at': new Date().toJSON().slice(0, 16).replace(':', '-'),
"Parallel": "Scenarios",
"Executed": "Remote"
},
failedSummaryReport: true,
};
reporter.generate(options);
}
catch (e){
throw new Error('error in report generation.Check into the test-esults folder fro json file =>',e)
}
// var options = {
// theme: 'bootstrap',
// jsonFile: 'test-results/cucumber_report.json',
// output: 'test-results/merged_cucumber_report.html',
// reportSuiteAsScenarios: true,
// scenarioTimestamp: true,
// launchReport: true,
// metadata: {
// "App Version":"0.3.2",
// "Test Environment": "STAGING",
// "Browser": "Chrome 54.0.2840.98",
// "Platform": "Windows 10",
// 'Test executed at': new Date().toJSON().slice(0, 16).replace(':', '-'),
// "Parallel": "Scenarios",
// "Executed": "Remote"
// },
// failedSummaryReport: true,
// };
// reporter.generate(options);