monocart-reporter 1.6.26 → 1.6.27
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 +1 -8
- package/lib/generate-report.js +26 -29
- package/lib/index.js +1 -1
- package/lib/merge-data.js +1 -1
- package/lib/plugins/coverage/v8/v8.js +19 -5
- package/lib/plugins/network/network.js +19 -5
- package/lib/runtime/monocart-common.js +1 -0
- package/lib/runtime/monocart-network.js +1 -1
- package/lib/runtime/monocart-reporter.js +1 -1
- package/lib/runtime/monocart-v8.js +1 -1
- package/lib/runtime/monocart-vendor.js +6 -6
- package/lib/utils/util.js +19 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -992,18 +992,11 @@ Please create an [Incoming Webhooks](https://learn.microsoft.com/en-us/microsoft
|
|
|
992
992
|
- [weixin-webhook.js](/tests/common/weixin-webhook.js)
|
|
993
993
|
- [feishu-webhook.js](/tests/common/feishu-webhook.js)
|
|
994
994
|
|
|
995
|
-
## Dependencies
|
|
995
|
+
## Dependencies
|
|
996
996
|
- UI Framework [Vue 3](https://github.com/vuejs/core)
|
|
997
997
|
- Lightweight UI Components [vine-ui](https://github.com/cenfun/vine-ui)
|
|
998
998
|
- High Performance Grid [turbogrid](https://github.com/cenfun/turbogrid)
|
|
999
999
|
- String compress/decompress [lz-utils](https://github.com/cenfun/lz-utils)
|
|
1000
|
-
- Packages
|
|
1001
|
-
- `packages/app` Monocart report UI
|
|
1002
|
-
- `packages/coverage` Coverage report libs
|
|
1003
|
-
- `packages/network` Network HAR report libs
|
|
1004
|
-
- `packages/v8` V8 HTML report UI
|
|
1005
|
-
- `packages/vendor` Third-party libs
|
|
1006
|
-
|
|
1007
1000
|
|
|
1008
1001
|
## Contributing
|
|
1009
1002
|
```sh
|
package/lib/generate-report.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
1
|
const path = require('path');
|
|
3
2
|
const EC = require('eight-colors');
|
|
4
3
|
const CG = require('console-grid');
|
|
5
|
-
const { deflateSync } = require('lz-utils');
|
|
6
4
|
const { nodemailer } = require('./runtime/monocart-vendor.js');
|
|
7
5
|
const Util = require('./utils/util.js');
|
|
8
6
|
const emailPlugin = require('./plugins/email.js');
|
|
9
7
|
|
|
10
8
|
// ===========================================================================
|
|
11
9
|
|
|
12
|
-
const generateJson = (outputDir,
|
|
10
|
+
const generateJson = (outputDir, htmlFile, reportData) => {
|
|
11
|
+
const filename = path.basename(htmlFile, '.html');
|
|
13
12
|
let jsonPath = path.resolve(outputDir, `${filename}.json`);
|
|
14
13
|
Util.writeJSONSync(jsonPath, reportData);
|
|
15
14
|
jsonPath = Util.relativePath(jsonPath);
|
|
@@ -17,30 +16,22 @@ const generateJson = (outputDir, filename, reportData) => {
|
|
|
17
16
|
return jsonPath;
|
|
18
17
|
};
|
|
19
18
|
|
|
20
|
-
const generateHtml = (outputDir,
|
|
21
|
-
const reportDistPath = path.resolve(__dirname, 'runtime/monocart-reporter.js');
|
|
22
|
-
const errMsg = `Not found runtime lib: ${Util.formatPath(reportDistPath)}`;
|
|
19
|
+
const generateHtml = async (outputDir, htmlFile, reportData, inline) => {
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const reportDataStr = deflateSync(JSON.stringify(reportData));
|
|
32
|
-
const content = `<script>\nwindow.reportData = '${reportDataStr}';\n${reportJs}\n</script>`;
|
|
21
|
+
const options = {
|
|
22
|
+
inline,
|
|
23
|
+
reportData,
|
|
24
|
+
jsFiles: ['monocart-common.js', 'monocart-reporter.js'],
|
|
25
|
+
htmlDir: outputDir,
|
|
26
|
+
htmlFile,
|
|
33
27
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
28
|
+
outputDir,
|
|
29
|
+
reportDataFile: 'report-data.js',
|
|
30
|
+
assetsName: 'assets',
|
|
31
|
+
assetsRelative: ''
|
|
32
|
+
};
|
|
40
33
|
|
|
41
|
-
|
|
42
|
-
Util.writeFileSync(htmlPath, html);
|
|
43
|
-
htmlPath = Util.relativePath(htmlPath);
|
|
34
|
+
const htmlPath = await Util.saveHtmlReport(options);
|
|
44
35
|
console.log(`[MCR] html report: ${EC.cyan(htmlPath)}`);
|
|
45
36
|
|
|
46
37
|
const cmd = `npx monocart show-report ${htmlPath}`;
|
|
@@ -141,7 +132,7 @@ const showTestResults = (reportData) => {
|
|
|
141
132
|
};
|
|
142
133
|
|
|
143
134
|
|
|
144
|
-
const generateReport = (reportData,
|
|
135
|
+
const generateReport = async (reportData, options) => {
|
|
145
136
|
|
|
146
137
|
console.log('[MCR] generating test report ...');
|
|
147
138
|
showTestResults(reportData);
|
|
@@ -161,20 +152,26 @@ const generateReport = (reportData, onEnd) => {
|
|
|
161
152
|
}
|
|
162
153
|
|
|
163
154
|
// console.log(reportData);
|
|
164
|
-
const
|
|
155
|
+
const htmlFile = path.basename(outputFile);
|
|
156
|
+
|
|
165
157
|
// generate json
|
|
166
|
-
const jsonPath = generateJson(outputDir,
|
|
158
|
+
const jsonPath = await generateJson(outputDir, htmlFile, reportData);
|
|
159
|
+
|
|
167
160
|
// generate html
|
|
168
|
-
|
|
161
|
+
let inline = true;
|
|
162
|
+
if (typeof options.inline === 'boolean') {
|
|
163
|
+
inline = options.inline;
|
|
164
|
+
}
|
|
165
|
+
const htmlPath = await generateHtml(outputDir, htmlFile, reportData, inline);
|
|
169
166
|
|
|
170
167
|
// onEnd callback
|
|
168
|
+
const onEnd = options.onEnd;
|
|
171
169
|
if (typeof onEnd !== 'function') {
|
|
172
170
|
return;
|
|
173
171
|
}
|
|
174
172
|
|
|
175
173
|
// for onEnd after saved
|
|
176
174
|
Object.assign(reportData, {
|
|
177
|
-
filename,
|
|
178
175
|
htmlPath,
|
|
179
176
|
jsonPath
|
|
180
177
|
});
|
package/lib/index.js
CHANGED
package/lib/merge-data.js
CHANGED
|
@@ -132,12 +132,26 @@ const mergeV8List = async (v8list, options) => {
|
|
|
132
132
|
|
|
133
133
|
// ============================================================
|
|
134
134
|
|
|
135
|
-
const saveV8HtmlReport = async (reportData,
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
|
|
135
|
+
const saveV8HtmlReport = async (reportData, _options) => {
|
|
136
|
+
|
|
137
|
+
const {
|
|
138
|
+
htmlDir, outputDir, inline
|
|
139
|
+
} = _options;
|
|
140
|
+
|
|
141
|
+
const options = {
|
|
142
|
+
inline,
|
|
143
|
+
reportData,
|
|
144
|
+
jsFiles: ['monocart-code-viewer.js', 'monocart-formatter.js', 'monocart-common.js', 'monocart-v8.js'],
|
|
145
|
+
htmlDir,
|
|
146
|
+
htmlFile: 'index.html',
|
|
147
|
+
|
|
148
|
+
outputDir,
|
|
149
|
+
reportDataFile: 'coverage-data.js',
|
|
150
|
+
assetsName: 'assets',
|
|
151
|
+
assetsRelative: '../'
|
|
152
|
+
};
|
|
139
153
|
|
|
140
|
-
const htmlPath = await Util.
|
|
154
|
+
const htmlPath = await Util.saveHtmlReport(options);
|
|
141
155
|
|
|
142
156
|
return htmlPath;
|
|
143
157
|
};
|
|
@@ -95,12 +95,26 @@ const getNetworkSummary = (log) => {
|
|
|
95
95
|
return summary;
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
-
const saveNetworkHtmlReport = async (reportData,
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
|
|
98
|
+
const saveNetworkHtmlReport = async (reportData, _options) => {
|
|
99
|
+
|
|
100
|
+
const {
|
|
101
|
+
htmlDir, outputDir, inline
|
|
102
|
+
} = _options;
|
|
103
|
+
|
|
104
|
+
const options = {
|
|
105
|
+
inline,
|
|
106
|
+
reportData,
|
|
107
|
+
jsFiles: ['monocart-code-viewer.js', 'monocart-formatter.js', 'monocart-common.js', 'monocart-network.js'],
|
|
108
|
+
htmlDir,
|
|
109
|
+
htmlFile: 'index.html',
|
|
110
|
+
|
|
111
|
+
outputDir,
|
|
112
|
+
reportDataFile: 'network-data.js',
|
|
113
|
+
assetsName: 'assets',
|
|
114
|
+
assetsRelative: '../'
|
|
115
|
+
};
|
|
102
116
|
|
|
103
|
-
const htmlPath = await Util.
|
|
117
|
+
const htmlPath = await Util.saveHtmlReport(options);
|
|
104
118
|
|
|
105
119
|
return htmlPath;
|
|
106
120
|
};
|