跳到正文
Skillpedia
测试75k · #3051

test-coverage

它能做什么

这项技能为软件项目设置测试覆盖率的下限。适用于希望代码长期保持良好测试的开发者和团队负责人。

适用场景

  • ✓当项目没有最低测试覆盖率规则的时候。
  • ✓当覆盖率设置已存在,但在构建过程中没有检查的时候。
  • ✓当团队希望在测试覆盖的代码不足时让构建失败的时候。

技能链接

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/test-coverage/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/test-coverage/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我们的项目有测试,但没有任何机制阻止覆盖率下降。请帮我设置能阻止构建的最低标准。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会在测试工具中设置最低覆盖率数值,并在构建中加入检查。如果覆盖率低于下限,构建就会失败。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Maintain test coverage thresholds

Coverage thresholds prevent code quality from degrading over time by failing builds when test coverage drops below safe levels.

Quick Reference

  • Set global thresholds: 70% branches, 80% lines/functions/statements
  • Apply stricter thresholds (90%+) to critical utility code
  • Exclude generated code, type definitions, and config files
  • Focus on meaningful coverage—test behavior, not just lines

Check

Review this project's test coverage configuration to ensure minimum thresholds are set and enforced in CI/CD.

Fix

Configure coverage thresholds in Jest, Vitest, or your testing framework, and add coverage checks to CI/CD.

Explain

Explain how to set up test coverage thresholds and what coverage levels are appropriate for different types of code.

Code Review

Review tests, CI workflows, and enforcement points related to Maintain test coverage thresholds. Flag exact gaps where the rule is not automatically verified or where failures do not block regressions.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/testing/test-coverage

常见问题

这项技能建议什么覆盖率水平?

它建议分支覆盖率约 70%,行、函数和语句覆盖率约 80%,关键代码应设置更严格的标准。

它支持哪些工具?

这项技能提到了 Jest、Vitest 和其他测试框架。

我应该测试每一行吗?

不需要。这项技能指出,应专注于对行为的有意义测试,而不是只为了达到某个数字。

详情

作者的原始描述

Use when reviewing CI coverage, automated checks, or test strategy related to Maintain test coverage thresholds. Focus on whether the rule is continuously verified, not just documented.

repo: thedaviddias/Front-End-Checklist

热度

GitHub 星标
75k
排名
#3051
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能