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

Coverage Data Enrichment Tool

Build a utility that enriches Istanbul coverage data with source map information before transformation.

Requirements

You need to implement a tool that:

  1. Accepts a coverage data object (in Istanbul's standard format) and a directory path containing source map files
  2. Loads all available source maps from the given directory (.map files)
  3. Registers each source map with a map store
  4. Enriches the coverage data by adding source map references to each file's coverage entry
  5. Returns the enriched coverage data

The tool should handle:

  • Multiple coverage entries (one per file)
  • Source maps that may or may not exist for each covered file
  • Only add source maps when a matching .map file is found

Input Format

Coverage data follows Istanbul's format with file paths as keys and coverage objects as values:

{
  "/path/to/compiled.js": {
    path: "/path/to/compiled.js",
    statementMap: { ... },
    fnMap: { ... },
    branchMap: { ... },
    s: { ... },
    f: { ... },
    b: { ... }
  }
}

Output Format

The same coverage data structure, but with inputSourceMap properties added where source maps were found.

Test Cases

  • Given coverage data for three files where two have matching .map files in the source maps directory, the tool correctly adds source maps to those two entries and leaves the third unchanged. @test
  • Given an empty coverage data object, the tool returns an empty object without errors. @test
  • Given coverage data when no source map files exist in the directory, the tool returns the coverage data unchanged. @test

Implementation

@generates

API

/**
 * Enriches coverage data with source map information.
 *
 * @param {Object} coverageData - Istanbul coverage data object with file paths as keys
 * @param {string} sourceMapsDir - Directory path containing .map files
 * @returns {Object} The enriched coverage data with inputSourceMap properties added
 */
function enrichCoverageWithSourceMaps(coverageData, sourceMapsDir) {
  // Implementation here
}

module.exports = { enrichCoverageWithSourceMaps };

Dependencies { .dependencies }

istanbul-lib-source-maps { .dependency }

Provides source map storage and registration capabilities for Istanbul coverage data.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-istanbul-lib-source-maps

tile.json