AGENT SKILL

bun-test-coverage

Use for test coverage with Bun, --coverage flag, lcov reports, thresholds, and CI integration.

License 许可
MIT
最近更新
2026-09-24
Stars
★ 0
Forks
0

01 前言 Front Matter

name
bun-test-coverage
license
MIT
metadata
{ "version": "1.0.0" }
description
Use for test coverage with Bun, --coverage flag, lcov reports, thresholds, and CI integration.

03 SKILL.md 正文

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 | % Lines | Uncovered Line #s
------------------|---------|---------|-------------------
All files         |   85.71 |   89.23 |
 src/index.ts     |  100.00 |  100.00 |
 src/utils.ts     |   75.00 |   82.35 | 23-25, 41-43
 src/api.ts       |   80.00 |   85.00 | 67, 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

  1. Set realistic thresholds - Start at 60%, increase gradually
  2. Exclude generated files - Mock files, type definitions
  3. Focus on critical paths - Business logic over boilerplate
  4. 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

04 同仓库更多 Skills

aibizmod
aibizmod/aibizmod-service-web

{TODO=lowercase-hyphen-case-name}

[TODO: Write comprehensive description in third-person. Start with "This skill provides..." or "This skill should be used when..."] [TODO: Add "Use when" scenarios - specific situations where Claude should use this skill] [TODO: Add keywords - technologies, use cases, error messages that should trigger this skill]

★ 0
aibizmod
aibizmod/aibizmod-service-web

zustand-state-management

Zustand state management for React with TypeScript. Use for global state, Redux/Context API migration, localStorage persistence, slices pattern, devtools, Next.js SSR, or encountering hydration errors, TypeScript inference issues, persist middleware problems, infinite render loops.

★ 0
aibizmod
aibizmod/aibizmod-service-web

zod

TypeScript-first schema validation and type inference. Use for validating API requests/responses, form data, env vars, configs, defining type-safe schemas with runtime validation, transforming data, generating JSON Schema for OpenAPI/AI, or encountering missing validation errors, type inference issues, validation error handling problems. Zero dependencies (2kb gzipped).

★ 0
aibizmod
aibizmod/aibizmod-service-web

xss-prevention

XSS attack prevention with input sanitization, output encoding, Content Security Policy. Use for user-generated content, rich text editors, web application security, or encountering stored XSS, reflected XSS, DOM manipulation, script injection errors.

★ 0
aibizmod
aibizmod/aibizmod-service-web

wordpress-plugin-core

WordPress plugin development with hooks, security, REST API, custom post types. Use for plugin creation, $wpdb queries, Settings API, or encountering SQL injection, XSS, CSRF, nonce errors.

★ 0
aibizmod
aibizmod/aibizmod-service-web

woocommerce-dev-cycle

Run tests, linting, and quality checks for WooCommerce development. Use when running tests, fixing code style, or following the development workflow in WooCommerce projects.

★ 0