-
Notifications
You must be signed in to change notification settings - Fork 42
/
cucumber.report.conf.js
104 lines (86 loc) · 2.51 KB
/
cucumber.report.conf.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
const report = require('multiple-cucumber-html-reporter');
const customData = {
title: 'Run info',
data: [
{
label: 'Project',
value: 'Web automation'
},
{
label: 'Generated on:',
value: new Date().toUTCString()
},
{
label: 'Reporter:',
value: '<a href="https://www.npmjs.com/package/multiple-cucumber-html-reporter" ' +
'target="_blank">multiple-cucumber-html-reporter</a>'
},
]
};
report.generate({
jsonDir: './report/cucumber/',
reportPath: './report/cucumber/html',
displayDuration: true,
removeFolders: true,
pageTitle: 'Web Automation Framework',
reportName: 'Web Automation Framework',
openReportInBrowser: true,
pageFooter:
'<div class="created-by"><p>Powered by © <a href="https://labs42.io" target="_blank">Labs42</a></p></div>',
customData: addCIMetadata(customData),
});
function addCIMetadata(customData) {
customData.data = customData.data
.concat(...fromCircleCI())
.concat(...fromGithubActions())
.concat(...fromTravis());
return customData;
}
function* fromCircleCI() {
if (process.env.CIRCLECI) {
yield { label: 'CI', value: 'CircleCI' };
}
if (process.env.CIRCLE_BRANCH) {
yield { label: 'Branch', value: process.env.CIRCLE_BRANCH };
}
if (process.env.CIRCLE_SHA1) {
yield { label: 'Commit', value: process.env.CIRCLE_SHA1 }
}
if (process.env.CIRCLE_BUILD_NUM) {
yield {
label: 'Build',
value: `<a href="${process.env.CIRCLE_BUILD_URL}" target="_blank">${process.env.CIRCLE_BUILD_NUM}</a>`
};
}
}
function* fromGithubActions() {
if (process.env.GITHUB_ACTIONS) {
yield { label: 'CI', value: 'Github Actions' };
}
if (process.env.GITHUB_REF) {
yield { label: 'Branch', value: process.env.GITHUB_REF.replace('refs/heads/', '') };
}
if (process.env.GITHUB_SHA) {
yield { label: 'Commit', value: process.env.GITHUB_SHA }
}
if (process.env.GITHUB_RUN_NUMBER) {
yield { label: 'Run', value: process.env.GITHUB_RUN_NUMBER };
}
}
function* fromTravis() {
if (process.env.TRAVIS) {
yield { label: 'CI', value: 'TravisCI' };
}
if (process.env.TRAVIS_BRANCH) {
yield { label: 'Branch', value: process.env.TRAVIS_BRANCH }
}
if (process.env.TRAVIS_COMMIT) {
yield { label: 'Commit', value: process.env.TRAVIS_COMMIT };
}
if (process.env.TRAVIS_BUILD_NUMBER) {
yield {
label: 'Build',
value: `<a href="${process.env.TRAVIS_BUILD_WEB_URL}" target="_blank">${process.env.TRAVIS_BUILD_NUMBER}</a>`
};
}
}