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

Coverage Reporter with Source Map Support

Build a simple code coverage reporter that handles transpiled JavaScript files using source maps to report coverage on the original source code.

Requirements

Your task is to implement a coverage reporting utility that:

  1. Initializes a source map store to manage source map data for coverage transformation
  2. Registers source maps for transpiled files that will be analyzed
  3. Transforms coverage data from transpiled code back to original source locations
  4. Reports the results showing which original source files have coverage and their coverage statistics

Input Format

Your implementation should accept:

  • A coverage data object representing statement, function, and branch coverage for transpiled files
  • Source map information (either as file paths or inline data) for each transpiled file

Output Format

Return a summary object containing:

  • The number of original source files covered
  • A list of original source file paths that have coverage data
  • Whether the transformation was successful

Implementation Details

Create a module that exports a function generateCoverageReport(coverageData, sourceMaps) that:

  1. Sets up the necessary infrastructure for source map handling
  2. Associates each transpiled file with its source map
  3. Transforms the coverage data to reference original source files
  4. Returns a summary of the transformation results

The function should handle cases where source maps might not be available for some files (skip those files gracefully).

Test Cases

  • Given coverage data for a single transpiled file with a registered source map, it returns a summary showing the original source file @test
  • Given coverage data for multiple transpiled files with their source maps, it returns a summary with all original source files @test
  • Given coverage data for files without source maps, it returns a summary excluding those files @test
  • Given an empty coverage object, it returns a summary with zero files covered @test

@generates

API

/**
 * Generate a coverage report by transforming transpiled coverage data back to original sources
 * @param {Object} coverageData - Coverage data object for transpiled files
 * @param {Object} sourceMaps - Map of file paths to source map URLs or objects
 * @returns {Promise<Object>} Summary object with originalFileCount, originalFiles array, and success boolean
 */
async function generateCoverageReport(coverageData, sourceMaps) {
  // Implementation here
}

module.exports = { generateCoverageReport };

Dependencies { .dependencies }

istanbul-lib-source-maps { .dependency }

Provides source map support for transforming coverage data from transpiled code to original source locations.

@satisfied-by

istanbul-lib-coverage { .dependency }

Provides coverage data structures and utilities for working with code coverage information.

@satisfied-by

Install with Tessl CLI

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

tile.json