monocart-reporter 2.9.3 → 2.9.4
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/generate-report.js +1 -26
- package/lib/merge-data.js +16 -2
- package/lib/utils/util.js +44 -0
- package/package.json +1 -1
package/lib/generate-report.js
CHANGED
|
@@ -18,31 +18,6 @@ const generateJson = (outputDir, filename, reportData, options) => {
|
|
|
18
18
|
reportData.jsonPath = Util.relativePath(jsonPath);
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
const forEachFile = (dir, callback) => {
|
|
22
|
-
if (!fs.existsSync(dir)) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const dirs = [];
|
|
26
|
-
fs.readdirSync(dir, {
|
|
27
|
-
withFileTypes: true
|
|
28
|
-
}).forEach((it) => {
|
|
29
|
-
|
|
30
|
-
if (it.isFile()) {
|
|
31
|
-
callback(it.name, dir);
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (it.isDirectory()) {
|
|
36
|
-
dirs.push(path.resolve(dir, it.name));
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
for (const subDir of dirs) {
|
|
41
|
-
forEachFile(subDir, callback);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
};
|
|
45
|
-
|
|
46
21
|
const generateZip = (outputDir, filename, reportData, options) => {
|
|
47
22
|
|
|
48
23
|
if (!options.zip) {
|
|
@@ -75,7 +50,7 @@ const generateZip = (outputDir, filename, reportData, options) => {
|
|
|
75
50
|
resolve();
|
|
76
51
|
});
|
|
77
52
|
|
|
78
|
-
forEachFile(outputDir, (name, dir) => {
|
|
53
|
+
Util.forEachFile(outputDir, (name, dir) => {
|
|
79
54
|
const absPath = path.resolve(dir, name);
|
|
80
55
|
const relPath = Util.relativePath(absPath, outputDir);
|
|
81
56
|
reportFiles.push(relPath);
|
package/lib/merge-data.js
CHANGED
|
@@ -36,8 +36,22 @@ const unzipDataFile = async (item, num, options) => {
|
|
|
36
36
|
// Do not forget to close the file once you're done
|
|
37
37
|
await zip.close();
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
let filename = path.basename(item, '.zip');
|
|
40
|
+
let jsonPath = path.resolve(unzipDir, `${filename}.json`);
|
|
41
|
+
if (fs.existsSync(jsonPath)) {
|
|
42
|
+
return jsonPath;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
Util.forEachFile(unzipDir, (name, dir) => {
|
|
46
|
+
if (name.endsWith('.html')) {
|
|
47
|
+
filename = path.basename(name, '.html');
|
|
48
|
+
return 'break';
|
|
49
|
+
}
|
|
50
|
+
}, true);
|
|
51
|
+
|
|
52
|
+
jsonPath = path.resolve(unzipDir, `${filename}.json`);
|
|
53
|
+
|
|
54
|
+
return jsonPath;
|
|
41
55
|
};
|
|
42
56
|
|
|
43
57
|
const getReportData = async (item, num, options) => {
|
package/lib/utils/util.js
CHANGED
|
@@ -277,6 +277,50 @@ const Util = {
|
|
|
277
277
|
}
|
|
278
278
|
},
|
|
279
279
|
|
|
280
|
+
// eslint-disable-next-line complexity
|
|
281
|
+
forEachFile: (dir, callback, shallow) => {
|
|
282
|
+
if (!fs.existsSync(dir)) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const isBreak = (res) => {
|
|
287
|
+
return res === 'break' || res === false;
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
const dirs = [];
|
|
291
|
+
const list = fs.readdirSync(dir, {
|
|
292
|
+
withFileTypes: true
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
for (const item of list) {
|
|
296
|
+
|
|
297
|
+
if (item.isFile()) {
|
|
298
|
+
const res = callback(item.name, dir);
|
|
299
|
+
if (isBreak(res)) {
|
|
300
|
+
return res;
|
|
301
|
+
}
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (item.isDirectory()) {
|
|
306
|
+
dirs.push(path.resolve(dir, item.name));
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
if (shallow) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
for (const subDir of dirs) {
|
|
316
|
+
const res = Util.forEachFile(subDir, callback, shallow);
|
|
317
|
+
if (isBreak(res)) {
|
|
318
|
+
return res;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
},
|
|
323
|
+
|
|
280
324
|
getTemplate: function(templatePath) {
|
|
281
325
|
if (!Util.templateCache) {
|
|
282
326
|
Util.templateCache = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "monocart-reporter",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.4",
|
|
4
4
|
"description": "A playwright test reporter. Shows suites/cases/steps with tree style, markdown annotations, custom columns/formatters/data collection visitors, console logs, style tags, send email.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"bin": {
|