monocart-reporter 1.7.13 → 2.0.1
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 +10 -26
- package/lib/generate-data.js +7 -19
- package/lib/generate-report.js +13 -6
- package/lib/index.d.ts +82 -53
- package/lib/index.js +1 -4
- package/lib/index.mjs +0 -1
- package/lib/packages/monocart-common.js +1 -0
- package/lib/packages/monocart-network.js +1 -0
- package/lib/packages/monocart-reporter.js +1 -0
- package/lib/packages/monocart-vendor.js +22 -0
- package/lib/platform/share.js +0 -5
- package/lib/plugins/audit/audit.js +2 -2
- package/lib/plugins/coverage/coverage.js +77 -256
- package/lib/plugins/network/network.js +17 -13
- package/lib/plugins/state/client.js +1 -1
- package/lib/plugins/state/state.js +1 -1
- package/lib/utils/parse-source.js +1 -1
- package/lib/utils/util.js +25 -38
- package/lib/visitor.js +6 -26
- package/package.json +10 -8
- package/lib/plugins/coverage/converter/collect-source-maps.js +0 -194
- package/lib/plugins/coverage/converter/converter.js +0 -565
- package/lib/plugins/coverage/converter/dedupe.js +0 -110
- package/lib/plugins/coverage/converter/find-original-range.js +0 -581
- package/lib/plugins/coverage/converter/info-branch.js +0 -30
- package/lib/plugins/coverage/converter/info-function.js +0 -29
- package/lib/plugins/coverage/converter/info-line.js +0 -20
- package/lib/plugins/coverage/converter/position-mapping.js +0 -183
- package/lib/plugins/coverage/converter/source-path.js +0 -140
- package/lib/plugins/coverage/istanbul/istanbul-summary.js +0 -49
- package/lib/plugins/coverage/istanbul/istanbul.js +0 -171
- package/lib/plugins/coverage/v8/v8-summary.js +0 -80
- package/lib/plugins/coverage/v8/v8.js +0 -260
- package/lib/runtime/monocart-code-viewer.js +0 -1
- package/lib/runtime/monocart-common.js +0 -1
- package/lib/runtime/monocart-coverage.js +0 -14
- package/lib/runtime/monocart-formatter.js +0 -1
- package/lib/runtime/monocart-network.js +0 -1
- package/lib/runtime/monocart-reporter.js +0 -1
- package/lib/runtime/monocart-v8.js +0 -1
- package/lib/runtime/monocart-vendor.js +0 -22
- package/lib/utils/decode-mappings.js +0 -49
package/lib/visitor.js
CHANGED
|
@@ -3,7 +3,7 @@ const path = require('path');
|
|
|
3
3
|
const EC = require('eight-colors');
|
|
4
4
|
const {
|
|
5
5
|
StackUtils, codeFrameColumns, sanitize
|
|
6
|
-
} = require('./
|
|
6
|
+
} = require('./packages/monocart-vendor.js');
|
|
7
7
|
const Util = require('./utils/util.js');
|
|
8
8
|
const commentsPlugin = require('./plugins/comments.js');
|
|
9
9
|
const defaultColumns = require('./default/columns.js');
|
|
@@ -53,7 +53,6 @@ class Visitor {
|
|
|
53
53
|
this.rows = [];
|
|
54
54
|
this.jobs = [];
|
|
55
55
|
this.artifacts = [];
|
|
56
|
-
this.artifactDataMap = {};
|
|
57
56
|
|
|
58
57
|
await this.visit(this.root, this.rows);
|
|
59
58
|
|
|
@@ -500,8 +499,6 @@ class Visitor {
|
|
|
500
499
|
|
|
501
500
|
const list = [];
|
|
502
501
|
|
|
503
|
-
const artifact = Util.attachments.artifact;
|
|
504
|
-
|
|
505
502
|
attachments.forEach((item, i) => {
|
|
506
503
|
|
|
507
504
|
if (item.body) {
|
|
@@ -516,11 +513,6 @@ class Visitor {
|
|
|
516
513
|
return;
|
|
517
514
|
}
|
|
518
515
|
|
|
519
|
-
if (item.name === artifact.name && item.contentType === artifact.contentType) {
|
|
520
|
-
this.artifactHandler(item.path);
|
|
521
|
-
return;
|
|
522
|
-
}
|
|
523
|
-
|
|
524
516
|
// before path change
|
|
525
517
|
this.reportHandler(item, 'audit', title);
|
|
526
518
|
this.reportHandler(item, 'coverage', title);
|
|
@@ -564,6 +556,8 @@ class Visitor {
|
|
|
564
556
|
return;
|
|
565
557
|
}
|
|
566
558
|
|
|
559
|
+
// itemName = item.name = definition.name
|
|
560
|
+
|
|
567
561
|
const jsonPath = path.resolve(path.dirname(item.path), definition.reportFile);
|
|
568
562
|
if (!fs.existsSync(jsonPath)) {
|
|
569
563
|
return;
|
|
@@ -575,9 +569,9 @@ class Visitor {
|
|
|
575
569
|
}
|
|
576
570
|
|
|
577
571
|
this.artifacts.push({
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
572
|
+
type: itemName,
|
|
573
|
+
name: report.name || title,
|
|
574
|
+
path: Util.relativePath(item.path)
|
|
581
575
|
});
|
|
582
576
|
|
|
583
577
|
item.report = report;
|
|
@@ -653,20 +647,6 @@ class Visitor {
|
|
|
653
647
|
|
|
654
648
|
// ==============================================================================================
|
|
655
649
|
|
|
656
|
-
artifactHandler(p) {
|
|
657
|
-
const json = Util.readJSONSync(p);
|
|
658
|
-
if (json) {
|
|
659
|
-
const artifactList = this.artifactDataMap[json.type];
|
|
660
|
-
if (artifactList) {
|
|
661
|
-
artifactList.push(json.data);
|
|
662
|
-
} else {
|
|
663
|
-
this.artifactDataMap[json.type] = [json.data];
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
// ==============================================================================================
|
|
669
|
-
|
|
670
650
|
caseErrorsHandler(caseItem) {
|
|
671
651
|
|
|
672
652
|
const errors = caseItem.errors;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "monocart-reporter",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
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": {
|
|
@@ -48,18 +48,20 @@
|
|
|
48
48
|
"koa": "^2.14.2",
|
|
49
49
|
"koa-static-resolver": "^1.0.4",
|
|
50
50
|
"lz-utils": "^2.0.1",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
51
|
+
"monocart-coverage-reports": "^1.0.7",
|
|
52
|
+
"nodemailer": "^6.9.7",
|
|
53
|
+
"open": "^9.1.0",
|
|
54
|
+
"turbogrid": "^3.0.10"
|
|
53
55
|
},
|
|
54
56
|
"devDependencies": {
|
|
55
|
-
"@playwright/test": "^1.
|
|
56
|
-
"axios": "^1.
|
|
57
|
+
"@playwright/test": "^1.40.1",
|
|
58
|
+
"axios": "^1.6.2",
|
|
57
59
|
"dotenv": "^16.3.1",
|
|
58
|
-
"eslint": "^8.
|
|
60
|
+
"eslint": "^8.55.0",
|
|
59
61
|
"eslint-config-plus": "^1.0.6",
|
|
60
62
|
"eslint-plugin-html": "^7.1.0",
|
|
61
|
-
"eslint-plugin-vue": "^9.
|
|
62
|
-
"stylelint": "^15.
|
|
63
|
+
"eslint-plugin-vue": "^9.19.2",
|
|
64
|
+
"stylelint": "^15.11.0",
|
|
63
65
|
"stylelint-config-plus": "^1.0.4",
|
|
64
66
|
"vine-ui": "^3.1.12"
|
|
65
67
|
}
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const EC = require('eight-colors');
|
|
3
|
-
const { fileURLToPath } = require('url');
|
|
4
|
-
const Concurrency = require('../../../platform/concurrency.js');
|
|
5
|
-
const { convertSourceMap, axios } = require('../../../runtime/monocart-coverage.js');
|
|
6
|
-
|
|
7
|
-
const Util = require('../../../utils/util.js');
|
|
8
|
-
|
|
9
|
-
const request = async (options) => {
|
|
10
|
-
if (typeof options === 'string') {
|
|
11
|
-
options = {
|
|
12
|
-
url: options
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
let err;
|
|
16
|
-
const res = await axios(options).catch((e) => {
|
|
17
|
-
err = e;
|
|
18
|
-
});
|
|
19
|
-
return [err, res];
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const loadSourceMap = async (url = '') => {
|
|
23
|
-
|
|
24
|
-
if (url.startsWith('file://')) {
|
|
25
|
-
const p = fileURLToPath(url);
|
|
26
|
-
const json = Util.readJSONSync(p);
|
|
27
|
-
if (!json) {
|
|
28
|
-
Util.logDebug(EC.red(`failed to load sourcemap ${p}`));
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
return json;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const [err, res] = await request({
|
|
35
|
-
url
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
if (err) {
|
|
39
|
-
Util.logDebug(EC.red(`${err.message} ${url}`));
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return res.data;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const getSourceMapUrl = (content, url) => {
|
|
47
|
-
|
|
48
|
-
const m = content.match(convertSourceMap.mapFileCommentRegex);
|
|
49
|
-
if (!m) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const comment = m.pop();
|
|
54
|
-
const r = convertSourceMap.mapFileCommentRegex.exec(comment);
|
|
55
|
-
// for some odd reason //# .. captures in 1 and /* .. */ in 2
|
|
56
|
-
const filename = r[1] || r[2];
|
|
57
|
-
|
|
58
|
-
let mapUrl;
|
|
59
|
-
|
|
60
|
-
try {
|
|
61
|
-
mapUrl = new URL(filename, url);
|
|
62
|
-
} catch (e) {
|
|
63
|
-
Util.logDebug(EC.red(`${e.message} ${filename} ${url}`));
|
|
64
|
-
}
|
|
65
|
-
if (mapUrl) {
|
|
66
|
-
return mapUrl.toString();
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const resolveSourceMap = (data) => {
|
|
71
|
-
if (data) {
|
|
72
|
-
const {
|
|
73
|
-
sources, sourcesContent, mappings
|
|
74
|
-
} = data;
|
|
75
|
-
if (!sources || !sourcesContent || !mappings) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
return data;
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const collectInlineSourceMaps = async (v8list) => {
|
|
83
|
-
let count = 0;
|
|
84
|
-
const concurrency = new Concurrency();
|
|
85
|
-
for (const item of v8list) {
|
|
86
|
-
|
|
87
|
-
const { type, source } = item;
|
|
88
|
-
|
|
89
|
-
// only for js
|
|
90
|
-
if (type === 'js') {
|
|
91
|
-
const converter = convertSourceMap.fromSource(source);
|
|
92
|
-
if (converter) {
|
|
93
|
-
item.sourceMap = resolveSourceMap(converter.sourcemap);
|
|
94
|
-
count += 1;
|
|
95
|
-
// source map comments is inline source map, remove it because it is big
|
|
96
|
-
item.source = convertSourceMap.removeComments(source);
|
|
97
|
-
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
const sourceMapUrl = getSourceMapUrl(source, item.url);
|
|
101
|
-
if (sourceMapUrl) {
|
|
102
|
-
// console.log('========================', sourceMapUrl);
|
|
103
|
-
item.sourceMapUrl = sourceMapUrl;
|
|
104
|
-
concurrency.addItem(item);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
await concurrency.start(async (item) => {
|
|
109
|
-
const data = await loadSourceMap(item.sourceMapUrl);
|
|
110
|
-
if (data) {
|
|
111
|
-
item.sourceMap = resolveSourceMap(data);
|
|
112
|
-
count += 1;
|
|
113
|
-
// source map comments is a link, no need remove
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
return count;
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const collectFileSourceMaps = async (v8list, options) => {
|
|
121
|
-
let count = 0;
|
|
122
|
-
const concurrency = new Concurrency();
|
|
123
|
-
for (const item of v8list) {
|
|
124
|
-
|
|
125
|
-
const {
|
|
126
|
-
type, url, source, id
|
|
127
|
-
} = item;
|
|
128
|
-
|
|
129
|
-
// remove source just keep functions to reduce artifacts size
|
|
130
|
-
delete item.source;
|
|
131
|
-
|
|
132
|
-
const sourcePath = Util.resolveArtifactSourcePath(options.artifactsDir, id);
|
|
133
|
-
if (fs.existsSync(sourcePath)) {
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const sourceData = {
|
|
138
|
-
url,
|
|
139
|
-
id,
|
|
140
|
-
source: convertSourceMap.removeComments(source)
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
// only for js
|
|
144
|
-
if (type === 'js') {
|
|
145
|
-
const converter = convertSourceMap.fromSource(source);
|
|
146
|
-
if (converter) {
|
|
147
|
-
sourceData.sourceMap = resolveSourceMap(converter.sourcemap);
|
|
148
|
-
count += 1;
|
|
149
|
-
await saveSourceFile(sourcePath, sourceData);
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
const sourceMapUrl = getSourceMapUrl(source, item.url);
|
|
153
|
-
if (sourceMapUrl) {
|
|
154
|
-
concurrency.addItem({
|
|
155
|
-
sourceMapUrl,
|
|
156
|
-
sourcePath,
|
|
157
|
-
sourceData
|
|
158
|
-
});
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
await saveSourceFile(sourcePath, sourceData);
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
await concurrency.start(async (item) => {
|
|
168
|
-
const sourceData = item.sourceData;
|
|
169
|
-
const data = await loadSourceMap(item.sourceMapUrl);
|
|
170
|
-
if (data) {
|
|
171
|
-
sourceData.sourceMap = resolveSourceMap(data);
|
|
172
|
-
count += 1;
|
|
173
|
-
}
|
|
174
|
-
await saveSourceFile(item.sourcePath, sourceData);
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
return count;
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
const saveSourceFile = async (filePath, data) => {
|
|
181
|
-
await Util.writeFile(filePath, JSON.stringify(data));
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
const collectSourceMaps = (v8list, options, inlineSourceMap) => {
|
|
185
|
-
|
|
186
|
-
if (inlineSourceMap) {
|
|
187
|
-
return collectInlineSourceMaps(v8list);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
return collectFileSourceMaps(v8list, options);
|
|
191
|
-
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
module.exports = collectSourceMaps;
|