Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

monocart-coverage-reports

Package Overview
Dependencies
Maintainers
1
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

monocart-coverage-reports - npm Package Compare versions

Comparing version 2.0.5 to 2.0.6

116

lib/generate.js
const fs = require('fs');
const path = require('path');
const CG = require('console-grid');
const EC = require('eight-colors');
const Util = require('./utils/util.js');

@@ -75,2 +76,5 @@ const {

// both
'console-summary',
// istanbul

@@ -99,2 +103,3 @@ 'clover',

// v8
if (k.startsWith('v8')) {

@@ -109,2 +114,8 @@ // v8

// both
if (k === 'console-summary') {
reportGroup[k] = reportMap[k];
return;
}
// istanbul

@@ -120,3 +131,5 @@ if (!reportGroup.istanbul) {

// ========================================================================================================
const generateCoverageReports = async (dataList, options) => {

@@ -151,3 +164,5 @@

// ========================================================================================================
const getCoverageDataList = async (cacheDir) => {

@@ -172,6 +187,103 @@ const files = fs.readdirSync(cacheDir).filter((f) => f.startsWith('coverage-'));

// ========================================================================================================
const capitalizeFirstLetter = (string) => {
return string.charAt(0).toUpperCase() + string.slice(1);
};
const pFormatter = (v, row, column) => {
if (typeof v === 'number') {
const p = Util.PSF(v, 100, 2);
if (row.status === 'low') {
return EC.red(p);
}
if (row.status === 'medium') {
return EC.yellow(p);
}
if (row.status === 'high') {
return EC.green(p);
}
}
return v;
};
const nFormatter = (v) => {
if (typeof v === 'number') {
return Util.NF(v);
}
return v;
};
const showConsoleSummary = (coverageResults, options) => {
const reportGroup = options.reportGroup;
const consoleOptions = reportGroup['console-summary'];
if (!consoleOptions) {
return;
}
const {
summary, name, type
} = coverageResults;
if (name) {
EC.logCyan(name);
}
const indicators = {
v8: ['bytes', 'functions', 'branches', 'lines'],
istanbul: ['statements', 'functions', 'branches', 'lines']
};
const list = indicators[type] || indicators.v8;
const rows = list.map((k) => {
return {
... summary[k],
name: capitalizeFirstLetter(k)
};
});
const columns = [{
id: 'name',
name: 'Name'
}, {
id: 'pct',
name: 'Coverage %',
align: 'right',
formatter: pFormatter
}, {
id: 'covered',
name: 'Covered',
align: 'right',
formatter: nFormatter
}, {
id: 'uncovered',
name: 'Uncovered',
align: 'right',
formatter: nFormatter
}, {
id: 'total',
name: 'Total',
align: 'right',
formatter: nFormatter
}];
if (type === 'istanbul') {
columns.splice(4, 0, {
id: 'skipped',
name: 'Skipped',
align: 'right',
formatter: nFormatter
});
}
CG({
columns,
rows
});
};
module.exports = {
getCoverageDataList,
generateCoverageReports
generateCoverageReports,
showConsoleSummary
};

@@ -31,2 +31,3 @@

}] |
['console-summary'] |
['clover'] | ['clover', {

@@ -33,0 +34,0 @@ file?: string

@@ -7,3 +7,5 @@ const fs = require('fs');

const { initV8ListAndSourcemap } = require('./v8/v8.js');
const { getCoverageDataList, generateCoverageReports } = require('./generate.js');
const {
getCoverageDataList, generateCoverageReports, showConsoleSummary
} = require('./generate.js');

@@ -111,2 +113,4 @@ class CoverageReport {

showConsoleSummary(coverageResults, this.options);
const onEnd = this.options.onEnd;

@@ -113,0 +117,0 @@ if (typeof onEnd === 'function') {

@@ -40,2 +40,15 @@ const istanbulLibReport = require('istanbul-lib-report');

getReport() {
// remove branchesTrue
delete this.summary.branchesTrue;
// add uncovered
Object.keys(this.summary).forEach((id) => {
const item = this.summary[id];
// NOTE: skipped
item.uncovered = item.total - item.covered - item.skipped;
});
// console.log(this.summary);
return {

@@ -42,0 +55,0 @@ summary: this.summary,

2

package.json
{
"name": "monocart-coverage-reports",
"version": "2.0.5",
"version": "2.0.6",
"description": "Monocart coverage reports",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -9,8 +9,5 @@ # Monocart Coverage Reports

* [Preview Reports](#preview-reports)
* [Usage](#usage)
* [Default Options](#default-options)
* [Multiple Reports](#multiple-reports)
- [V8 reports](#v8-reports)
- [Istanbul reports](#istanbul-reports)
* [Available Reports](#available-reports)
* [Multiprocessing Support](#multiprocessing-support)

@@ -30,10 +27,2 @@ * [Compare Reports](#compare-reports)

## Preview Reports
- [V8](https://cenfun.github.io/monocart-coverage-reports/v8) - Example for browser, build with webpack, and also [Rollup](https://cenfun.github.io/monocart-coverage-reports/v8-rollup) and [Esbuild](https://cenfun.github.io/monocart-coverage-reports/v8-esbuild)
- [V8 Node](https://cenfun.github.io/monocart-coverage-reports/v8-node-env) - Example for Node.js using 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)
- [V8 Minify](https://cenfun.github.io/monocart-coverage-reports/v8-minify)
- [V8 to Istanbul](https://cenfun.github.io/monocart-coverage-reports/v8-and-istanbul/istanbul)
- [Istanbul](https://cenfun.github.io/monocart-coverage-reports/istanbul/)
- [Integration with Monocart Reporter](https://cenfun.github.io/monocart-reporter/) - Playwright test report
## Usage

@@ -58,21 +47,3 @@ ```js

## Multiple Reports
### V8 reports
- v8 (html)
- v8-json
### [Istanbul reports](https://github.com/istanbuljs/istanbuljs/tree/master/packages/istanbul-reports/lib)
- clover
- cobertura
- html
- html-spa
- json
- json-summary
- lcov
- lcovonly
- none
- teamcity
- text
- text-lcov
- text-summary
## Available Reports
```js

@@ -83,2 +54,3 @@ const CoverageReport = require('monocart-coverage-reports');

reports: [
['console-summary'],
['v8'],

@@ -96,3 +68,40 @@ ['html', {

```
- `v8` (V8 data only)
- [V8 html](https://cenfun.github.io/monocart-coverage-reports/v8) - Example for browser, build with webpack, and also [Rollup](https://cenfun.github.io/monocart-coverage-reports/v8-rollup) and [Esbuild](https://cenfun.github.io/monocart-coverage-reports/v8-esbuild)
- [V8 Node](https://cenfun.github.io/monocart-coverage-reports/v8-node-env) - Example for Node.js using 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)
- [V8 Minify](https://cenfun.github.io/monocart-coverage-reports/v8-minify)
![](test/v8.gif)
- `v8-json` (V8 data only)
- [V8 coverage-report.json](https://cenfun.github.io/monocart-coverage-reports/v8-and-istanbul/coverage-report.json)
- `console-summary` shows coverage summary in console
![](test/console-summary.png)
> Following are [istanbul reports](https://github.com/istanbuljs/istanbuljs/tree/master/packages/istanbul-reports/lib)
- `clover`
- `cobertura`
- `html`
- [Istanbul html](https://cenfun.github.io/monocart-coverage-reports/istanbul/)
- [V8 to Istanbul](https://cenfun.github.io/monocart-coverage-reports/v8-and-istanbul/istanbul)
- `html-spa`
- [Istanbul html-spa](https://cenfun.github.io/monocart-coverage-reports/istanbul/html-spa/)
- `json`
- `json-summary`
- `lcov`
- `lcovonly`
- [V8 lcov.info](https://cenfun.github.io/monocart-coverage-reports/v8/lcov.info)
- [Istanbul lcov.info](https://cenfun.github.io/monocart-coverage-reports/istanbul/lcov.info)
- `none`
- `teamcity`
- `text`
- `text-lcov`
- `text-summary`
## Integration
- [monocart-reporter](https://cenfun.github.io/monocart-reporter/) - Test reporter for [Playwright](https://github.com/microsoft/playwright)
- [vitest-monocart-coverage](https://github.com/cenfun/vitest-monocart-coverage) - Integration with [Vitest](https://github.com/vitest-dev/vitest) coverage
## Multiprocessing Support

@@ -99,0 +108,0 @@ The data will be added to `[outputDir]/.cache`, and the cache will be removed after reports generated.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc