bun test coverage

Bun has built-in code coverage reporting without additional dependencies.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "bun test coverage" with this command: npx skills add secondsky/claude-skills/secondsky-claude-skills-bun-test-coverage

Bun Test Coverage

Bun has built-in code coverage reporting without additional dependencies.

Enabling Coverage

Enable coverage

bun test --coverage

With threshold (fail if below)

bun test --coverage --coverage-threshold 80

Configuration in bunfig.toml

[test] coverage = true coverageThreshold = 0.8 # 80% minimum coverageDir = "./coverage"

Patterns to ignore

coverageSkipTestFiles = true

Coverage Output

------------------|---------|---------|-------------------

File% Funcs% LinesUncovered Line #s
All files85.7189.23
src/index.ts100.00100.00
src/utils.ts75.0082.3523-25, 41-43
src/api.ts80.0085.0067, 89-92
-------------------------------------------------------

Coverage Reporters

Default console output

bun test --coverage

Generate lcov report

bun test --coverage --coverage-reporter=lcov

Multiple reporters

bun test --coverage --coverage-reporter=text --coverage-reporter=lcov

Available Reporters

Reporter Output

text

Console table (default)

lcov

coverage/lcov.info for CI tools

json

coverage/coverage.json

Coverage Thresholds

Set minimum coverage requirements:

Fail if coverage < 80%

bun test --coverage --coverage-threshold 80

Per-metric thresholds in bunfig.toml

[test] coverage = true coverageThreshold = { lines = 80, functions = 75, branches = 70 }

Excluding Files

[test] coverage = true

Skip test files from coverage

coverageSkipTestFiles = true

Patterns to exclude

coverageIgnore = [ "/*.test.ts", "/fixtures/", "/mocks/**" ]

CI Integration

GitHub Actions

  • name: Run tests with coverage run: bun test --coverage --coverage-reporter=lcov

  • name: Upload coverage to Codecov uses: codecov/codecov-action@v5 with: files: ./coverage/lcov.info

Output Directory

Custom output directory

bun test --coverage --coverage-dir=./reports/coverage

Programmatic Coverage

import { test, expect } from "bun:test";

// Get coverage data programmatically const coverage = Bun.coverage;

// Access after tests complete process.on("exit", () => { console.log(coverage.getCoverageData()); });

Common Errors

Error Cause Fix

Coverage threshold not met

Coverage below threshold Increase test coverage

No coverage data

Files not executed Check test includes file

lcov not found

Missing reporter Add --coverage-reporter=lcov

Best Practices

  • Set realistic thresholds - Start at 60%, increase gradually

  • Exclude generated files - Mock files, type definitions

  • Focus on critical paths - Business logic over boilerplate

  • Run in CI - Prevent coverage regression

When to Load References

Load references/reporters.md when:

  • Custom reporter configuration

  • CI/CD integration details

  • Codecov/Coveralls setup

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

code-review

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

claude-code-bash-patterns

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

chrome-devtools

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

workers-dev-experience

No summary provided by upstream source.

Repository SourceNeeds Review