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.10 to 2.1.0

36

lib/default/options.js
module.exports = {
// (String) logging levels: off, error, info, debug
// {string} logging levels: off, error, info, debug
logging: 'info',
// (String) output dir
// {string} output dir
outputDir: './coverage-reports',
// (String) v8 or html for istanbul by default
// (Array) multiple reports with options
// {string} v8 or html for istanbul by default
// {array} multiple reports with options
// v8 report or istanbul supported reports

@@ -21,15 +21,15 @@ // reports: [

// (String) Report name. Defaults to "Coverage Report".
// {string} Report name. Defaults to "Coverage Report".
name: 'Coverage Report',
// [V8 only](String) Output [sub dir/]filename. Defaults to "index.html"
// (V8 only) {string} Output [sub dir/]filename. Defaults to "index.html"
outputFile: 'index.html',
// [V8 only](Boolean) Inline all scripts to the single HTML file. Defaults to false.
// (V8 only) {boolean} Inline all scripts to the single HTML file. Defaults to false.
inline: false,
// [V8 only](String) Assets path if not inline. Defaults to "./assets"
// (V8 only) {string} Assets path if not inline. Defaults to "./assets"
assetsPath: './assets',
// [V8 only](Function) A filter function to execute for each element in the V8 list.
// (V8 only) {function} A filter function to execute for each element in the V8 list.
// entryFilter: (entry) => {

@@ -43,28 +43,28 @@ // if (entry.url.indexOf('googleapis.com') !== -1) {

// [V8 only](Function) A filter function to execute for each element in the sources which unpacked from the source map.
// (V8 only) {function} A filter function to execute for each element in the sources which unpacked from the source map.
// sourceFilter: (sourcePath) => sourcePath.search(/src\/.+/) !== -1,
sourceFilter: null,
// [V8 only](Boolean) Enable/Disable ignoring uncovered codes with the special comments: /* v8 ignore next/next N/start/stop */
// (V8 only) {boolean} Enable/Disable ignoring uncovered codes with the special comments: v8 ignore next/next N/start/stop
v8Ignore: true,
// [Istanbul only] defaultSummarizer, sourceFinder
// (Istanbul only) defaultSummarizer, sourceFinder
// (Boolean) Generate lcov.info file, same as lcovonly report. Defaults to false.
// {boolean} Generate lcov.info file, same as lcovonly report. Defaults to false.
lcov: false,
// (Function) Source path handler.
// {function} Source path handler.
// sourcePath: (filePath) => `wwwroot/${filePath}`,
sourcePath: null,
// (String|Function) Specify the report path, especially when there are multiple reports. Defaults to outputDir/index.html.
// {string|function} Specify the report path, especially when there are multiple reports. Defaults to outputDir/index.html.
reportPath: null,
// (Array) watermarks for low/medium/high. Defaults to [50, 80]
// (Object) Istanbul: { statements:[50,80], functions:[50,80], branches:[50,80], lines:[50,80] }, V8: { bytes:[50,80] }.
// {array} watermarks for low/medium/high. Defaults to [50, 80]
// {object} Istanbul: { statements:[50,80], functions:[50,80], branches:[50,80], lines:[50,80] }, V8: { bytes:[50,80] }.
watermarks: [50, 80],
// (Function) onEnd hook
// {function} onEnd hook
// onEnd: async (reportData) => {}
onEnd: null
};

@@ -0,167 +1,240 @@

