
Product
Introducing GitHub Actions Scanning Support
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.
@glideapps/vitest-v8-json-coverage-summary
Advanced tools
A plugin for vitest that generates a coverage summary in json format
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.
npm install --save-dev vitest-v8-json-coverage-summary
This package also includes a GitHub Action that automatically creates beautiful coverage reports in pull requests.
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.
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()],
},
});
// 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()],
},
});
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]
}
]
}
The main reporter class that implements Vitest's Reporter interface.
onInit(vitest: Vitest): Called when the reporter is initializedonCoverage(coverage: any): Called when coverage data is availableonTestRunEnd(): Called when the test run ends (kept for compatibility)Utility function that processes V8 coverage data and returns a structured summary.
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 workAfter 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]
}
]
}
# 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
You can use the generated JSON to create coverage badges or integrate with coverage reporting services.
MIT License - see LICENSE file for details.
FAQs
A plugin for vitest that generates a coverage summary in json format
We found that @glideapps/vitest-v8-json-coverage-summary demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 31 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.

Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.

Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.