From ee19c06c905108dc4a1c27df224b49a4558d083b Mon Sep 17 00:00:00 2001 From: cenfun Date: Sun, 15 Sep 2024 14:31:07 +0800 Subject: [PATCH] fix empty functions and ranges --- lib/converter/untested.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/converter/untested.js b/lib/converter/untested.js index 91a6371..3a0328a 100644 --- a/lib/converter/untested.js +++ b/lib/converter/untested.js @@ -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; @@ -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, @@ -197,7 +199,7 @@ const getUntestedCoverageData = async (emptyList, options, coverageType) => { }]; } else { // empty css - entryFile.ranges = []; + entryFile.ranges = entryFile.ranges || []; } const item = { @@ -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));