Source maps support for Istanbul code coverage toolkit, enabling accurate coverage reporting for transpiled JavaScript code
Overall
score
98%
Build a tool that processes JavaScript code coverage data and provides detailed diagnostic information about source map issues. The tool should help developers understand why coverage mapping might be failing for their transpiled code.
Your tool should:
Create a file src/debugger.js that exports a CoverageDebugger class with the following interface:
class CoverageDebugger {
constructor(options)
registerSourceMap(filePath, sourceMapUrlOrObject)
analyzeCoverage(coverageMap)
getReport()
}The constructor should accept an options object with:
verbose: boolean flag for detailed logging (defaults to false)The registerSourceMap method should:
The analyzeCoverage method should:
The getReport method should return a detailed report object containing:
registered: array of successfully registered source mapsfailed: array of failed registrations with error detailsunmapped: array of files with coverage but no source mapsstats: object with numerical summariesCreate tests in src/debugger.test.js:
Input:
const debugger = new CoverageDebugger({ verbose: false })
debugger.registerSourceMap('/path/to/bundle.js', {
version: 3,
sources: ['original.js'],
mappings: 'AAAA'
})Expected Output:
The report should show 1 successfully registered source map for /path/to/bundle.js
Input:
const debugger = new CoverageDebugger({ verbose: false })
debugger.registerSourceMap('/path/to/file.js', { invalid: 'data' })Expected Output: The report should show 1 failed registration with an error indicating invalid source map format
Input:
const debugger = new CoverageDebugger({ verbose: false })
const coverageMap = {
'/app/bundle.js': {
path: '/app/bundle.js',
statementMap: { '0': { start: { line: 1, column: 0 }, end: { line: 1, column: 10 } } },
s: { '0': 1 }
}
}
debugger.analyzeCoverage(coverageMap)Expected Output:
The report should show /app/bundle.js in the unmapped files list
Input:
const debugger = new CoverageDebugger({ verbose: false })
debugger.registerSourceMap('/path/to/file.js', 'data:invalid-format')
debugger.registerSourceMap('/path/to/file2.js', null)Expected Output: No exceptions should be thrown; both failures should be logged in the failed registrations list
Provides source map support for Istanbul code coverage, including source map registration, validation, and diagnostic capabilities.
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