Source maps support for Istanbul code coverage toolkit, enabling accurate coverage reporting for transpiled JavaScript code
Overall
score
98%
Build a utility that accumulates coverage data from multiple test runs of source-mapped code, handling duplicate coverage entries at the same location by merging them and summing their hit counts.
When running multiple test suites or collecting coverage from different sources, you may encounter duplicate coverage entries for the same location. Your tool must:
Coverage data consists of entries for statements, functions, and branches:
Statement: { start: {line, column}, end: {line, column}, hits: number }
Function: { name: string, decl: {start, end}, loc: {start, end}, hits: number }
Branch: { type: string, loc: {start, end}, locations: [{start, end}], hits: [number] }
Locations use line and column numbers where start is inclusive and end is exclusive.
@generates
/**
* Accumulates coverage entries with deduplication and hit count summation.
*
* @param {string} filePath - Source file path
* @param {Array} statements - Statement entries: [{loc: {start, end}, hits}]
* @param {Array} functions - Function entries: [{name, decl, loc, hits}]
* @param {Array} branches - Branch entries: [{type, loc, locations, hits}]
* @returns {Object} Coverage object with statementMap, fnMap, branchMap, s, f, b
*/
function accumulateCoverage(filePath, statements, functions, branches) {
// IMPLEMENTATION HERE
}
module.exports = { accumulateCoverage };Provides coverage transformation and accumulation support for handling source-mapped code coverage.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-istanbul-lib-source-mapsdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10