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.9.1 to 2.9.2

lib/converter/flatten-source-maps.js

60

lib/converter/collect-source-maps.js

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

const { convertSourceMap } = require('../packages/monocart-coverage-vendor.js');
const { flattenSourceMaps } = require('./flatten-source-maps.js');

@@ -104,2 +105,45 @@ const Util = require('../utils/util.js');

const checkSourcesContent = (data) => {
const { sourcesContent, sources } = data;
if (!sourcesContent) {
data.sourcesContent = [];
return false;
}
// all should be string, could be [null]
const contents = sourcesContent.filter((content) => typeof content === 'string');
if (contents.length === sources.length) {
return true;
}
return false;
};
const resolveSectionedSourceMap = (data, url, sections) => {
let hasSourceContent = false;
sections.forEach((item) => {
// offset: { line: 1, column: 0 },
// map: { sources, sourcesContent }
const map = item.map;
if (checkSourcesContent(map)) {
hasSourceContent = true;
return;
}
const done = resolveSourcesContent(map, url);
if (done) {
hasSourceContent = true;
}
});
if (hasSourceContent) {
return flattenSourceMaps(data);
}
};
const resolveSourceMap = (data, url) => {

@@ -110,5 +154,9 @@ if (!data) {

const {
sources, sourcesContent, mappings
sections, sources, mappings
} = data;
if (sections) {
return resolveSectionedSourceMap(data, url, sections);
}
if (!sources || !mappings) {

@@ -119,10 +167,4 @@ return;

// check sources content
if (sourcesContent) {
// all should be string, could be [null]
const contents = sourcesContent.filter((content) => typeof content === 'string');
if (contents.length === sources.length) {
return data;
}
} else {
data.sourcesContent = [];
if (checkSourcesContent(data)) {
return data;
}

@@ -129,0 +171,0 @@

8

lib/converter/converter.js

@@ -844,6 +844,10 @@ /**

const { sources, mappings } = state.sourceMap;
const {
sources, mappings, decodedMappings
} = state.sourceMap;
const decodedList = decode(mappings);
const decodedList = decodedMappings || decode(mappings);
// console.log(decodedList);
sources.forEach((source, i) => {

@@ -850,0 +854,0 @@ originalDecodedMap.set(i, []);

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

str = str.replace(/\\\\/g, '/');
str = str.replace(/\?/g, '/');
// decodeURI("%20") to space

@@ -40,0 +42,0 @@ str = decodeURI(str);

{
"name": "monocart-coverage-reports",
"version": "2.9.1",
"version": "2.9.2",
"description": "A code coverage tool to generate native V8 reports or Istanbul reports.",

@@ -46,2 +46,3 @@ "main": "./lib/index.js",

"test-rollup": "node ./test/test-rollup.js",
"test-sections": "node ./test/test-sections.js",
"test-swc": "node ./test/test-swc.js",

@@ -79,3 +80,3 @@ "test-v8-and-istanbul": "node ./test/test-v8-and-istanbul.js",

"@bcoe/v8-coverage": "^0.2.3",
"@jridgewell/sourcemap-codec": "^1.4.15",
"@jridgewell/sourcemap-codec": "^1.5.0",
"acorn": "^8.12.1",

@@ -93,3 +94,3 @@ "acorn-loose": "^8.4.0",

"lz-utils": "^2.0.2",
"minimatch": "^9.0.5",
"minimatch": "^10.0.1",
"monocart-code-viewer": "^1.1.4",

@@ -102,3 +103,3 @@ "monocart-formatter": "^3.0.0",

"esbuild": "^0.23.0",
"eslint": "~9.6.0",
"eslint": "~9.7.0",
"eslint-config-plus": "^2.0.2",

@@ -109,3 +110,3 @@ "eslint-plugin-html": "^8.1.1",

"starfall-cli": "^2.0.20",
"stylelint": "^16.6.1",
"stylelint": "^16.7.0",
"stylelint-config-plus": "^1.1.2",

@@ -112,0 +113,0 @@ "supports-color": "^9.4.0",

@@ -588,3 +588,17 @@ # Monocart Coverage Reports

```
Normalize the full path of the file:
```js
const path = require("path")
// MCR coverage options
const coverageOptions = {
sourcePath: (filePath, info)=> {
if (!filePath.includes('/') && info.distFile) {
return `${path.dirname(info.distFile)}/${filePath}`;
}
return filePath;
}
}
```
## Adding Empty Coverage for Untested Files

@@ -591,0 +605,0 @@ By default the untested files will not be included in the coverage report, we can add empty coverage data for all files with option `all`, the untested files will show 0% coverage.

@@ -591,3 +591,17 @@ # Monocart Coverage Reports

```
解决文件路径不完整的问题:
```js
const path = require("path")
// MCR coverage options
const coverageOptions = {
sourcePath: (filePath, info)=> {
if (!filePath.includes('/') && info.distFile) {
return `${path.dirname(info.distFile)}/${filePath}`;
}
return filePath;
}
}
```
## Adding Empty Coverage for Untested Files

@@ -594,0 +608,0 @@ 默认,未测试的文件是不会包含到覆盖率报告的,需要使用`all`选项来为这些文件添加一个空的覆盖率,也就是0%

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