@testomatio/reporter 1.2.0-beta-2 → 1.2.0-beta-3
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/lib/pipe/html.js +26 -7
- package/lib/template/testomatio.hbs +23 -0
- package/package.json +2 -1
package/lib/pipe/html.js
CHANGED
|
@@ -4,6 +4,7 @@ const fs = require('fs');
|
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const chalk = require('chalk');
|
|
6
6
|
const handlebars = require('handlebars');
|
|
7
|
+
const fileUrl = require('file-url');
|
|
7
8
|
|
|
8
9
|
const { fileSystem, isSameTest, ansiRegExp } = require('../utils/utils');
|
|
9
10
|
const { HTML_REPORT } = require('../constants');
|
|
@@ -23,6 +24,7 @@ class HtmlPipe {
|
|
|
23
24
|
|
|
24
25
|
this.isEnabled = false;
|
|
25
26
|
this.htmlOutputPath = "";
|
|
27
|
+
this.fullHtmlOutputPath = "";
|
|
26
28
|
this.tests = [];
|
|
27
29
|
this.data = {};
|
|
28
30
|
|
|
@@ -35,9 +37,6 @@ class HtmlPipe {
|
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
if (process.env.TESTOMATIO_HTML_FILENAME && !process.env.TESTOMATIO_HTML_FILENAME.endsWith(".html")) {
|
|
38
|
-
console.log(
|
|
39
|
-
chalk.blue(`The name must include the extension ".html". The default report name is used!`)
|
|
40
|
-
);
|
|
41
40
|
this.htmlReportName = HTML_REPORT.REPORT_DEFAULT_NAME;
|
|
42
41
|
}
|
|
43
42
|
|
|
@@ -140,20 +139,41 @@ class HtmlPipe {
|
|
|
140
139
|
debug('HTML tests data:', data);
|
|
141
140
|
|
|
142
141
|
if (!this.htmlOutputPath && this.htmlOutputPath !== "") {
|
|
143
|
-
console.log(chalk.yellow(
|
|
142
|
+
console.log(chalk.yellow(`🚨 HTML export path is not set, ignoring...`));
|
|
144
143
|
return;
|
|
145
144
|
}
|
|
146
145
|
|
|
147
|
-
console.log(chalk.yellow(
|
|
146
|
+
console.log(chalk.yellow(`⏳ The test results will be added to the HTML report. It will take some time...`));
|
|
148
147
|
// generate output HTML based on the template
|
|
149
148
|
const html = this.#generateHTMLReport(data);
|
|
150
149
|
|
|
150
|
+
if (process.env.TESTOMATIO_HTML_FILENAME && !process.env.TESTOMATIO_HTML_FILENAME.endsWith(".html")) {
|
|
151
|
+
console.log(
|
|
152
|
+
chalk.blue("HTML filename must include the extension \".html\"." +
|
|
153
|
+
` The default report name "${this.htmlOutputPath}" is used!`)
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
151
157
|
fs.writeFileSync(this.htmlOutputPath, html, 'utf-8');
|
|
158
|
+
|
|
159
|
+
// Check if the file exists
|
|
160
|
+
if (fs.existsSync(this.htmlOutputPath)) {
|
|
161
|
+
// Get the absolute path of the file
|
|
162
|
+
const absolutePath = path.resolve(this.htmlOutputPath);
|
|
163
|
+
// Convert the file path to a file URL
|
|
164
|
+
const fileUrlPath = fileUrl(absolutePath, {resolve: true});
|
|
165
|
+
|
|
166
|
+
debug('HTML tests data:', fileUrlPath);
|
|
167
|
+
|
|
168
|
+
console.log(chalk.green(`📊 The HTML report was successfully generated. Full filepath: ${fileUrlPath}`));
|
|
169
|
+
} else {
|
|
170
|
+
console.log(chalk.red(`🚨 Failed to generate the HTML report.`));
|
|
171
|
+
}
|
|
152
172
|
}
|
|
153
173
|
|
|
154
174
|
#generateHTMLReport(data) {
|
|
155
175
|
if (!this.templateHtmlPath) {
|
|
156
|
-
console.log(chalk.red(
|
|
176
|
+
console.log(chalk.red(`🚨 HTML template not found. Report generation is impossible!`))
|
|
157
177
|
return;
|
|
158
178
|
}
|
|
159
179
|
|
|
@@ -162,7 +182,6 @@ class HtmlPipe {
|
|
|
162
182
|
try {
|
|
163
183
|
const template = handlebars.compile(templateSource);
|
|
164
184
|
|
|
165
|
-
console.log(chalk.green(`Generated HTML report saved in file: ${this.htmlOutputPath}`));
|
|
166
185
|
return template(data);
|
|
167
186
|
}
|
|
168
187
|
catch (e) {
|
|
@@ -245,6 +245,29 @@
|
|
|
245
245
|
font-size: 14px;
|
|
246
246
|
white-space: pre-line;
|
|
247
247
|
}
|
|
248
|
+
/* Passed TAB*/
|
|
249
|
+
#passedTest:not(:checked) + .btn-outline-dark {
|
|
250
|
+
background-color: #39BD2F;
|
|
251
|
+
}
|
|
252
|
+
#passedTest:checked + .btn-outline-dark {
|
|
253
|
+
background-color: #68cf61;
|
|
254
|
+
color: white;
|
|
255
|
+
}
|
|
256
|
+
/* Failed TAB*/
|
|
257
|
+
#failedTest:not(:checked) + .btn-outline-dark {
|
|
258
|
+
background-color: #F2230C;
|
|
259
|
+
}
|
|
260
|
+
#failedTest:checked + .btn-outline-dark {
|
|
261
|
+
background-color: #FA6E5E;
|
|
262
|
+
color: white;
|
|
263
|
+
}
|
|
264
|
+
/* Skipped TAB*/
|
|
265
|
+
#skippedTest:not(:checked) + .btn-outline-dark {
|
|
266
|
+
background-color: #F2C00C;
|
|
267
|
+
}
|
|
268
|
+
#skippedTest:checked + .btn-outline-dark {
|
|
269
|
+
background-color: #dfc155;
|
|
270
|
+
}
|
|
248
271
|
</style>
|
|
249
272
|
</head>
|
|
250
273
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testomatio/reporter",
|
|
3
|
-
"version": "1.2.0-beta-
|
|
3
|
+
"version": "1.2.0-beta-3",
|
|
4
4
|
"description": "Testomatio Reporter Client",
|
|
5
5
|
"main": "./lib/reporter.js",
|
|
6
6
|
"typings": "typings/index.d.ts",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"debug": "^4.3.4",
|
|
21
21
|
"dotenv": "^16.0.1",
|
|
22
22
|
"fast-xml-parser": "^4.0.8",
|
|
23
|
+
"file-url": "3.0.0",
|
|
23
24
|
"glob": "^10.3",
|
|
24
25
|
"handlebars": "^4.7.8",
|
|
25
26
|
"has-flag": "^5.0.1",
|