configure-coverage
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese/configure:coverage
/configure:coverage
Check and configure code coverage thresholds and reporting for test frameworks.
为测试框架检查并配置代码覆盖率阈值与报告。
When to Use This Skill
适用场景
| Use this skill when... | Use another approach when... |
|---|---|
| Setting up coverage thresholds for Vitest, Jest, pytest, or Rust | Running tests with coverage ( |
| Configuring coverage reporters (text, JSON, HTML, lcov) | Configuring the test framework itself ( |
| Adding Codecov or Coveralls integration to CI/CD | Analyzing test failures (test-runner agent) |
| Auditing coverage configuration compliance across a project | Writing individual test cases |
| Adjusting coverage threshold percentages | Configuring general CI/CD workflows ( |
| 适用此技能的场景... | 适用其他方法的场景... |
|---|---|
| 为Vitest、Jest、pytest或Rust设置覆盖率阈值 | 运行带覆盖率的测试( |
| 配置覆盖率报告器(text、JSON、HTML、lcov) | 配置测试框架本身( |
| 在CI/CD中添加Codecov或Coveralls集成 | 分析测试失败(test-runner agent) |
| 审计项目中覆盖率配置的合规性 | 编写单个测试用例 |
| 调整覆盖率阈值百分比 | 配置通用CI/CD工作流( |
Context
上下文信息
- Project root: !
pwd - Package files: !
find . -maxdepth 1 \( -name 'package.json' -o -name 'pyproject.toml' -o -name 'Cargo.toml' \) 2>/dev/null - Vitest config: !
find . -maxdepth 1 -name 'vitest.config.*' 2>/dev/null - Jest config: !
find . -maxdepth 1 -name 'jest.config.*' 2>/dev/null - Coverage dir: !
find . -maxdepth 1 -type d -name 'coverage' 2>/dev/null - Codecov config: !
find . -maxdepth 1 \( -name 'codecov.yml' -o -name '.codecov.yml' \) 2>/dev/null - Project standards: !
find . -maxdepth 1 -name '.project-standards.yaml' 2>/dev/null
- 项目根目录: !
pwd - 包文件: !
find . -maxdepth 1 \( -name 'package.json' -o -name 'pyproject.toml' -o -name 'Cargo.toml' \) 2>/dev/null - Vitest配置: !
find . -maxdepth 1 -name 'vitest.config.*' 2>/dev/null - Jest配置: !
find . -maxdepth 1 -name 'jest.config.*' 2>/dev/null - 覆盖率目录: !
find . -maxdepth 1 -type d -name 'coverage' 2>/dev/null - Codecov配置: !
find . -maxdepth 1 \( -name 'codecov.yml' -o -name '.codecov.yml' \) 2>/dev/null - 项目标准: !
find . -maxdepth 1 -name '.project-standards.yaml' 2>/dev/null
Parameters
参数
Parse from command arguments:
- : Report compliance status without modifications (CI/CD mode)
--check-only - : Apply fixes automatically without prompting
--fix - : Set coverage threshold (default: 80)
--threshold <percentage>
Default threshold: 80% (lines, branches, functions, statements)
Supported frameworks:
- Vitest: or
@vitest/coverage-v8@vitest/coverage-istanbul - Jest: Built-in coverage with
--coverage - pytest: plugin
pytest-cov - Rust: or
cargo-llvm-covcargo-tarpaulin
从命令参数中解析:
- : 仅报告合规状态,不进行修改(CI/CD模式)
--check-only - : 自动应用修复,无需提示
--fix - : 设置覆盖率阈值(默认值:80)
--threshold <percentage>
默认阈值: 80%(行、分支、函数、语句)
支持的框架:
- Vitest: 或
@vitest/coverage-v8@vitest/coverage-istanbul - Jest: 内置覆盖率功能,使用
--coverage - pytest: 插件
pytest-cov - Rust: 或
cargo-llvm-covcargo-tarpaulin
Execution
执行流程
Execute this code coverage compliance check:
执行以下代码覆盖率合规性检查:
Step 1: Detect test framework and coverage configuration
步骤1:检测测试框架与覆盖率配置
Check for framework indicators:
| Indicator | Framework | Coverage Tool |
|---|---|---|
| Vitest | @vitest/coverage-v8 |
| Jest | Built-in |
| pytest | pytest-cov |
| Rust | cargo-llvm-cov |
Use WebSearch or WebFetch to verify latest versions of coverage tools before configuring.
检查框架标识:
| 标识 | 框架 | 覆盖率工具 |
|---|---|---|
带覆盖率配置的 | Vitest | @vitest/coverage-v8 |
带覆盖率配置的 | Jest | 内置工具 |
| pytest | pytest-cov |
| Rust | cargo-llvm-cov |
在配置前,使用WebSearch或WebFetch验证覆盖率工具的最新版本。
Step 2: Analyze current coverage state
步骤2:分析当前覆盖率状态
For the detected framework, check configuration completeness:
Vitest:
- Coverage provider configured (or
v8)istanbul - Coverage reporters configured (,
text,json,html)lcov - Thresholds set for lines, functions, branches, statements
- Exclusions configured (node_modules, dist, tests, config files)
- Output directory specified
Jest:
- enabled
collectCoverage - set (
coverageProviderorv8)babel - patterns configured
collectCoverageFrom - configured
coverageThresholds - configured
coverageReporters
pytest:
- installed
pytest-cov - section exists
[tool.coverage.run] - section exists
[tool.coverage.report] - Coverage threshold configured ()
--cov-fail-under
Rust (cargo-llvm-cov):
- installed
cargo-llvm-cov - Coverage configuration in workspace
- HTML/LCOV output configured
针对检测到的框架,检查配置完整性:
Vitest:
- 已配置覆盖率提供方(或
v8)istanbul - 已配置覆盖率报告器(、
text、json、html)lcov - 已设置行、函数、分支、语句的阈值
- 已配置排除项(node_modules、dist、tests、配置文件)
- 已指定输出目录
Jest:
- 已启用
collectCoverage - 已设置(
coverageProvider或v8)babel - 已配置模式
collectCoverageFrom - 已配置
coverageThresholds - 已配置
coverageReporters
pytest:
- 已安装
pytest-cov - 存在章节
[tool.coverage.run] - 存在章节
[tool.coverage.report] - 已配置覆盖率阈值()
--cov-fail-under
Rust (cargo-llvm-cov):
- 已安装
cargo-llvm-cov - 工作区中存在覆盖率配置
- 已配置HTML/LCOV输出
Step 3: Generate compliance report
步骤3:生成合规性报告
Print a formatted compliance report:
Code Coverage Compliance Report
================================
Project: [name]
Framework: [Vitest 2.x | pytest 8.x | cargo-llvm-cov 0.6.x]
Coverage Configuration:
Provider @vitest/coverage-v8 [CONFIGURED | MISSING]
Reporters text, json, html, lcov [ALL | PARTIAL]
Output directory coverage/ [CONFIGURED | DEFAULT]
Exclusions node_modules, dist, tests [CONFIGURED | INCOMPLETE]
Thresholds:
Lines 80% [PASS | LOW | NOT SET]
Branches 80% [PASS | LOW | NOT SET]
Functions 80% [PASS | LOW | NOT SET]
Statements 80% [PASS | LOW | NOT SET]
CI/CD Integration:
Coverage upload codecov/coveralls [CONFIGURED | MISSING]
Artifact upload coverage reports [CONFIGURED | MISSING]
Overall: [X issues found]If , stop here.
--check-only打印格式化的合规性报告:
代码覆盖率合规性报告
================================
项目: [名称]
框架: [Vitest 2.x | pytest 8.x | cargo-llvm-cov 0.6.x]
覆盖率配置:
提供方 @vitest/coverage-v8 [已配置 | 缺失]
报告器 text、json、html、lcov [全部配置 | 部分配置]
输出目录 coverage/ [已配置 | 默认]
排除项 node_modules、dist、tests [已配置 | 不完整]
阈值:
行覆盖率 80% [通过 | 不达标 | 未设置]
分支覆盖率 80% [通过 | 不达标 | 未设置]
函数覆盖率 80% [通过 | 不达标 | 未设置]
语句覆盖率 80% [通过 | 不达标 | 未设置]
CI/CD集成:
覆盖率上传 codecov/coveralls [已配置 | 缺失]
制品上传 覆盖率报告 [已配置 | 缺失]
总体状态: [发现X个问题]如果使用,在此步骤停止。
--check-onlyStep 4: Configure coverage (if --fix or user confirms)
步骤4:配置覆盖率(如果使用--fix或用户确认)
Apply coverage configuration based on detected framework. Use templates from REFERENCE.md:
- Install coverage provider (e.g., ,
@vitest/coverage-v8)pytest-cov - Update config file with thresholds, reporters, exclusions
- Add scripts to package.json or pyproject.toml
- Configure CI/CD with Codecov upload and artifact storage
根据检测到的框架应用覆盖率配置。使用REFERENCE.md中的模板:
- 安装覆盖率提供方(例如:、
@vitest/coverage-v8)pytest-cov - 更新配置文件,添加阈值、报告器、排除项
- 添加脚本到package.json或pyproject.toml
- 配置CI/CD,添加Codecov上传与制品存储
Step 5: Update standards tracking
步骤5:更新标准跟踪
Update :
.project-standards.yamlyaml
standards_version: "2025.1"
last_configured: "[timestamp]"
components:
coverage: "2025.1"
coverage_threshold: 80
coverage_provider: "[v8|istanbul|pytest-cov|llvm-cov]"
coverage_reporters: ["text", "json", "html", "lcov"]
coverage_ci: "codecov"更新:
.project-standards.yamlyaml
standards_version: "2025.1"
last_configured: "[时间戳]"
components:
coverage: "2025.1"
coverage_threshold: 80
coverage_provider: "[v8|istanbul|pytest-cov|llvm-cov]"
coverage_reporters: ["text", "json", "html", "lcov"]
coverage_ci: "codecov"Step 6: Print final report
步骤6:打印最终报告
Print a summary of changes applied, scripts added, and next steps for verifying coverage.
For detailed configuration templates, see REFERENCE.md.
打印已应用的更改、添加的脚本,以及验证覆盖率的后续步骤。
有关详细配置模板,请参阅REFERENCE.md。
Agentic Optimizations
智能优化命令
| Context | Command |
|---|---|
| Quick compliance check | |
| Auto-fix all issues | |
| Custom threshold | |
| Check coverage config exists | |
| Verify coverage directory | |
| 场景 | 命令 |
|---|---|
| 快速合规性检查 | |
| 自动修复所有问题 | |
| 自定义阈值 | |
| 检查覆盖率配置是否存在 | |
| 验证覆盖率目录 | |
Flags
标志参数
| Flag | Description |
|---|---|
| Report status without offering fixes |
| Apply all fixes automatically without prompting |
| Set coverage threshold (default: 80) |
| 标志 | 描述 |
|---|---|
| 仅报告状态,不提供修复 |
| 自动应用所有修复,无需提示 |
| 设置覆盖率阈值(默认值:80) |
Examples
使用示例
bash
undefinedbash
undefinedCheck compliance and offer fixes
检查合规性并提供修复选项
/configure:coverage
/configure:coverage
Check only, no modifications
仅检查,不修改
/configure:coverage --check-only
/configure:coverage --check-only
Auto-fix with custom threshold
自动修复并使用自定义阈值
/configure:coverage --fix --threshold 90
undefined/configure:coverage --fix --threshold 90
undefinedError Handling
错误处理
- No test framework detected: Suggest running first
/configure:tests - Coverage provider missing: Offer to install
- Invalid threshold: Reject values <0 or >100
- CI token missing: Warn about Codecov/Coveralls setup
- 未检测到测试框架: 建议先运行
/configure:tests - 缺失覆盖率提供方: 提供安装选项
- 无效阈值: 拒绝<0或>100的值
- 缺失CI令牌: 警告Codecov/Coveralls设置
See Also
相关链接
- - Configure testing frameworks
/configure:tests - - Run tests with coverage
/test:coverage - - Run all compliance checks
/configure:all - Codecov documentation: https://docs.codecov.com
- pytest-cov documentation: https://pytest-cov.readthedocs.io
- - 配置测试框架
/configure:tests - - 运行带覆盖率的测试
/test:coverage - - 运行所有合规性检查
/configure:all - Codecov文档: https://docs.codecov.com
- pytest-cov文档: https://pytest-cov.readthedocs.io