{"id":28892911,"url":"https://github.com/glideapps/vitest-v8-json-coverage-summary","last_synced_at":"2026-02-02T16:39:43.383Z","repository":{"id":299766607,"uuid":"1004115264","full_name":"glideapps/vitest-v8-json-coverage-summary","owner":"glideapps","description":"A vitest plugin that generates a JSON file with structured summary output","archived":false,"fork":false,"pushed_at":"2025-06-18T06:46:26.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-18T07:31:18.965Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/glideapps.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-18T06:25:21.000Z","updated_at":"2025-06-18T06:46:29.000Z","dependencies_parsed_at":"2025-06-18T07:42:31.849Z","dependency_job_id":null,"html_url":"https://github.com/glideapps/vitest-v8-json-coverage-summary","commit_stats":null,"previous_names":["glideapps/vitest-v8-json-coverage-summary"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/glideapps/vitest-v8-json-coverage-summary","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glideapps%2Fvitest-v8-json-coverage-summary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glideapps%2Fvitest-v8-json-coverage-summary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glideapps%2Fvitest-v8-json-coverage-summary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glideapps%2Fvitest-v8-json-coverage-summary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/glideapps","download_url":"https://codeload.github.com/glideapps/vitest-v8-json-coverage-summary/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glideapps%2Fvitest-v8-json-coverage-summary/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261050701,"owners_count":23102557,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-21T02:07:10.621Z","updated_at":"2026-02-02T16:39:43.376Z","avatar_url":"https://github.com/glideapps.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vitest V8 JSON Coverage Summary\n\nA plugin for [Vitest](https://vitest.dev/) that generates a structured JSON coverage summary from V8 coverage data. This package also includes GitHub Actions for coverage reporting and badge management.\n\n## Features\n\n- ✅ Generates structured JSON coverage summary\n- ✅ Supports V8 coverage provider\n- ✅ Includes file-level and overall coverage statistics\n- ✅ Tracks uncovered lines for detailed analysis\n- ✅ Compatible with Vitest 3.0+\n- 🚀 **GitHub Actions**: Coverage reporting, badge generation, and badge upload\n- 🏷️ **Coverage Badges**: Shields.io compatible badges\n- 🔧 **Modular Design**: Separate actions for different use cases\n\n## Installation\n\n```bash\nnpm install --save-dev vitest-v8-json-coverage-summary\n```\n\n## GitHub Actions\n\nThis package includes three separate GitHub Actions that can be used independently:\n\n### 1. Coverage Reporter\n\nCreates beautiful coverage reports in pull requests.\n\n```yaml\n- name: Report Coverage\n  uses: glideapps/vitest-v8-json-coverage-summary/actions/coverage-reporter@v0.0.0-echo\n  with:\n    coverage-file: \"coverage/coverage-summary.json\"\n    title: \"🧪 Test Coverage Report\"\n    show-files: \"true\"\n    coverage-threshold: \"80\"\n```\n\n### 2. Badge Generator\n\nGenerates coverage badges from coverage data.\n\n```yaml\n- name: Generate Badges\n  uses: glideapps/vitest-v8-json-coverage-summary/actions/badge-generator@v0.0.0-echo\n  with:\n    coverage-file: \"coverage/coverage-summary.json\"\n    badges-dir: \"badges\"\n```\n\n### 3. Badge Uploader\n\nUploads badges to GitHub Pages.\n\n```yaml\n- name: Upload Badges to GitHub Pages\n  uses: glideapps/vitest-v8-json-coverage-summary/actions/badge-uploader@v0.0.0-echo\n  with:\n    coverage-file: \"coverage/coverage-summary.json\"\n    badges-dir: \"badges\"\n    pages-branch: \"gh-pages\"\n    generate-badges: \"true\"\n```\n\n## Quick Start\n\n### Basic Coverage Reporting\n\n```yaml\nname: Coverage Report\non:\n  pull_request:\n    branches: [main]\n\npermissions:\n  pull-requests: write\n\njobs:\n  coverage:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      - uses: actions/setup-node@v4\n        with:\n          node-version: \"20\"\n      - run: npm ci\n      - run: npm test\n      - uses: glideapps/vitest-v8-json-coverage-summary/actions/coverage-reporter@v0.0.0-echo\n        with:\n          coverage-file: \"coverage/coverage-summary.json\"\n```\n\n### Full Workflow with Badges\n\n```yaml\nname: Coverage with Badges\non:\n  pull_request:\n    branches: [main]\n  push:\n    branches: [main]\n\npermissions:\n  pull-requests: write\n  contents: write\n\njobs:\n  coverage:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      - uses: actions/setup-node@v4\n        with:\n          node-version: \"20\"\n      - run: npm ci\n      - run: npm test\n      - uses: glideapps/vitest-v8-json-coverage-summary/actions/coverage-reporter@v0.0.0-echo\n\n  badges:\n    if: github.ref == 'refs/heads/main'\n    runs-on: ubuntu-latest\n    needs: coverage\n    steps:\n      - uses: actions/checkout@v4\n        with:\n          fetch-depth: 0\n      - uses: actions/setup-node@v4\n        with:\n          node-version: \"20\"\n      - run: npm ci\n      - run: npm test\n      - uses: glideapps/vitest-v8-json-coverage-summary/actions/badge-uploader@v0.0.0-echo\n        with:\n          generate-badges: \"true\"\n```\n\n## Action Reference\n\n### Coverage Reporter\n\n| Input                | Description                                             | Required | Default                          |\n| -------------------- | ------------------------------------------------------- | -------- | -------------------------------- |\n| `coverage-file`      | Path to the coverage summary JSON file                  | No       | `coverage/coverage-summary.json` |\n| `token`              | GitHub token for creating comments                      | No       | `${{ github.token }}`            |\n| `title`              | Title for the coverage report comment                   | No       | `📊 Coverage Report`             |\n| `show-files`         | Whether to show individual file coverage details        | No       | `true`                           |\n| `coverage-threshold` | Minimum coverage percentage to consider as good (0-100) | No       | `80`                             |\n\n### Badge Generator\n\n| Input           | Description                              | Required | Default                          |\n| --------------- | ---------------------------------------- | -------- | -------------------------------- |\n| `coverage-file` | Path to the coverage summary JSON file   | No       | `coverage/coverage-summary.json` |\n| `badges-dir`    | Directory to output the generated badges | No       | `badges`                         |\n\n### Badge Uploader\n\n| Input              | Description                                       | Required | Default                            |\n| ------------------ | ------------------------------------------------- | -------- | ---------------------------------- |\n| `coverage-file`    | Path to the coverage summary JSON file            | No       | `coverage/coverage-summary.json`   |\n| `badges-dir`       | Directory containing the badges to upload         | No       | `badges`                           |\n| `pages-branch`     | Branch to upload badges to for GitHub Pages       | No       | `gh-pages`                         |\n| `pages-badges-dir` | Directory within the pages branch to store badges | No       | `badges`                           |\n| `commit-message`   | Commit message for badge updates                  | No       | `Update coverage badges [skip ci]` |\n| `generate-badges`  | Whether to generate badges if they don't exist    | No       | `true`                             |\n\n## Badge URLs\n\nWhen GitHub Pages is enabled, badges are available at:\n\n```\nhttps://yourusername.github.io/yourrepo/badges/coverage.json\nhttps://yourusername.github.io/yourrepo/badges/statements.json\nhttps://yourusername.github.io/yourrepo/badges/branches.json\nhttps://yourusername.github.io/yourrepo/badges/functions.json\nhttps://yourusername.github.io/yourrepo/badges/lines.json\n```\n\nUse in your README.md:\n\n```markdown\n![Coverage](https://yourusername.github.io/yourrepo/badges/coverage.json)\n```\n\n## Examples\n\nSee the `examples/` directory for complete workflow examples:\n\n- `coverage-only.yml` - Only coverage reporting\n- `badge-generator-only.yml` - Only badge generation\n- `badge-uploader-only.yml` - Only badge upload\n- `full-workflow.yml` - Complete workflow with all actions\n\n## Setup\n\n### Configure Vitest\n\n```javascript\n// vitest.config.js\nexport default {\n  coverage: {\n    provider: \"v8\",\n    reporter: [\"json-summary\"],\n    reportsDirectory: \"coverage\",\n  },\n};\n```\n\n### Enable GitHub Pages\n\n1. Go to Settings → Pages\n2. Set source to \"Deploy from a branch\"\n3. Select `gh-pages` branch\n4. Set folder to `/ (root)` or `/badges`\n\n## Usage\n\n### Basic Setup\n\nAdd the reporter to your Vitest configuration:\n\n```javascript\n// vitest.config.js\nimport { defineConfig } from \"vitest/config\";\nimport V8JSONSummaryReporter from \"vitest-v8-json-coverage-summary\";\n\nexport default defineConfig({\n  test: {\n    coverage: {\n      provider: \"v8\",\n      reporter: [\"text\", \"json\"],\n      reportsDirectory: \"./coverage\",\n    },\n    reporters: [\"default\", new V8JSONSummaryReporter()],\n  },\n});\n```\n\n## Output Format\n\nThe reporter generates a `coverage-summary.json` file in your coverage directory with the following structure:\n\n```json\n{\n  \"summary\": {\n    \"statements\": 85.5,\n    \"branches\": 72.3,\n    \"functions\": 90.1,\n    \"lines\": 85.5\n  },\n  \"files\": [\n    {\n      \"file\": \"src/example.js\",\n      \"statements\": 95.2,\n      \"branches\": 80.0,\n      \"functions\": 100.0,\n      \"lines\": 95.2,\n      \"uncoveredLines\": [15, 23, 45]\n    }\n  ]\n}\n```\n\n### Coverage Metrics\n\n- **statements**: Percentage of statements covered\n- **branches**: Percentage of branch paths covered\n- **functions**: Percentage of functions covered\n- **lines**: Percentage of lines covered (matches statements for V8)\n- **uncoveredLines**: Array of line numbers that are not covered (optional)\n\n## API Reference\n\n### V8JSONSummaryReporter\n\nThe main reporter class that implements Vitest's Reporter interface.\n\n#### Methods\n\n- `onInit(vitest: Vitest)`: Called when the reporter is initialized\n- `onCoverage(coverage: any)`: Called when coverage data is available\n- `onTestRunEnd()`: Called when the test run ends (kept for compatibility)\n\n### generateV8CoverageSummary(coverage: any): CoverageSummary\n\nUtility function that processes V8 coverage data and returns a structured summary.\n\n## Configuration Options\n\nThe reporter uses the coverage configuration from your Vitest config:\n\n- `coverage.reportsDirectory`: Directory where the summary file will be written (default: `./coverage`)\n- `coverage.provider`: Must be set to `'v8'` for this reporter to work\n\n## Example Output\n\nAfter running your tests with coverage, you'll find a `coverage-summary.json` file that looks like this:\n\n```json\n{\n  \"summary\": {\n    \"statements\": 87.5,\n    \"branches\": 75.0,\n    \"functions\": 92.3,\n    \"lines\": 87.5\n  },\n  \"files\": [\n    {\n      \"file\": \"src/utils.js\",\n      \"statements\": 100.0,\n      \"branches\": 100.0,\n      \"functions\": 100.0,\n      \"lines\": 100.0\n    },\n    {\n      \"file\": \"src/main.js\",\n      \"statements\": 75.0,\n      \"branches\": 50.0,\n      \"functions\": 85.7,\n      \"lines\": 75.0,\n      \"uncoveredLines\": [12, 15, 23]\n    }\n  ]\n}\n```\n\n## Integration Examples\n\n### With CI/CD\n\n```yaml\n# GitHub Actions example\n- name: Run tests with coverage\n  run: npm test\n\n- name: Upload coverage summary\n  uses: actions/upload-artifact@v3\n  with:\n    name: coverage-summary\n    path: coverage/coverage-summary.json\n```\n\n### With Coverage Badges\n\nYou can use the generated JSON to create coverage badges or integrate with coverage reporting services.\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Add tests if applicable\n5. Submit a pull request\n\n## License\n\nMIT License - see [LICENSE](LICENSE) file for details.\n\n## Changelog\n\n### 1.0.0\n\n- Initial release\n- V8 coverage support\n- JSON summary generation\n- File-level and overall coverage statistics\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglideapps%2Fvitest-v8-json-coverage-summary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglideapps%2Fvitest-v8-json-coverage-summary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglideapps%2Fvitest-v8-json-coverage-summary/lists"}