()
| 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)); |
no test coverage detected