monocart-coverage-reports
Advanced tools
Comparing version 2.3.0 to 2.3.1
@@ -6,5 +6,2 @@ /** | ||
*/ | ||
const path = require('path'); | ||
const Util = require('../utils/util.js'); | ||
@@ -425,3 +422,3 @@ | ||
const handleOriginalFunctionsCoverage = (state, originalMap) => { | ||
const handleOriginalFunctionsCoverage = (state, originalStateMap) => { | ||
@@ -452,3 +449,3 @@ // functions only for js | ||
const result = findOriginalRange(range, state, originalMap); | ||
const result = findOriginalRange(range, state, originalStateMap); | ||
if (result.error) { | ||
@@ -477,3 +474,3 @@ return; | ||
const handleOriginalBranchesCoverage = (state, originalMap) => { | ||
const handleOriginalBranchesCoverage = (state, originalStateMap) => { | ||
@@ -499,3 +496,3 @@ // branches only for js | ||
// start | ||
const result = findOriginalRange(bRange, state, originalMap); | ||
const result = findOriginalRange(bRange, state, originalStateMap); | ||
if (result.error) { | ||
@@ -529,3 +526,3 @@ // not in the original files | ||
}; | ||
const res = findOriginalRange(lRange, state, originalMap); | ||
const res = findOriginalRange(lRange, state, originalStateMap); | ||
if (res.error) { | ||
@@ -568,3 +565,3 @@ // It should not happen unless it is minify files, the SourceMap has some order problems | ||
const handleOriginalBytesCoverage = (state, originalMap) => { | ||
const handleOriginalBytesCoverage = (state, originalStateMap) => { | ||
@@ -585,3 +582,3 @@ const { js, coverageList } = state; | ||
const result = findOriginalRange(range, state, originalMap); | ||
const result = findOriginalRange(range, state, originalStateMap); | ||
if (result.error) { | ||
@@ -610,2 +607,43 @@ return; | ||
// check original bytes if fully in a wrapper range | ||
originalStateMap.forEach((originalState) => { | ||
const bytes = originalState.bytes; | ||
if (Util.isList(bytes)) { | ||
return; | ||
} | ||
const { decodedMappings } = originalState; | ||
const len = decodedMappings.length; | ||
if (len < 2) { | ||
return; | ||
} | ||
// sort by original line/column | ||
const startMapping = decodedMappings[0]; | ||
const endMapping = decodedMappings[len - 1]; | ||
// console.log(startMapping, endMapping); | ||
const startOffset = startMapping.generatedOffset; | ||
const endOffset = endMapping.generatedEndOffset || endMapping.generatedOffset; | ||
// console.log('===========================================================', originalState.sourcePath); | ||
// console.log(originalState.source.length, endMapping); | ||
// only check uncovered range | ||
// because a uncovered range could be in a covered wrapper | ||
// { start: 0, end: 12137, count: 1 }, could be { start: > 0, end: < 12137, count: 0 } | ||
for (const range of state.bytes) { | ||
if (range.count > 0) { | ||
continue; | ||
} | ||
if (startOffset >= range.start && endOffset <= range.end) { | ||
bytes.push({ | ||
start: 0, | ||
end: originalState.source.length, | ||
count: 0 | ||
}); | ||
break; | ||
} | ||
} | ||
}); | ||
}; | ||
@@ -717,3 +755,3 @@ | ||
// create original content mappings | ||
const originalMap = new Map(); | ||
const originalStateMap = new Map(); | ||
@@ -765,15 +803,15 @@ const { sources, sourcesContent } = state.sourceMap; | ||
originalMap.set(sourceIndex, originalState); | ||
originalStateMap.set(sourceIndex, originalState); | ||
}); | ||
return originalMap; | ||
return originalStateMap; | ||
}; | ||
const collectOriginalList = (state, originalMap) => { | ||
const collectOriginalList = (state, originalStateMap) => { | ||
const { fileUrls, sourceMap } = state; | ||
const distFile = sourceMap.file || path.basename(state.sourcePath); | ||
const { fileUrls } = state; | ||
const distFile = state.sourcePath; | ||
// collect original files | ||
originalMap.forEach((originalState) => { | ||
originalStateMap.forEach((originalState) => { | ||
@@ -835,3 +873,3 @@ const { | ||
// filter original list and init list | ||
const originalMap = initOriginalList(state, originalDecodedMap, options); | ||
const originalStateMap = initOriginalList(state, originalDecodedMap, options); | ||
@@ -843,7 +881,7 @@ originalDecodedMap.clear(); | ||
// handle functions before handle original state functions | ||
handleOriginalFunctionsCoverage(state, originalMap); | ||
handleOriginalBranchesCoverage(state, originalMap); | ||
handleOriginalFunctionsCoverage(state, originalStateMap); | ||
handleOriginalBranchesCoverage(state, originalStateMap); | ||
// handle lines info before handle ranges to update line count | ||
originalMap.forEach((originalState) => { | ||
originalStateMap.forEach((originalState) => { | ||
@@ -860,6 +898,6 @@ handleFunctionsCoverage(originalState); | ||
// handle ranges after lines ready | ||
handleOriginalBytesCoverage(state, originalMap); | ||
handleOriginalBytesCoverage(state, originalStateMap); | ||
// collect coverage for original list | ||
collectOriginalList(state, originalMap); | ||
collectOriginalList(state, originalStateMap); | ||
@@ -866,0 +904,0 @@ }; |
@@ -586,2 +586,4 @@ | ||
// after column fixed, the originalOffset could be not right | ||
const locator = originalState.locator; | ||
@@ -588,0 +590,0 @@ const originalStart = locator.locationToOffset({ |
{ | ||
"name": "monocart-coverage-reports", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"description": "Monocart coverage reports", | ||
@@ -59,3 +59,3 @@ "main": "./lib/index.js", | ||
"monocart-code-viewer": "~1.0.13", | ||
"monocart-formatter": "~2.3.0", | ||
"monocart-formatter": "~2.3.1", | ||
"turbogrid": "^3.0.13" | ||
@@ -62,0 +62,0 @@ }, |
@@ -423,3 +423,4 @@ # Monocart Coverage Reports | ||
```js | ||
import {CoverageReport} from 'monocart-coverage-reports'; | ||
import fs from "fs"; | ||
import { CoverageReport } from 'monocart-coverage-reports'; | ||
const coverageOptions = { | ||
@@ -435,3 +436,10 @@ name: 'My Merged Coverage Report', | ||
['console-summary'] | ||
] | ||
], | ||
onEnd: () => { | ||
// remove the raw files if it useless | ||
fs.rmSync('./coverage-reports/unit/raw', { | ||
recursive: true, | ||
force: true | ||
}) | ||
} | ||
}; | ||
@@ -438,0 +446,0 @@ await new CoverageReport(coverageOptions).generate(); |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
891296
6925
592
Updatedmonocart-formatter@~2.3.1