npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@glideapps/vitest-v8-json-coverage-summary

v0.0.0-quebec

Published

A plugin for vitest that generates a coverage summary in json format

Readme

Vitest V8 JSON Coverage Summary

A plugin for Vitest that generates a structured JSON coverage summary from V8 coverage data. This reporter creates a coverage-summary.json file with detailed coverage information for statements, branches, functions, and lines.

Features

  • ✅ Generates structured JSON coverage summary
  • ✅ Supports V8 coverage provider
  • ✅ Includes file-level and overall coverage statistics
  • ✅ Tracks uncovered lines for detailed analysis
  • ✅ Compatible with Vitest 3.0+
  • 🚀 NEW: GitHub Action for automatic PR coverage reporting

Installation

npm install --save-dev vitest-v8-json-coverage-summary

GitHub Action

This package also includes a GitHub Action that automatically creates beautiful coverage reports in pull requests.

Quick Start

name: Coverage Report
on:
  pull_request:
    branches: [main]

permissions:
  pull-requests: write

jobs:
  coverage:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: "20"
      - run: npm ci
      - run: npm test
      - uses: glideapps/vitest-v8-json-coverage-summary@v1

For detailed documentation, see ACTION_README.md.

Usage

Basic Setup

Add the reporter to your Vitest configuration:

// vitest.config.js
import { defineConfig } from "vitest/config";
import V8JSONSummaryReporter from "vitest-v8-json-coverage-summary";

export default defineConfig({
  test: {
    coverage: {
      provider: "v8",
      reporter: ["text", "json"],
      reportsDirectory: "./coverage",
    },
    reporters: ["default", new V8JSONSummaryReporter()],
  },
});

TypeScript Configuration

// vitest.config.ts
import { defineConfig } from "vitest/config";
import V8JSONSummaryReporter from "vitest-v8-json-coverage-summary";

export default defineConfig({
  test: {
    coverage: {
      provider: "v8",
      reporter: ["text", "json"],
      reportsDirectory: "./coverage",
    },
    reporters: ["default", new V8JSONSummaryReporter()],
  },
});

Output Format

The reporter generates a coverage-summary.json file in your coverage directory with the following structure:

{
  "summary": {
    "statements": 85.5,
    "branches": 72.3,
    "functions": 90.1,
    "lines": 85.5
  },
  "files": [
    {
      "file": "src/example.js",
      "statements": 95.2,
      "branches": 80.0,
      "functions": 100.0,
      "lines": 95.2,
      "uncoveredLines": [15, 23, 45]
    }
  ]
}

Coverage Metrics

  • statements: Percentage of statements covered
  • branches: Percentage of branch paths covered
  • functions: Percentage of functions covered
  • lines: Percentage of lines covered (matches statements for V8)
  • uncoveredLines: Array of line numbers that are not covered (optional)

API Reference

V8JSONSummaryReporter

The main reporter class that implements Vitest's Reporter interface.

Methods

  • onInit(vitest: Vitest): Called when the reporter is initialized
  • onCoverage(coverage: any): Called when coverage data is available
  • onTestRunEnd(): Called when the test run ends (kept for compatibility)

generateV8CoverageSummary(coverage: any): CoverageSummary

Utility function that processes V8 coverage data and returns a structured summary.

Configuration Options

The reporter uses the coverage configuration from your Vitest config:

  • coverage.reportsDirectory: Directory where the summary file will be written (default: ./coverage)
  • coverage.provider: Must be set to 'v8' for this reporter to work

Example Output

After running your tests with coverage, you'll find a coverage-summary.json file that looks like this:

{
  "summary": {
    "statements": 87.5,
    "branches": 75.0,
    "functions": 92.3,
    "lines": 87.5
  },
  "files": [
    {
      "file": "src/utils.js",
      "statements": 100.0,
      "branches": 100.0,
      "functions": 100.0,
      "lines": 100.0
    },
    {
      "file": "src/main.js",
      "statements": 75.0,
      "branches": 50.0,
      "functions": 85.7,
      "lines": 75.0,
      "uncoveredLines": [12, 15, 23]
    }
  ]
}

Integration Examples

With CI/CD

# GitHub Actions example
- name: Run tests with coverage
  run: npm test

- name: Upload coverage summary
  uses: actions/upload-artifact@v3
  with:
    name: coverage-summary
    path: coverage/coverage-summary.json

With Coverage Badges

You can use the generated JSON to create coverage badges or integrate with coverage reporting services.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Changelog

1.0.0

  • Initial release
  • V8 coverage support
  • JSON summary generation
  • File-level and overall coverage statistics