-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcypress-cucumber-html-report.js
44 lines (41 loc) · 1.33 KB
/
cypress-cucumber-html-report.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
const report = require('multiple-cucumber-html-reporter');
const fs = require('fs');
const data = fs.readFileSync('./cypress/.run/results.json', { encoding: 'utf8', flag: 'r' });
const runInfos = JSON.parse(data);
let mapOs = (os) => {
if(os.startsWith('win')) {
return 'windows';
} else if (os.startsWith('darwin')) {
return 'osx';
} else if (os.startsWith('linux')) {
return 'linux';
} else if (os.startsWith('ubuntu')) {
return 'ubuntu';
} else if (os.startsWith('android')) {
return 'android';
} else if (os.startsWith('ios')) {
return 'ios';
}
};
report.generate({
jsonDir: './cypress/.run/reports/json/',
reportPath: './cypress/.run/html-report/',
metadata:{
browser: {
name: runInfos.browserName === 'chromium' ? 'chrome' : runInfos.browserName,
version: runInfos.browserVersion
},
device: 'Cypress',
platform: {
name: mapOs(runInfos.osName)
}
},
customData: {
title: 'Run info',
data: [
{label: 'Project', value: 'Todolist'},
{label: 'Execution Start Time', value: new Date(runInfos.startedTestsAt).toLocaleString()},
{label: 'Execution End Time', value: new Date(runInfos.endedTestsAt).toLocaleString()}
]
}
});