monocart-reporter 2.7.1 → 2.8.0
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/README.md +40 -100
- package/lib/cli.js +113 -1
- package/lib/default/options.js +12 -6
- package/lib/generate-data.js +4 -14
- package/lib/generate-report.js +12 -1
- package/lib/index.d.ts +45 -33
- package/lib/index.js +29 -8
- package/lib/merge-data.js +48 -7
- package/lib/packages/monocart-reporter-vendor.js +29 -27
- package/lib/plugins/audit/audit.js +3 -1
- package/lib/plugins/coverage/coverage.js +2 -4
- package/lib/plugins/network/network.js +3 -1
- package/lib/utils/util.js +16 -18
- package/lib/visitor.js +36 -1
- package/package.json +5 -2
|
@@ -72,9 +72,11 @@ const attachAuditReport = async (runnerResult, testInfo, options = {}) => {
|
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
const outputDir = await Util.resolveOutputDir(testInfo);
|
|
76
|
+
|
|
75
77
|
options = {
|
|
76
78
|
name: `Lighthouse Report - ${testInfo.title}`,
|
|
77
|
-
outputDir
|
|
79
|
+
outputDir,
|
|
78
80
|
outputName: `audit-${Util.resolveTestIdWithRetry(testInfo)}`,
|
|
79
81
|
... options
|
|
80
82
|
};
|
|
@@ -5,9 +5,7 @@ const Util = require('../../utils/util.js');
|
|
|
5
5
|
|
|
6
6
|
const attachCoverageReport = async (data, testInfo, options = {}) => {
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const outputDir = Util.resolveOutputDir(testInfo, options);
|
|
8
|
+
const outputDir = await Util.resolveOutputDir(testInfo);
|
|
11
9
|
const folderName = `coverage-${Util.resolveTestIdWithRetry(testInfo)}`;
|
|
12
10
|
|
|
13
11
|
// support multiple calls
|
|
@@ -21,7 +19,7 @@ const attachCoverageReport = async (data, testInfo, options = {}) => {
|
|
|
21
19
|
}
|
|
22
20
|
|
|
23
21
|
const coverageOptions = {
|
|
24
|
-
logging:
|
|
22
|
+
logging: Util.resolveLogging(testInfo, options),
|
|
25
23
|
outputDir: htmlDir,
|
|
26
24
|
name: `Coverage Report - ${testInfo.title}`,
|
|
27
25
|
assetsPath: '../assets',
|
|
@@ -129,10 +129,12 @@ const attachNetworkReport = async (har, testInfo, options = {}) => {
|
|
|
129
129
|
return;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
const outputDir = await Util.resolveOutputDir(testInfo);
|
|
133
|
+
|
|
132
134
|
options = {
|
|
133
135
|
// default title
|
|
134
136
|
name: `Network Report - ${testInfo.title}`,
|
|
135
|
-
outputDir
|
|
137
|
+
outputDir,
|
|
136
138
|
outputName: `network-${Util.resolveTestIdWithRetry(testInfo)}`,
|
|
137
139
|
inline: false,
|
|
138
140
|
... options
|
package/lib/utils/util.js
CHANGED
|
@@ -9,8 +9,6 @@ const Share = require('../platform/share.js');
|
|
|
9
9
|
|
|
10
10
|
const getDefaultOptions = require('../default/options.js');
|
|
11
11
|
|
|
12
|
-
const assetsName = 'assets';
|
|
13
|
-
|
|
14
12
|
const Util = {
|
|
15
13
|
... Share,
|
|
16
14
|
|
|
@@ -78,15 +76,11 @@ const Util = {
|
|
|
78
76
|
return parsed;
|
|
79
77
|
},
|
|
80
78
|
|
|
81
|
-
resolveOutputDir: (testInfo
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (outputDir) {
|
|
87
|
-
return outputDir;
|
|
88
|
-
}
|
|
89
|
-
return path.resolve(testInfo.outputDir, '../');
|
|
79
|
+
resolveOutputDir: async (testInfo) => {
|
|
80
|
+
const reporterOptions = Util.resolveReporterOptions(testInfo);
|
|
81
|
+
const outputFile = await Util.resolveOutputFile(reporterOptions.outputFile);
|
|
82
|
+
const outputDir = path.dirname(outputFile);
|
|
83
|
+
return outputDir;
|
|
90
84
|
},
|
|
91
85
|
|
|
92
86
|
resolveOutputFile: async (outputFile) => {
|
|
@@ -98,6 +92,12 @@ const Util = {
|
|
|
98
92
|
if (!outputFile || typeof outputFile !== 'string') {
|
|
99
93
|
outputFile = getDefaultOptions().outputFile;
|
|
100
94
|
}
|
|
95
|
+
|
|
96
|
+
// end with html
|
|
97
|
+
if (!outputFile.endsWith('.html')) {
|
|
98
|
+
outputFile = path.join(outputFile, 'index.html');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
101
|
return path.resolve(outputFile);
|
|
102
102
|
},
|
|
103
103
|
|
|
@@ -109,7 +109,11 @@ const Util = {
|
|
|
109
109
|
return reporterOptions.logging;
|
|
110
110
|
},
|
|
111
111
|
|
|
112
|
+
// eslint-disable-next-line complexity
|
|
112
113
|
resolveReporterOptions: (testInfo) => {
|
|
114
|
+
if (Util.reporterOptions) {
|
|
115
|
+
return Util.reporterOptions;
|
|
116
|
+
}
|
|
113
117
|
if (!testInfo) {
|
|
114
118
|
return {};
|
|
115
119
|
}
|
|
@@ -119,6 +123,7 @@ const Util = {
|
|
|
119
123
|
if (Array.isArray(item)) {
|
|
120
124
|
const [name, options] = item;
|
|
121
125
|
if (name && name.indexOf('monocart-reporter') !== -1) {
|
|
126
|
+
Util.reporterOptions = options;
|
|
122
127
|
return options || {};
|
|
123
128
|
}
|
|
124
129
|
}
|
|
@@ -152,13 +157,6 @@ const Util = {
|
|
|
152
157
|
});
|
|
153
158
|
},
|
|
154
159
|
|
|
155
|
-
initAssetsDir: async (options) => {
|
|
156
|
-
const outputFile = await Util.resolveOutputFile(options.outputFile);
|
|
157
|
-
const outputDir = path.dirname(outputFile);
|
|
158
|
-
const assetsDir = path.resolve(outputDir, assetsName);
|
|
159
|
-
Util.initDir(assetsDir);
|
|
160
|
-
},
|
|
161
|
-
|
|
162
160
|
getEOL: function(content) {
|
|
163
161
|
if (!content) {
|
|
164
162
|
return os.EOL;
|
package/lib/visitor.js
CHANGED
|
@@ -536,6 +536,7 @@ class Visitor {
|
|
|
536
536
|
|
|
537
537
|
const o = this.options;
|
|
538
538
|
// store relative path first
|
|
539
|
+
this.copyAttachmentsHandler(item);
|
|
539
540
|
item.path = Util.relativePath(item.path, o.outputDir);
|
|
540
541
|
|
|
541
542
|
// custom attachment path
|
|
@@ -558,6 +559,37 @@ class Visitor {
|
|
|
558
559
|
}
|
|
559
560
|
}
|
|
560
561
|
|
|
562
|
+
copyAttachmentsHandler(item) {
|
|
563
|
+
|
|
564
|
+
const { attachmentsDir } = this.options;
|
|
565
|
+
if (!attachmentsDir) {
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
if (!fs.existsSync(attachmentsDir)) {
|
|
570
|
+
fs.mkdirSync(attachmentsDir, {
|
|
571
|
+
recursive: true
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// custom report
|
|
576
|
+
if (item.report) {
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
const oldPath = item.path;
|
|
581
|
+
const filename = Util.calculateSha1(oldPath);
|
|
582
|
+
const ext = path.extname(oldPath);
|
|
583
|
+
const newPath = path.resolve(attachmentsDir, `${filename}${ext}`);
|
|
584
|
+
fs.cpSync(oldPath, newPath, {
|
|
585
|
+
force: true,
|
|
586
|
+
recursive: true
|
|
587
|
+
});
|
|
588
|
+
|
|
589
|
+
item.path = newPath;
|
|
590
|
+
|
|
591
|
+
}
|
|
592
|
+
|
|
561
593
|
getImageCategory(item) {
|
|
562
594
|
if (item.contentType && item.contentType.startsWith('image/')) {
|
|
563
595
|
if (item.name) {
|
|
@@ -702,7 +734,10 @@ class Visitor {
|
|
|
702
734
|
return;
|
|
703
735
|
}
|
|
704
736
|
|
|
705
|
-
|
|
737
|
+
// testOutputDir is for test results not reporter
|
|
738
|
+
const { outputDir, testOutputDir } = this.options;
|
|
739
|
+
|
|
740
|
+
const attachmentsPath = path.resolve(testOutputDir || outputDir, caseId);
|
|
706
741
|
if (!fs.existsSync(attachmentsPath)) {
|
|
707
742
|
fs.mkdirSync(attachmentsPath, {
|
|
708
743
|
recursive: true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "monocart-reporter",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
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": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"ansi-to-html": "^0.7.2",
|
|
57
57
|
"async-tick": "^1.0.0",
|
|
58
58
|
"autolinker": "^4.0.0",
|
|
59
|
-
"axios": "^1.7.
|
|
59
|
+
"axios": "^1.7.7",
|
|
60
60
|
"commander": "^12.1.0",
|
|
61
61
|
"dotenv": "^16.4.5",
|
|
62
62
|
"eslint": "^9.9.1",
|
|
@@ -64,7 +64,9 @@
|
|
|
64
64
|
"eslint-plugin-html": "^8.1.1",
|
|
65
65
|
"eslint-plugin-vue": "^9.27.0",
|
|
66
66
|
"file-saver": "^2.0.5",
|
|
67
|
+
"find-up": "^7.0.0",
|
|
67
68
|
"github-markdown-css": "^5.6.1",
|
|
69
|
+
"glob": "^11.0.0",
|
|
68
70
|
"marked": "^14.1.0",
|
|
69
71
|
"mermaid": "^11.0.2",
|
|
70
72
|
"mitt": "^3.0.1",
|
|
@@ -76,6 +78,7 @@
|
|
|
76
78
|
"stack-utils": "^2.0.6",
|
|
77
79
|
"stylelint": "^16.9.0",
|
|
78
80
|
"stylelint-config-plus": "^1.1.2",
|
|
81
|
+
"supports-color": "^9.4.0",
|
|
79
82
|
"turbogrid": "^3.2.0",
|
|
80
83
|
"vine-ui": "^3.1.16",
|
|
81
84
|
"ws": "^8.18.0"
|