monocart-coverage-reports 2.5.7 → 2.5.9

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.
@@ -101,11 +101,22 @@ const initIstanbulSourcePath = (coverageData, fileSources, sourcePathHandler) =>
101
101
  return coverageData;
102
102
  }
103
103
 
104
+ // console.log(fileSources);
105
+
104
106
  const newCoverage = {};
105
107
  Object.keys(coverageData).forEach((sourcePath) => {
106
108
  // previous coverage and source
107
109
  const item = coverageData[sourcePath];
108
- const source = fileSources[sourcePath];
110
+ let source = fileSources[sourcePath];
111
+
112
+ // source could be empty string ''
113
+ if (typeof source !== 'string') {
114
+ // read source with original source path first
115
+ source = Util.readFileSync(sourcePath);
116
+ if (typeof source === 'string') {
117
+ fileSources[sourcePath] = source;
118
+ }
119
+ }
109
120
 
110
121
  // new source path, second is source url
111
122
  const newSourcePath = sourcePathHandler(sourcePath, '');
@@ -117,11 +128,14 @@ const initIstanbulSourcePath = (coverageData, fileSources, sourcePathHandler) =>
117
128
  item.data.path = sourcePath;
118
129
  newCoverage[sourcePath] = item;
119
130
  // update source for the new path
120
- if (source) {
131
+ if (typeof source === 'string') {
121
132
  fileSources[sourcePath] = source;
122
133
  }
123
134
  });
124
135
 
136
+ // console.log(Object.keys(fileSources));
137
+ // console.log(newCoverage);
138
+
125
139
  return newCoverage;
126
140
  };
127
141
 
package/lib/utils/util.js CHANGED
@@ -502,20 +502,12 @@ const Util = {
502
502
  console.log(`[MCR] ${message}`);
503
503
  },
504
504
 
505
- // time is debug level
505
+ // time is debug level, fix the log info, for checking snapshot
506
506
  logTime: (message, time_start) => {
507
- if (Util.loggingLevel < Util.loggingLevels.info) {
507
+ if (Util.loggingLevel < Util.loggingLevels.debug) {
508
508
  return;
509
509
  }
510
-
511
- const slowDuration = 1000;
512
510
  const duration = Date.now() - time_start;
513
- if (Util.loggingLevel < Util.loggingLevels.debug) {
514
- if (duration < slowDuration) {
515
- return;
516
- }
517
- }
518
-
519
511
  const durationH = Util.TSF(duration);
520
512
  const ls = [`[MCR] ${message}`, ' ('];
521
513
  if (duration <= 100) {
@@ -5,6 +5,14 @@ const getV8SummaryBytes = (item) => {
5
5
  const source = item.source;
6
6
  const total = source.length;
7
7
 
8
+ // for empty coverage
9
+ if (item.empty) {
10
+ return {
11
+ total,
12
+ covered: 0
13
+ };
14
+ }
15
+
8
16
  const uncoveredBytes = item.data.bytes.filter((range) => range.count === 0);
9
17
 
10
18
  let uncovered = 0;
package/lib/v8/v8.js CHANGED
@@ -24,17 +24,35 @@ const getWrapperSource = (offset, source) => {
24
24
  };
25
25
 
26
26
  const getEntryFilter = (options) => {
27
- const entryFilter = options.entryFilter;
28
- if (typeof entryFilter === 'function') {
29
- return entryFilter;
27
+ const input = options.entryFilter;
28
+
29
+ // for function handler
30
+ if (typeof input === 'function') {
31
+ return input;
30
32
  }
31
33
 
32
- if (entryFilter && typeof entryFilter === 'string') {
34
+ // for single minimatch pattern
35
+ if (input && typeof input === 'string') {
33
36
  return (entry) => {
34
- return minimatch(entry.url, entryFilter);
37
+ return minimatch(entry.url, input);
38
+ };
39
+ }
40
+
41
+ // for patterns
42
+ if (input && typeof input === 'object') {
43
+ const patterns = Object.keys(input);
44
+ return (entry) => {
45
+ const url = entry.url;
46
+ for (const pattern of patterns) {
47
+ if (minimatch(url, pattern)) {
48
+ return input[pattern];
49
+ }
50
+ }
51
+ // false if not matched
35
52
  };
36
53
  }
37
54
 
55
+ // default
38
56
  return () => true;
39
57
  };
40
58
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monocart-coverage-reports",
3
- "version": "2.5.7",
3
+ "version": "2.5.9",
4
4
  "description": "Monocart coverage reports",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {
@@ -31,11 +31,12 @@
31
31
  "test-istanbul": "node ./test/test-istanbul.js",
32
32
  "test-v8": "node ./test/test-v8.js",
33
33
  "test-puppeteer": "node ./test/test-puppeteer.js",
34
- "test-browser": "node ./test/test.js && npm run test-istanbul && npm run test-v8 && npm run test-puppeteer && npm run test-anonymous && npm run test-css",
34
+ "test-browser": "node ./test/test-browser.js && npm run test-istanbul && npm run test-v8 && npm run test-puppeteer && npm run test-anonymous && npm run test-css",
35
35
  "test-anonymous": "node ./test/test-anonymous.js",
36
36
  "test-css": "node ./test/test-css.js",
37
37
  "test-cli": "npx mcr \"node ./test/test-node-env.js\" -o docs/cli -c test/cli-options.js",
38
38
  "test-merge": "node ./test/test-merge.js",
39
+ "test-merge-istanbul": "node ./test/test-merge-istanbul.js",
39
40
  "test-all": "npm run test-browser && npm run test-node && npm run test-cli && npm run test-merge && npm run build-docs",
40
41
  "test": "npx mcr \"npm run test-all\" -c test/mcr-options.js",
41
42
  "dev": "sf d v8",