-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerateReport.js
70 lines (67 loc) · 1.46 KB
/
generateReport.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
const fs = require('fs-extra');
const path = require('path');
const getEnviromentCombo = require('./getEnviromentCombo');
const template = data => `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Noreferrer test report</title>
<style>
body {
font-family: Arial, sans-serif;
}
th {
text-align: left;
width: 20%;
}
th:first-child {
max-width: 0;
}
pre {
font-weight: normal;
}
td {
text-align: center;
}
.passed {
background: palegreen;
}
.failed {
background: orangered;
color: white;
}
</style>
</head>
<body>
<table>
<tr>
<th>window.opener</th>
${data[0].suites[0].tests.map(({name}) => `<th>${name}</th>`).join(`
`)}
</tr>
${data.map(({capabilities, suites}) => {
return `<tr>
<th>
<details>
<summary>${getEnviromentCombo(capabilities)}</summary>
<pre>${JSON.stringify(capabilities, null, 2)}</pre>
</details>
</th>
${suites[0].tests.map(({state}) => `<td class="${state}">${state}</td>`).join(`
`)}
</tr>`
}).join(`
`)}
</table>
</body>
</html>
`;
(async function generateReport() {
const dir = path.resolve('./results');
const files = await fs.readdir(dir);
const data = await Promise.all(
files.map(name => fs.readJson(path.join(dir, name)))
);
await fs.writeFile('./report.html', template(data));
})();