SupercovDocumentation

Documentation

JavaScript and TypeScript test coverage

Set up Supercov with your agent, or run it yourself with Vitest, Jest, node:test or Playwright.

JavaScript

Ask your coding agent to set up Supercov in your project:

Set up Supercov in this JavaScript or TypeScript project using npx supercov.
Read npx supercov docs and run our existing tests. Follow
npx supercov docs assertion-agent to build and validate the assertion map.
Show the coverage report and any measurement limits. Don't change
application code or tests.

Run it yourself

You’ll need Node.js 22 or newer and your project’s test dependencies. For browser tests, start any services your suite needs.

Run Supercov through npx; no global install is needed:

npx supercov --version

Run your tests

Put Supercov before the command you normally run:

npx supercov -- npm test

If you invoke the runner directly, use the matching command instead:

npx supercov -- npx vitest run
npx supercov -- npx jest
npx supercov -- npx playwright test

This works with JavaScript, JSX, TypeScript and TSX, including React and Next.js. Keep your runner and build configuration. Supercov measures an isolated copy and builds it if your tests use compiled output.

Read the result and list a few gaps:

npx supercov runs latest
npx supercov runs latest gaps --limit 5

With Vitest, Jest, node:test and Playwright, Supercov can identify which test ran each piece of code. Mocha and AVA report coverage for the suite as a whole. See runner support for browser and custom-assertion limits.

Try a small example

Download the examples, extract them, and open supercov-examples/javascript. This JavaScript example uses node:test and needs no extra test dependencies.

In src/session.js, checkout requires a signed-in customer and a session that hasn’t expired:

export function checkout(signedIn, expired, price, quantity) {
  if (signedIn && !expired) {
    const total = price * quantity;
    return { status: 'confirmed', total };
  }
  return { status: 'denied', total: 0 };
}

The two tests check a valid order and a signed-out visitor. Run them:

npx supercov -- npm test
npx supercov runs latest

The coverage section recorded with Supercov 0.0.48 is:

Coverage
  Lines      100.00% (5/5)
  Branches   100.00% (2/2)
  MC/DC      50.00% (1/2)

Both branches ran, but no test checks an expired session for a signed-in customer. Inspect that decision:

npx supercov runs latest decision src/session.js:2

The report includes:

signedIn && !expired
C1 covered: signedIn
C2 MISSING: !expired

A test for a signed-in customer with an expired session closes the gap. In the recorded run, MC/DC reaches 100%; line and branch coverage stay the same. See MC/DC for how it works.

Check what the tests assert

These tests check the returned status, but not the total. An assertion such as assert.equal(order.total, 50) would check the calculation for this input.

The setup prompt asks your agent to map each assertion to the code it checks. Supercov checks that map against the recorded test run. Running tests alone doesn’t establish assertion coverage. See Assertion coverage for how to read the result.

Already using Vitest coverage? See how the reports differ. npx supercov docs coverage-model prints the guide for your installed version.