connor4312 / istanbul-to-vscode

Converts Istanbul coverage output to VS Code's coverage API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

istanbul-to-vscode

A utility library that converts Istanbul coverage reports to the format expected by VS Code's test coverage API.

Usage

In simple cases, you can just read the Istanbul report and create the coverage provider that we export:

import { IstanbulCoverageContext } from 'istanbul-to-vscode';

export const coverageContext = new IstanbulCoverageContext();

function activate() {
  // ...

  testRunProfile.loadDetailedCoverage = coverageContext.loadDetailedCoverage;
}

async function runTests() {
  // ...

  await coverageContext.apply(testRun, coverageDir);
}

But often you may want to apply sourcemap mappings. To do that, you can provide additional options either in apply() or when creating the CoverageContext:

async function runTests() {
  // ...

  await coverageContext.apply(task, coverageDir, {
    mapFileUri: (uri) => sourceMapStore.mapUri(uri),
    mapPosition: (uri, position) => sourceMapStore.mapLocation(uri, position),
  });
}

About

Converts Istanbul coverage output to VS Code's coverage API

License:MIT License


Languages

Language:TypeScript 97.0%Language:JavaScript 3.0%