CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-istanbul-lib-source-maps

Source maps support for Istanbul code coverage toolkit, enabling accurate coverage reporting for transpiled JavaScript code

Overall
score

98%

Overview
Eval results
Files

task.mdevals/scenario-4/

Coverage Accumulator

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.

Requirements

When running multiple test suites or collecting coverage from different sources, you may encounter duplicate coverage entries for the same location. Your tool must:

  1. Accept an array of coverage entries (statements, functions, branches) for a source file
  2. Build a deduplicated coverage object where duplicate locations are merged
  3. Accumulate hit counts from all entries that share the same location

Coverage Data Structure

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.

Test Cases

  • Given multiple statement entries at location (1,0)-(1,10), accumulate returns one entry with summed hits @test
  • Given multiple function entries with same declaration and body location, accumulate returns one with summed hits @test
  • Given multiple branch entries at the same location, accumulate returns one with summed hit arrays @test

Implementation

@generates

API

/**
 * 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 };

Dependencies { .dependencies }

istanbul-lib-source-maps { .dependency }

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-maps

tile.json