monocart-coverage-reports 2.7.6 → 2.7.8
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 +141 -74
- package/lib/cli.js +4 -17
- package/lib/client/cdp-client.js +1 -4
- package/lib/client/coverage-client.js +61 -19
- package/lib/converter/collect-source-maps.js +1 -3
- package/lib/converter/converter.js +13 -1
- package/lib/generate.js +5 -0
- package/lib/index.d.ts +12 -7
- package/lib/index.js +3 -1
- package/lib/packages/monocart-coverage-v8.js +1 -1
- package/lib/packages/monocart-coverage-vendor.js +2 -2
- package/lib/utils/request.js +26 -7
- package/lib/utils/source-path.js +15 -5
- package/lib/utils/util.js +26 -0
- package/lib/v8/v8.js +5 -6
- package/package.json +14 -12
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
const EC = require('eight-colors');
|
|
8
|
-
const { Locator } = require('monocart-formatter');
|
|
9
8
|
|
|
9
|
+
const { Locator } = require('monocart-locator');
|
|
10
10
|
const Util = require('../utils/util.js');
|
|
11
11
|
|
|
12
12
|
const findOriginalRange = require('./find-original-range.js');
|
|
@@ -984,9 +984,13 @@ const initOriginalList = (state, originalDecodedMap, options) => {
|
|
|
984
984
|
|
|
985
985
|
const { sources, sourcesContent } = state.sourceMap;
|
|
986
986
|
|
|
987
|
+
const lengthBefore = sources.length;
|
|
988
|
+
let lengthAfter = 0;
|
|
989
|
+
|
|
987
990
|
sources.forEach((sourcePath, sourceIndex) => {
|
|
988
991
|
|
|
989
992
|
// filter
|
|
993
|
+
// do not change for sourceIndex
|
|
990
994
|
if (!sourceFilter(sourcePath)) {
|
|
991
995
|
// console.log('-', sourcePath);
|
|
992
996
|
return;
|
|
@@ -1034,8 +1038,11 @@ const initOriginalList = (state, originalDecodedMap, options) => {
|
|
|
1034
1038
|
};
|
|
1035
1039
|
|
|
1036
1040
|
originalStateMap.set(sourceIndex, originalState);
|
|
1041
|
+
lengthAfter += 1;
|
|
1037
1042
|
});
|
|
1038
1043
|
|
|
1044
|
+
Util.logFilter(`source filter (${state.sourcePath}):`, lengthBefore, lengthAfter);
|
|
1045
|
+
|
|
1039
1046
|
return originalStateMap;
|
|
1040
1047
|
};
|
|
1041
1048
|
|
|
@@ -1044,6 +1051,8 @@ const collectOriginalList = (state, originalStateMap) => {
|
|
|
1044
1051
|
const { fileUrls } = state;
|
|
1045
1052
|
const distFile = state.sourcePath;
|
|
1046
1053
|
|
|
1054
|
+
let added = 0;
|
|
1055
|
+
|
|
1047
1056
|
// collect original files
|
|
1048
1057
|
originalStateMap.forEach((originalState) => {
|
|
1049
1058
|
|
|
@@ -1070,8 +1079,11 @@ const collectOriginalList = (state, originalStateMap) => {
|
|
|
1070
1079
|
// save v8 data and add to originalList
|
|
1071
1080
|
originalState.v8Data = sourceItem;
|
|
1072
1081
|
state.originalList.push(originalState);
|
|
1082
|
+
added += 1;
|
|
1073
1083
|
});
|
|
1074
1084
|
|
|
1085
|
+
Util.logDebug(`added source files: ${EC.yellow(added)}`);
|
|
1086
|
+
|
|
1075
1087
|
};
|
|
1076
1088
|
|
|
1077
1089
|
// ========================================================================================================
|
package/lib/generate.js
CHANGED
|
@@ -686,6 +686,7 @@ const getInputData = async (inputList, all, cacheDir, addHandler) => {
|
|
|
686
686
|
// dataList for data type, before `add` we don't which one is tested, because using hash id
|
|
687
687
|
const emptyData = getEmptyData(all, dataList);
|
|
688
688
|
if (emptyData) {
|
|
689
|
+
Util.logDebug(`added empty files for all: ${EC.yellow(emptyData.length)}`);
|
|
689
690
|
const coverageResults = await addHandler(emptyData);
|
|
690
691
|
// after `add`
|
|
691
692
|
if (coverageResults) {
|
|
@@ -782,7 +783,11 @@ const readCoverageData = (filePath, entryFilter, sourceCache) => {
|
|
|
782
783
|
|
|
783
784
|
// filter node internal files, should no anonymous for nodejs
|
|
784
785
|
coverageData = coverageData.filter((entry) => entry.url && entry.url.startsWith('file:'));
|
|
786
|
+
|
|
787
|
+
const lengthBefore = coverageData.length;
|
|
785
788
|
coverageData = coverageData.filter(entryFilter);
|
|
789
|
+
const lengthAfter = coverageData.length;
|
|
790
|
+
Util.logFilter('entry filter (addFromDir):', lengthBefore, lengthAfter);
|
|
786
791
|
|
|
787
792
|
if (!Util.isList(coverageData)) {
|
|
788
793
|
// Util.logDebug('No coverage data after filter');
|
package/lib/index.d.ts
CHANGED
|
@@ -119,7 +119,7 @@ declare namespace MCR {
|
|
|
119
119
|
outputDir?: string;
|
|
120
120
|
}] |
|
|
121
121
|
[string] | [string, {
|
|
122
|
-
type?: "v8" | "istanbul" | "both";
|
|
122
|
+
type?: "v8" | "istanbul" | "both" | string;
|
|
123
123
|
[key: string]: any;
|
|
124
124
|
}];
|
|
125
125
|
|
|
@@ -192,7 +192,7 @@ declare namespace MCR {
|
|
|
192
192
|
ignores?: IgnoredRange[];
|
|
193
193
|
/** codecov json format */
|
|
194
194
|
lines: {
|
|
195
|
-
[key: string]: number | string
|
|
195
|
+
[key: string]: number | string;
|
|
196
196
|
};
|
|
197
197
|
}
|
|
198
198
|
}
|
|
@@ -287,7 +287,7 @@ declare namespace MCR {
|
|
|
287
287
|
*/
|
|
288
288
|
filter?: string | {
|
|
289
289
|
[pattern: string]: "js" | "css" | boolean;
|
|
290
|
-
} | ((filePath: string) => "js" | "css" | boolean)
|
|
290
|
+
} | ((filePath: string) => "js" | "css" | boolean);
|
|
291
291
|
};
|
|
292
292
|
|
|
293
293
|
/** (V8 only) {boolean} Enable/Disable ignoring uncovered codes with the special comments: v8 ignore next/next N/start/stop */
|
|
@@ -320,6 +320,7 @@ declare namespace MCR {
|
|
|
320
320
|
/** {function} onEnd hook */
|
|
321
321
|
onEnd?: (coverageResults: CoverageResults) => Promise<void>;
|
|
322
322
|
|
|
323
|
+
[key: string]: any;
|
|
323
324
|
}
|
|
324
325
|
|
|
325
326
|
export interface McrCliOptions extends CoverageReportOptions {
|
|
@@ -441,15 +442,19 @@ declare namespace MCR {
|
|
|
441
442
|
stopCoverage: () => Promise<V8CoverageEntry[]>;
|
|
442
443
|
|
|
443
444
|
/** write the coverage started by NODE_V8_COVERAGE to disk on demand, returns v8 coverage dir */
|
|
444
|
-
writeCoverage: () => Promise<string
|
|
445
|
+
writeCoverage: () => Promise<string>;
|
|
445
446
|
|
|
447
|
+
/** get istanbul coverage data
|
|
448
|
+
* @param coverageKey defaults to `__coverage__`
|
|
449
|
+
*/
|
|
450
|
+
getIstanbulCoverage: (coverageKey?: string) => Promise<any>;
|
|
446
451
|
}
|
|
447
452
|
|
|
448
453
|
/** Adapt to the CDPSession of Playwright or Puppeteer */
|
|
449
454
|
export interface CDPSession {
|
|
450
455
|
send: (method: string, params?: any) => Promise<any>;
|
|
451
456
|
on: (type: string, handler: (e: any) => void) => void;
|
|
452
|
-
detach: () => Promise<void
|
|
457
|
+
detach: () => Promise<void>;
|
|
453
458
|
}
|
|
454
459
|
|
|
455
460
|
/** custom websocket CDPSession */
|
|
@@ -457,7 +462,7 @@ declare namespace MCR {
|
|
|
457
462
|
constructor(ws: any);
|
|
458
463
|
send: (method: string, params?: any) => Promise<any>;
|
|
459
464
|
on: (type: string, handler: (e: any) => void) => void;
|
|
460
|
-
detach: () => Promise<void
|
|
465
|
+
detach: () => Promise<void>;
|
|
461
466
|
}
|
|
462
467
|
|
|
463
468
|
export interface CDPOptions {
|
|
@@ -472,7 +477,7 @@ declare namespace MCR {
|
|
|
472
477
|
/** enable https, defaults to false (http) */
|
|
473
478
|
secure?: boolean;
|
|
474
479
|
/** target filter, defaults to first page */
|
|
475
|
-
target?: (targets) => any;
|
|
480
|
+
target?: (targets: any) => any;
|
|
476
481
|
/** websocket options */
|
|
477
482
|
ws?: any;
|
|
478
483
|
/** timeout, defaults to 10 * 1000 */
|
package/lib/index.js
CHANGED
|
@@ -61,6 +61,9 @@ class CoverageReport {
|
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
// before clean cache, do no call initOptions again in hasCache
|
|
65
|
+
this.fixedOptions = true;
|
|
66
|
+
|
|
64
67
|
// init logging for clean after generated
|
|
65
68
|
this.logging = Util.initLoggingLevel(this.options.logging);
|
|
66
69
|
|
|
@@ -79,7 +82,6 @@ class CoverageReport {
|
|
|
79
82
|
this.cleanCache();
|
|
80
83
|
}
|
|
81
84
|
|
|
82
|
-
this.fixedOptions = true;
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
// add coverage data: {array} V8 format, {object} Istanbul format
|