monocart-coverage-reports 2.5.7 → 2.5.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/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.8",
4
4
  "description": "Monocart coverage reports",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {
@@ -31,7 +31,7 @@
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",