monocart-coverage-reports 2.4.4 → 2.5.0

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 CHANGED
@@ -56,24 +56,22 @@ console.log(coverageResults.summary);
56
56
  - [lib/default/options.js](https://github.com/cenfun/monocart-coverage-reports/blob/main/lib/default/options.js)
57
57
 
58
58
  ## Available Reports
59
- - `v8` (V8 data only)
60
- - Test in browser
61
- - Build with webpack: [V8](https://cenfun.github.io/monocart-coverage-reports/v8) and [V8 Minify](https://cenfun.github.io/monocart-coverage-reports/v8-minify)
62
- - Build with [Rollup](https://cenfun.github.io/monocart-coverage-reports/v8-rollup) and [Esbuild](https://cenfun.github.io/monocart-coverage-reports/v8-esbuild)
63
- - Collect with [puppeteer](https://cenfun.github.io/monocart-coverage-reports/puppeteer/)
64
- - [anonymous](https://cenfun.github.io/monocart-coverage-reports/anonymous/) and [css](https://cenfun.github.io/monocart-coverage-reports/css/)
65
- - Test in Node.js
66
- - Collect with [env](https://cenfun.github.io/monocart-coverage-reports/v8-node-env), and also V8 [API](https://cenfun.github.io/monocart-coverage-reports/v8-node-api), [Inspector](https://cenfun.github.io/monocart-coverage-reports/v8-node-ins) and [CDP](https://cenfun.github.io/monocart-coverage-reports/v8-node-cdp)
67
- - Web server example: [koa](https://cenfun.github.io/monocart-coverage-reports/v8-node-koa/)
59
+ > V8 build-in reports (V8 data only):
60
+ - `v8`
61
+ - Browser: Build with webpack [V8](https://cenfun.github.io/monocart-coverage-reports/v8) and [V8 Minify](https://cenfun.github.io/monocart-coverage-reports/v8-minify); Build with [Rollup](https://cenfun.github.io/monocart-coverage-reports/v8-rollup) and [Esbuild](https://cenfun.github.io/monocart-coverage-reports/v8-esbuild); Collect with [puppeteer](https://cenfun.github.io/monocart-coverage-reports/puppeteer/); [anonymous](https://cenfun.github.io/monocart-coverage-reports/anonymous/) and [css](https://cenfun.github.io/monocart-coverage-reports/css/)
62
+ - Node.js: Collect with [env](https://cenfun.github.io/monocart-coverage-reports/v8-node-env), and also V8 [API](https://cenfun.github.io/monocart-coverage-reports/v8-node-api), [Inspector](https://cenfun.github.io/monocart-coverage-reports/v8-node-ins) and [CDP](https://cenfun.github.io/monocart-coverage-reports/v8-node-cdp); Web server example: [koa](https://cenfun.github.io/monocart-coverage-reports/v8-node-koa/)
68
63
 
69
64
  ![](test/v8.gif)
70
65
 
71
- - `v8-json` (V8 data only)
66
+ - `v8-json`
72
67
  - [V8 coverage-report.json](https://cenfun.github.io/monocart-coverage-reports/v8-and-istanbul/coverage-report.json)
73
- - `codecov` (V8 data only)
68
+ - `codecov`
74
69
  - coverage data for [Codecov](https://docs.codecov.com/docs/codecov-custom-coverage-format), see [example](https://app.codecov.io/github/cenfun/monocart-coverage-reports)
70
+ - `console-details` Show file coverage and uncovered lines in the console. Like `text`, but for V8.
75
71
 
76
- > Istanbul [build-in reports](https://github.com/istanbuljs/istanbuljs/tree/master/packages/istanbul-reports/lib)
72
+ ![](test/console-details.png)
73
+
74
+ > Istanbul build-in reports (both V8 and istanbul data):
77
75
  - `clover`
78
76
  - `cobertura`
79
77
  - `html`
@@ -93,9 +91,11 @@ console.log(coverageResults.summary);
93
91
  - `text-lcov`
94
92
  - `text-summary`
95
93
 
96
- > Other reports
97
- - `console-summary` shows coverage summary in console
94
+ > Other reports:
95
+ - `console-summary` shows coverage summary in the console
96
+
98
97
  ![](test/console-summary.png)
98
+
99
99
  - `raw` only keep all original data, which can be used for other reports input with `inputDir`
100
100
  - see [Merge Coverage Reports](#merge-coverage-reports)
101
101
 
package/lib/generate.js CHANGED
@@ -72,6 +72,7 @@ const getReportGroup = (reports, lcov, dataType) => {
72
72
  'v8': 'v8',
73
73
  'v8-json': 'v8',
74
74
  'codecov': 'v8',
75
+ 'console-details': 'v8',
75
76
 
76
77
  // istanbul
77
78
  'clover': 'istanbul',
@@ -126,22 +127,9 @@ const getReportGroup = (reports, lcov, dataType) => {
126
127
 
127
128
  // ========================================================================================================
128
129
 
129
- const capitalizeFirstLetter = (string) => {
130
- return string.charAt(0).toUpperCase() + string.slice(1);
131
- };
132
-
133
130
  const pFormatter = (v, row, column) => {
134
131
  if (typeof v === 'number') {
135
- const p = Util.PSF(v, 100, 2);
136
- if (row.status === 'low') {
137
- return EC.red(p);
138
- }
139
- if (row.status === 'medium') {
140
- return EC.yellow(p);
141
- }
142
- if (row.status === 'high') {
143
- return EC.green(p);
144
- }
132
+ return Util.getColorStrByStatus(Util.PSF(v, 100, 2), row.status);
145
133
  }
146
134
  return v;
147
135
  };
@@ -153,9 +141,12 @@ const nFormatter = (v) => {
153
141
  return v;
154
142
  };
155
143
 
156
- const showConsoleSummary = (reportData, reportOptions, options) => {
144
+ const handleConsoleSummaryReport = (reportData, reportOptions, options) => {
157
145
 
158
- const { metrics } = reportOptions;
146
+ const csOptions = {
147
+ metrics: [],
148
+ ... reportOptions
149
+ };
159
150
 
160
151
  const {
161
152
  summary, name, type
@@ -165,23 +156,12 @@ const showConsoleSummary = (reportData, reportOptions, options) => {
165
156
  EC.logCyan(name);
166
157
  }
167
158
 
168
- const allMetrics = {
169
- v8: ['bytes', 'statements', 'branches', 'functions', 'lines'],
170
- istanbul: ['statements', 'branches', 'functions', 'lines']
171
- };
172
-
173
- let list = allMetrics[type];
174
- if (Util.isList(metrics)) {
175
- const newList = list.filter((k) => metrics.includes(k));
176
- if (newList.length) {
177
- list = newList;
178
- }
179
- }
159
+ const metrics = Util.getMetrics(type, csOptions.metrics);
180
160
 
181
- const rows = list.map((k) => {
161
+ const rows = metrics.map((k) => {
182
162
  return {
183
163
  ... summary[k],
184
- name: capitalizeFirstLetter(k)
164
+ name: Util.capitalizeFirstLetter(k)
185
165
  };
186
166
  });
187
167
 
@@ -216,7 +196,7 @@ const showConsoleSummary = (reportData, reportOptions, options) => {
216
196
  });
217
197
  };
218
198
 
219
- const saveRawReport = (reportData, reportOptions, options) => {
199
+ const handleRawReport = (reportData, reportOptions, options) => {
220
200
  const rawOptions = {
221
201
  outputDir: 'raw',
222
202
  ... reportOptions
@@ -285,8 +265,8 @@ const generateCoverageReports = async (dataList, sourceCache, options) => {
285
265
  // console.log(Object.keys(coverageResults));
286
266
 
287
267
  const buildInBothReports = {
288
- 'console-summary': showConsoleSummary,
289
- 'raw': saveRawReport
268
+ 'console-summary': handleConsoleSummaryReport,
269
+ 'raw': handleRawReport
290
270
  };
291
271
 
292
272
  const bothGroup = options.reportGroup.both;
package/lib/index.d.ts CHANGED
@@ -36,6 +36,11 @@ declare namespace MCR {
36
36
  ['codecov'] | ["codecov", {
37
37
  outputFile?: string;
38
38
  }] |
39
+ ['console-details'] | ['console-details', {
40
+ maxCols?: number;
41
+ skipPercent?: number;
42
+ metrics?: Array<"bytes" | "statements" | "branches" | "functions" | "lines">;
43
+ }] |
39
44
  ['clover'] | ['clover', {
40
45
  file?: string;
41
46
  }] |