declare namespace MCR {
// https://playwright.dev/docs/api/class-coverage
export type V8CoverageEntry = {
url: string,
// css
text?: string,
ranges?: any[]
// js
scriptId?: string,
source?: string,
functions?: any[]
}
export interface V8CoverageEntry {
url: string;
/** css only */
text?: string;
/** css only */
ranges?: any[];
/** js only */
scriptId?: string;
/** js only */
source?: string;
/** js only */
functions?: any[];
}
export type Watermarks = [number, number] | {
statements?: [number, number],
functions?: [number, number],
branches?: [number, number],
lines?: [number, number],
bytes?: [number, number]
}
export type Watermarks = [number, number] | {
functions?: [number, number];
branches?: [number, number];
lines?: [number, number];
/** V8 only */
bytes?: [number, number];
/** Istanbul only */
statements?: [number, number];
}
export type ReportDescription =
['v8'] | ["v8", {
outputFile?: string,
inline?: boolean,
assetsPath?: string,
metrics?: Array<"bytes" | "functions" | "branches" | "lines">
}] |
['v8-json'] | ["v8-json", {
outputFile?: string
}] |
['console-summary'] | ['console-summary', {
metrics?: Array<"bytes" | "functions" | "branches" | "lines" | "statements">
}] |
['clover'] | ['clover', {
file?: string
}] |
['cobertura'] | ['cobertura', {
file?: string,
timestamp?: string,
projectRoot?: string
}] |
['html'] | ['html', {
subdir?: string,
verbose?: boolean,
linkMapper?: any,
skipEmpty?: boolean
}] |
['html-spa'] | ['html-spa', {
subdir?: string,
verbose?: boolean,
linkMapper?: any,
skipEmpty?: boolean,
metricsToShow?: Array<"lines" | "branches" | "functions" | "statements">
}] |
['json'] | ['json', {
file?: string
}] |
['json-summary'] | ['json-summary', {
file?: string
}] |
['lcov'] | ['lcov', {
file?: string,
projectRoot?: string
}] |
['lcovonly'] | ['lcovonly', {
file?: string,
projectRoot?: string
}] |
['none'] |
['teamcity'] | ['teamcity', {
file?: string,
blockName?: string
}] |
['text'] | ['text', {
file?: string,
maxCols?: number,
skipEmpty?: boolean,
skipFull?: boolean
}] |
['text-lcov'] | ['text-lcov', {
projectRoot?: string
}] |
['text-summary'] | ['text-summary', {
file?: string
}];
export type ReportDescription =
['v8'] | ["v8", {
outputFile?: string;
inline?: boolean;
assetsPath?: string;
metrics?: Array<"bytes" | "functions" | "branches" | "lines">;
}] |
['v8-json'] | ["v8-json", {
outputFile?: string;
}] |
['console-summary'] | ['console-summary', {
metrics?: Array<"bytes" | "functions" | "branches" | "lines" | "statements">;
}] |
['clover'] | ['clover', {
file?: string;
}] |
['cobertura'] | ['cobertura', {
file?: string;
timestamp?: string;
projectRoot?: string;
}] |
['html'] | ['html', {
subdir?: string;
verbose?: boolean;
linkMapper?: any;
skipEmpty?: boolean;
}] |
['html-spa'] | ['html-spa', {
subdir?: string;
verbose?: boolean;
linkMapper?: any;
skipEmpty?: boolean;
metricsToShow?: Array<"lines" | "branches" | "functions" | "statements">;
}] |
['json'] | ['json', {
file?: string;
}] |
['json-summary'] | ['json-summary', {
file?: string;
}] |
['lcov'] | ['lcov', {
file?: string;
projectRoot?: string;
}] |
['lcovonly'] | ['lcovonly', {
file?: string;
projectRoot?: string;
}] |
['none'] |
['teamcity'] | ['teamcity', {
file?: string;
blockName?: string;
}] |
['text'] | ['text', {
file?: string;
maxCols?: number;
skipEmpty?: boolean;
skipFull?: boolean;
}] |
['text-lcov'] | ['text-lcov', {
projectRoot?: string;
}] |
['text-summary'] | ['text-summary', {
file?: string;
}];
export type CoverageResults = {
type: "v8" | "istanbul",
reportPath: string,
name: string,
watermarks: Watermarks,
summary: any,
files: any
}
export type AddedResults = {
id: string;
path: string;
type: "v8" | "istanbul";
data: any;
} | undefined;
export type CoverageReportOptions = {
// (String) logging levels: off, error, info, debug
logging?: string,
export interface MetricsSummary {
covered: number;
uncovered?: number;
total: number;
pct: number | "";
status: "low" | "medium" | "high" | "unknown";
}
// (String) output dir
outputDir?: string,
export interface LinesSummary extends MetricsSummary {
/** V8 only */
blank?: number;
/** V8 only */
comment?: number;
}
// (String) v8 or html for istanbul by default
// (Array) multiple reports with options
// v8 report or istanbul supported reports
reports?: string | ReportDescription[],
export interface CoverageSummary {
functions: MetricsSummary;
branches: MetricsSummary;
lines: LinesSummary;
/** V8 only */
bytes?: MetricsSummary;
/** Istanbul only */
statements?: MetricsSummary;
}
// (String) Report name. Defaults to "Coverage Report".
name?: string,
/** V8 only */
export interface CoverageRange {
start: number;
end: number;
count: number;
ignored?: boolean;
none?: boolean;
}
// [V8 only](String) Output [sub dir/]filename. Defaults to "index.html"
outputFile?: string,
// [V8 only](Boolean) Inline all scripts to the single HTML file. Defaults to false.
inline?: boolean,
// [V8 only](String) Assets path if not inline. Defaults to "./assets"
assetsPath?: string
export interface CoverageFile {
sourcePath: string;
summary: CoverageSummary;
/** V8 only */
url?: string;
/** V8 only */
id?: string;
/** V8 only */
type?: string;
/** V8 only */
source?: string;
/** V8 only */
distFile?: string;
/** V8 only */
js?: boolean;
/** V8 only */
data?: {
bytes: CoverageRange[];
functions: CoverageRange[];
branches: CoverageRange[];
}
}
// [V8 only](Function) A filter function to execute for each element in the V8 list.
entryFilter?: (entry: V8CoverageEntry) => boolean,
export type CoverageResults = {
type: "v8" | "istanbul";
reportPath: string;
name: string;
watermarks: Watermarks;
summary: CoverageSummary;
files: CoverageFile[];
} | undefined;
// [V8 only](Function) A filter function to execute for each element in the sources which unpacked from the source map.
sourceFilter?: (sourcePath: string) => boolean,
export interface CoverageReportOptions {
// [V8 only](Boolean) Enable/Disable ignoring uncovered codes with the special comments: /* v8 ignore next/next N/start/stop */
v8Ignore?: boolean,
/** {string} logging levels: off, error, info, debug */
logging?: string;
// [Istanbul only] defaultSummarizer, sourceFinder
/** {string} output dir */
outputDir?: string;
// (Boolean) Generate lcov.info file, same as lcovonly report. Defaults to false.
lcov?: boolean,
/** {string} v8 or html for istanbul by default
* {array} multiple reports with options
* v8 report or istanbul supported reports */
reports?: string | ReportDescription[];
// (Function) Source path handler.
sourcePath?: (filePath: string) => string,
/** {string} Report name. Defaults to "Coverage Report". */
name?: string;
// (String|Function) Specify the report path, especially when there are multiple reports. Defaults to outputDir/index.html.
reportPath?: string | (() => string),
/** (V8 only) {string} Output [sub dir/]filename. Defaults to "index.html" */
outputFile?: string;
/** (V8 only) {boolean} Inline all scripts to the single HTML file. Defaults to false. */
inline?: boolean;
/** (V8 only) {string} Assets path if not inline. Defaults to "./assets" */
assetsPath?: string;
// (Array) watermarks for low/medium/high. Defaults to [50, 80]
// (Object) Istanbul: { statements:[50,80], functions:[50,80], branches:[50,80], lines:[50,80] }, V8: { bytes:[50,80] }.
watermarks?: Watermarks,
/** (V8 only) {function} A filter function to execute for each element in the V8 list. */
entryFilter?: (entry: V8CoverageEntry) => boolean;
// (Function) onEnd hook
onEnd?: (reportData: CoverageResults) => Promise<void>
}
/** (V8 only) {function} A filter function to execute for each element in the sources which unpacked from the source map. */
sourceFilter?: (sourcePath: string) => boolean;
export class CoverageReport {
constructor(options?: CoverageReportOptions);
/** (V8 only) {boolean} Enable/Disable ignoring uncovered codes with the special comments: v8 ignore next/next N/start/stop */
v8Ignore?: boolean;
// add coverage data: (Array) V8 format, (Object) Istanbul format
add: (coverageData: any[] | any) => Promise<any>;
/** (Istanbul only) defaultSummarizer, sourceFinder */
// generate report
generate: () => Promise<CoverageResults>;
/** {boolean} Generate lcov.info file, same as lcovonly report. Defaults to false. */
lcov?: boolean;
// check if cache exists
hasCache: () => boolean;
/** {function} Source path handler. */
sourcePath?: (filePath: string) => string;
// clean cache
cleanCache: () => boolean;
/** {string|function} Specify the report path, especially when there are multiple reports. Defaults to outputDir/index.html. */
reportPath?: string | (() => string);
/** {array} watermarks for low/medium/high. Defaults to [50, 80]
* {object} { statements:[50,80], functions:[50,80], branches:[50,80], lines:[50,80] }, V8: { bytes:[50,80] } */
watermarks?: Watermarks;
/** {function} onEnd hook */
onEnd?: (reportData: CoverageResults) => Promise<void>;
}
export class CoverageReport {
constructor(options?: CoverageReportOptions);
/** add coverage data: {array} V8 format, {object} Istanbul format */
add: (coverageData: any[] | any) => Promise<AddedResults>;
/** generate report */
generate: () => Promise<CoverageResults>;
/** check if cache exists */
hasCache: () => boolean;
/** clean previous cache, return `false` if no cache */
cleanCache: () => boolean;
}
}
export default CoverageReport;
/** create coverage report */
declare function MCR(options?: MCR.CoverageReportOptions): MCR.CoverageReport;
export function createCoverageReport(options?: CoverageReportOptions): CoverageReport;
export = MCR;

@@ -11,6 +11,2 @@ const fs = require('fs');

static createCoverageReport = (options) => {
return new CoverageReport(options);
};
constructor(options = {}) {

@@ -46,3 +42,3 @@ this.cacheDirName = '.cache';

// add coverage data: (Array) V8 format, (Object) Istanbul format
// add coverage data: {array} V8 format, {object} Istanbul format
async add(data) {

@@ -138,2 +134,8 @@

module.exports = CoverageReport;
/** create coverage report */
const MCR = function(options) {
return new CoverageReport(options);
};
MCR.CoverageReport = CoverageReport;
module.exports = MCR;

@@ -31,4 +31,7 @@ const istanbulLibReport = require('istanbul-lib-report');

this.addStatus(fileSummary);
fileSummary.name = node.getRelativeName();
this.files.push(fileSummary);
const sourcePath = node.getQualifiedName();
this.files.push({
sourcePath,
summary: fileSummary
});
}

@@ -35,0 +38,0 @@

@@ -278,4 +278,2 @@ const path = require('path');

const summaryList = v8list.map((entry) => entry.summary);
const coverageResults = {

@@ -287,3 +285,3 @@ type: 'v8',

summary,
files: summaryList
files: v8list
};

@@ -290,0 +288,0 @@

{
"name": "monocart-coverage-reports",
"version": "2.0.10",
"version": "2.1.0",
"description": "Monocart coverage reports",

@@ -45,8 +45,8 @@ "main": "lib/index.js",

"dependencies": {
"console-grid": "~2.0.1",
"eight-colors": "~1.0.3",
"console-grid": "~2.1.0",
"eight-colors": "~1.2.1",
"istanbul-lib-coverage": "~3.2.2",
"istanbul-lib-report": "~3.0.1",
"istanbul-reports": "~3.1.6",
"lz-utils": "~2.0.1",
"lz-utils": "~2.0.2",
"monocart-code-viewer": "~1.0.13",

@@ -60,3 +60,3 @@ "monocart-formatter": "~2.3.0",

"eslint-plugin-html": "^7.1.0",
"eslint-plugin-vue": "^9.19.2",
"eslint-plugin-vue": "^9.20.0",
"stylelint": "^15.11.0",

@@ -63,0 +63,0 @@ "stylelint-config-plus": "^1.0.4"

@@ -33,3 +33,3 @@ # Monocart Coverage Reports

```js
const CoverageReport = require('monocart-coverage-reports');
const MCR = require('monocart-coverage-reports');
const options = {

@@ -39,3 +39,3 @@ outputDir: './coverage-reports',

}
const coverageReport = new CoverageReport(options);
const coverageReport = MCR(options);
await coverageReport.add(coverageData1);

@@ -87,3 +87,3 @@ await coverageReport.add(coverageData2);

```js
const CoverageReport = require('monocart-coverage-reports');
const MCR = require('monocart-coverage-reports');
const options = {

@@ -103,3 +103,3 @@ outputDir: './coverage-reports',

}
const coverageReport = new CoverageReport(options);
const coverageReport = MCR(options);
```

@@ -116,5 +116,5 @@

```js
const CoverageReport = require('monocart-coverage-reports');
const MCR = require('monocart-coverage-reports');
const options = require('path-to/same-options.js');
const coverageReport = new CoverageReport(options);
const coverageReport = MCR(options);
await coverageReport.add(coverageData1);

@@ -125,5 +125,5 @@ ```

```js
const CoverageReport = require('monocart-coverage-reports');
const MCR = require('monocart-coverage-reports');
const options = require('path-to/same-options.js');
const coverageReport = new CoverageReport(options);
const coverageReport = MCR(options);
await coverageReport.add(coverageData2);

@@ -135,5 +135,5 @@ ```

// after all sub processes finished
const CoverageReport = require('monocart-coverage-reports');
const MCR = require('monocart-coverage-reports');
const options = require('path-to/same-options.js');
const coverageReport = new CoverageReport(options);
const coverageReport = MCR(options);
const coverageResults = await coverageReport.generate();

@@ -140,0 +140,0 @@ console.log(coverageResults.summary);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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