Skip to content

Commit

Permalink
fix empty functions and ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
cenfun committed Sep 15, 2024
1 parent 5f60e4e commit ee19c06
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/converter/untested.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ const getUntestedCoverageData = async (emptyList, options, coverageType) => {

// save all empty source and sourcemap
for (const entryFile of emptyList) {

// for raw report: source file
await saveUntestedFileSource(entryFile, options);

const { type, url } = entryFile;
Expand All @@ -187,7 +189,7 @@ const getUntestedCoverageData = async (emptyList, options, coverageType) => {
// ===============================================
if (type === 'js') {
// empty js
entryFile.functions = [{
entryFile.functions = entryFile.functions || [{
functionName: '',
ranges: [{
startOffset: 0,
Expand All @@ -197,7 +199,7 @@ const getUntestedCoverageData = async (emptyList, options, coverageType) => {
}];
} else {
// empty css
entryFile.ranges = [];
entryFile.ranges = entryFile.ranges || [];
}

const item = {
Expand All @@ -208,13 +210,14 @@ const getUntestedCoverageData = async (emptyList, options, coverageType) => {

// array
results.data.push(item);
// will be parsed to AST and converted to V8 coverage
emptyCoverageList.push(entryFile);

}

}


// for raw report: coverage file
const { cachePath } = Util.getCacheFileInfo('coverage', dataId, options.cacheDir);
await Util.writeFile(cachePath, JSON.stringify(results));

Expand Down

0 comments on commit ee19c06

Please sign in to comment.