monocart-reporter 1.7.0 → 1.7.2
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 +8 -12
- package/lib/cli.js +1 -1
- package/lib/common.js +2 -3
- package/lib/default/options.js +4 -3
- package/lib/generate-data.js +2 -7
- package/lib/generate-report.js +10 -11
- package/lib/index.d.ts +2 -9
- package/lib/index.js +6 -0
- package/lib/merge-data.js +7 -6
- package/lib/plugins/audit/audit.js +4 -2
- package/lib/plugins/comments.js +2 -3
- package/lib/plugins/coverage/converter/collect-source-maps.js +194 -0
- package/lib/plugins/coverage/converter/converter.js +547 -0
- package/lib/plugins/coverage/converter/decode-mappings.js +49 -0
- package/lib/plugins/coverage/{v8 → converter}/dedupe.js +8 -1
- package/lib/plugins/coverage/converter/find-original-range.js +576 -0
- package/lib/plugins/coverage/converter/info-branch.js +30 -0
- package/lib/plugins/coverage/converter/info-function.js +29 -0
- package/lib/plugins/coverage/converter/info-line.js +20 -0
- package/lib/plugins/coverage/converter/position-mapping.js +183 -0
- package/lib/plugins/coverage/{coverage-utils.js → converter/source-path.js} +26 -42
- package/lib/plugins/coverage/coverage.js +61 -57
- package/lib/plugins/coverage/istanbul/istanbul.js +21 -174
- package/lib/plugins/coverage/v8/v8.js +22 -30
- package/lib/plugins/network/network.js +4 -13
- package/lib/plugins/state/client.js +3 -4
- package/lib/plugins/state/state.js +6 -3
- package/lib/runtime/monocart-code-viewer.js +1 -1
- package/lib/runtime/monocart-coverage.js +13 -14
- package/lib/runtime/monocart-formatter.js +1 -1
- 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 +13 -13
- package/lib/utils/util.js +97 -3
- package/package.json +5 -6
- package/lib/plugins/coverage/v8/position-mapping.js +0 -92
- package/lib/plugins/coverage/v8/source-map.js +0 -464
package/lib/utils/util.js
CHANGED
|
@@ -4,9 +4,12 @@ const path = require('path');
|
|
|
4
4
|
const os = require('os');
|
|
5
5
|
const crypto = require('crypto');
|
|
6
6
|
const EC = require('eight-colors');
|
|
7
|
+
const CG = require('console-grid');
|
|
7
8
|
const Share = require('../platform/share.js');
|
|
8
9
|
const { deflateSync } = require('lz-utils');
|
|
9
10
|
|
|
11
|
+
const assetsName = 'assets';
|
|
12
|
+
|
|
10
13
|
const Util = {
|
|
11
14
|
|
|
12
15
|
root: process.cwd(),
|
|
@@ -116,6 +119,23 @@ const Util = {
|
|
|
116
119
|
return sourcePath;
|
|
117
120
|
},
|
|
118
121
|
|
|
122
|
+
// empty or create dir
|
|
123
|
+
initDir: (dirPath) => {
|
|
124
|
+
if (fs.existsSync(dirPath)) {
|
|
125
|
+
Util.rmSync(dirPath);
|
|
126
|
+
}
|
|
127
|
+
fs.mkdirSync(dirPath, {
|
|
128
|
+
recursive: true
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
initAssetsDir: async (options) => {
|
|
133
|
+
const outputFile = await Util.resolveOutputFile(options.outputFile);
|
|
134
|
+
const outputDir = path.dirname(outputFile);
|
|
135
|
+
const assetsDir = path.resolve(outputDir, assetsName);
|
|
136
|
+
Util.initDir(assetsDir);
|
|
137
|
+
},
|
|
138
|
+
|
|
119
139
|
saveHtmlReport: async (options) => {
|
|
120
140
|
|
|
121
141
|
const {
|
|
@@ -127,7 +147,6 @@ const Util = {
|
|
|
127
147
|
|
|
128
148
|
outputDir,
|
|
129
149
|
reportDataFile,
|
|
130
|
-
assetsName,
|
|
131
150
|
assetsRelative
|
|
132
151
|
} = options;
|
|
133
152
|
|
|
@@ -226,7 +245,7 @@ const Util = {
|
|
|
226
245
|
writeJSONSync: function(filePath, json) {
|
|
227
246
|
let content = Util.jsonString(json);
|
|
228
247
|
if (!content) {
|
|
229
|
-
|
|
248
|
+
Util.logError('invalid JSON object');
|
|
230
249
|
return false;
|
|
231
250
|
}
|
|
232
251
|
// end of line
|
|
@@ -325,7 +344,7 @@ const Util = {
|
|
|
325
344
|
if (template) {
|
|
326
345
|
Util.templateCache[templatePath] = template;
|
|
327
346
|
} else {
|
|
328
|
-
|
|
347
|
+
Util.logError(`not found template: ${templatePath}`);
|
|
329
348
|
}
|
|
330
349
|
}
|
|
331
350
|
return template;
|
|
@@ -352,6 +371,81 @@ const Util = {
|
|
|
352
371
|
});
|
|
353
372
|
});
|
|
354
373
|
return option;
|
|
374
|
+
},
|
|
375
|
+
|
|
376
|
+
// ==========================================================================================
|
|
377
|
+
|
|
378
|
+
loggingLevels: {
|
|
379
|
+
off: 0,
|
|
380
|
+
error: 10,
|
|
381
|
+
info: 20,
|
|
382
|
+
debug: 30
|
|
383
|
+
},
|
|
384
|
+
|
|
385
|
+
initLoggingLevel: (level, from = '') => {
|
|
386
|
+
if (!level && Util.loggingType) {
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
const types = {
|
|
390
|
+
off: 'off',
|
|
391
|
+
error: 'error',
|
|
392
|
+
info: 'info',
|
|
393
|
+
debug: 'debug'
|
|
394
|
+
};
|
|
395
|
+
const type = types[level] || types.info;
|
|
396
|
+
Util.loggingType = type;
|
|
397
|
+
Util.loggingLevel = Util.loggingLevels[type];
|
|
398
|
+
|
|
399
|
+
// console.log('=========================================');
|
|
400
|
+
// console.log(from, Util.loggingType, Util.loggingLevel);
|
|
401
|
+
},
|
|
402
|
+
|
|
403
|
+
logError: (message) => {
|
|
404
|
+
if (Util.loggingLevel < Util.loggingLevels.error) {
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
EC.logRed(`[MCR] ${message}`);
|
|
408
|
+
},
|
|
409
|
+
|
|
410
|
+
logInfo: (message) => {
|
|
411
|
+
if (Util.loggingLevel < Util.loggingLevels.info) {
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
console.log(`[MCR] ${message}`);
|
|
415
|
+
},
|
|
416
|
+
|
|
417
|
+
// grid is info level
|
|
418
|
+
logGrid: (gridData) => {
|
|
419
|
+
if (Util.loggingLevel < Util.loggingLevels.info) {
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
CG(gridData);
|
|
423
|
+
},
|
|
424
|
+
|
|
425
|
+
logDebug: (message) => {
|
|
426
|
+
if (Util.loggingLevel < Util.loggingLevels.debug) {
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
console.log(`[MCR] ${message}`);
|
|
430
|
+
},
|
|
431
|
+
|
|
432
|
+
// time is debug level
|
|
433
|
+
logTime: (message, time_start) => {
|
|
434
|
+
if (Util.loggingLevel < Util.loggingLevels.debug) {
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
const duration = Date.now() - time_start;
|
|
438
|
+
const durationH = Util.TSF(duration);
|
|
439
|
+
const ls = [`[MCR] ${message}`, ' ('];
|
|
440
|
+
if (duration <= 100) {
|
|
441
|
+
ls.push(EC.green(durationH));
|
|
442
|
+
} else if (duration < 500) {
|
|
443
|
+
ls.push(EC.yellow(durationH));
|
|
444
|
+
} else {
|
|
445
|
+
ls.push(EC.red(durationH));
|
|
446
|
+
}
|
|
447
|
+
ls.push(')');
|
|
448
|
+
console.log(ls.join(''));
|
|
355
449
|
}
|
|
356
450
|
|
|
357
451
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "monocart-reporter",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
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,8 +48,7 @@
|
|
|
48
48
|
"koa-static-resolver": "^1.0.4",
|
|
49
49
|
"lz-utils": "^2.0.1",
|
|
50
50
|
"nodemailer": "^6.9.3",
|
|
51
|
-
"open": "^9.1.0"
|
|
52
|
-
"source-map": "^0.7.4"
|
|
51
|
+
"open": "^9.1.0"
|
|
53
52
|
},
|
|
54
53
|
"devDependencies": {
|
|
55
54
|
"@playwright/test": "^1.35.1",
|
|
@@ -58,9 +57,9 @@
|
|
|
58
57
|
"eslint": "^8.43.0",
|
|
59
58
|
"eslint-config-plus": "^1.0.6",
|
|
60
59
|
"eslint-plugin-html": "^7.1.0",
|
|
61
|
-
"eslint-plugin-vue": "^9.15.
|
|
62
|
-
"stylelint": "^15.
|
|
60
|
+
"eslint-plugin-vue": "^9.15.1",
|
|
61
|
+
"stylelint": "^15.9.0",
|
|
63
62
|
"stylelint-config-plus": "^1.0.3",
|
|
64
63
|
"vine-ui": "^3.1.12"
|
|
65
64
|
}
|
|
66
|
-
}
|
|
65
|
+
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const findLine = function(list, position) {
|
|
3
|
-
let start = 0;
|
|
4
|
-
let end = list.length - 1;
|
|
5
|
-
while (end - start > 1) {
|
|
6
|
-
const i = Math.floor((start + end) * 0.5);
|
|
7
|
-
const item = list[i];
|
|
8
|
-
if (position < item.start) {
|
|
9
|
-
end = i;
|
|
10
|
-
continue;
|
|
11
|
-
}
|
|
12
|
-
if (position > item.end) {
|
|
13
|
-
start = i;
|
|
14
|
-
continue;
|
|
15
|
-
}
|
|
16
|
-
return list[i];
|
|
17
|
-
}
|
|
18
|
-
// last two items, less is start
|
|
19
|
-
const endItem = list[end];
|
|
20
|
-
if (position < endItem.start) {
|
|
21
|
-
return list[start];
|
|
22
|
-
}
|
|
23
|
-
return list[end];
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
class PositionMapping {
|
|
27
|
-
constructor(source, sourceName) {
|
|
28
|
-
this.source = source;
|
|
29
|
-
this.sourceName = sourceName;
|
|
30
|
-
this.lines = this.getLines(source);
|
|
31
|
-
this.ranges = [];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// =============================================================================
|
|
35
|
-
|
|
36
|
-
getSlice(s, e) {
|
|
37
|
-
return this.source.slice(s, e);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
locationToOffset(location) {
|
|
41
|
-
const { line, column } = location;
|
|
42
|
-
// 1-based
|
|
43
|
-
const lineInfo = this.lines[line - 1];
|
|
44
|
-
if (lineInfo) {
|
|
45
|
-
if (column === Infinity) {
|
|
46
|
-
return lineInfo.start + lineInfo.length;
|
|
47
|
-
}
|
|
48
|
-
return lineInfo.start + column;
|
|
49
|
-
}
|
|
50
|
-
return 0;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
offsetToLocation(offset) {
|
|
54
|
-
const lineInfo = findLine(this.lines, offset);
|
|
55
|
-
const column = Math.min(Math.max(offset - lineInfo.start, 0), lineInfo.length);
|
|
56
|
-
|
|
57
|
-
// 1-based
|
|
58
|
-
const line = lineInfo.line + 1;
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
line,
|
|
62
|
-
column
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// =============================================================================
|
|
67
|
-
|
|
68
|
-
getLines(content) {
|
|
69
|
-
let pos = 0;
|
|
70
|
-
const lines = content.split(/\n/).map((text, line) => {
|
|
71
|
-
const length = text.length;
|
|
72
|
-
const start = pos;
|
|
73
|
-
const end = start + length;
|
|
74
|
-
|
|
75
|
-
pos += length + 1;
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
line,
|
|
79
|
-
start,
|
|
80
|
-
end,
|
|
81
|
-
length,
|
|
82
|
-
text
|
|
83
|
-
};
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
return lines;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
module.exports = PositionMapping;
|
|
92
|
-
|