MCPcopy Index your code
hub / github.com/nodejs/node / summary

Method summary

lib/internal/test_runner/coverage.js:206–356  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

204 }
205
206 summary() {
207 internalBinding('profiler').takeCoverage();
208 const coverage = this.getCoverageFromDirectory();
209 const coverageSummary = {
210 __proto__: null,
211 workingDirectory: this.options.cwd,
212 files: [],
213 totals: {
214 __proto__: null,
215 totalLineCount: 0,
216 totalBranchCount: 0,
217 totalFunctionCount: 0,
218 coveredLineCount: 0,
219 coveredBranchCount: 0,
220 coveredFunctionCount: 0,
221 coveredLinePercent: 0,
222 coveredBranchPercent: 0,
223 coveredFunctionPercent: 0,
224 },
225 thresholds: {
226 __proto__: null,
227 line: this.options.lineCoverage,
228 branch: this.options.branchCoverage,
229 function: this.options.functionCoverage,
230 },
231 };
232
233 if (!coverage) {
234 return coverageSummary;
235 }
236
237 for (let i = 0; i < coverage.length; ++i) {
238 const { functions, url } = coverage[i];
239
240 let totalBranches = 0;
241 let totalFunctions = 0;
242 let branchesCovered = 0;
243 let functionsCovered = 0;
244 const functionReports = [];
245 const branchReports = [];
246
247 const lines = this.getLines(url);
248 if (!lines) {
249 continue;
250 }
251
252
253 for (let j = 0; j < functions.length; ++j) {
254 const { isBlockCoverage, ranges } = functions[j];
255
256 let maxCountPerFunction = 0;
257 for (let k = 0; k < ranges.length; ++k) {
258 const range = ranges[k];
259 maxCountPerFunction = MathMax(maxCountPerFunction, range.count);
260
261 // Add some useful data to the range. The test runner has read these ranges
262 // from a file, so we own the data structures and can do what we want.
263 ObjectAssign(range, mapRangeToLines(range, lines));

Callers 2

postRunMethod · 0.45
collectCoverageFunction · 0.45

Calls 7

getLinesMethod · 0.95
ObjectAssignFunction · 0.85
mapRangeToLinesFunction · 0.85
fileURLToPathFunction · 0.85
toPercentageFunction · 0.85
sortMethod · 0.80

Tested by

no test coverage detected