testing-guidelines
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "testing-guidelines":https://skillpi.com/zh/skills/deepskill-4386e2fc293f65957648445bc17c8f50fe18fc348f4afb59f8763ce99d102879。安装前核对上游来源和版本:https://skills.sh/getsentry/warden/testing-guidelines。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
skills.sh
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
用于编写测试指南,在添加新功能、修复缺陷或需要测试时使用,强调集成测试、使用真实场景测试数据以及回归测试覆盖。
介绍来源: third_party · getsentry · 1.0.0 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 适合谁
- 来源文档未说明。
- 输入和输出
- 来源文档未说明。
- 软件、账号及付费要求
- 来源文档未说明。
- 限制与区别
- 来源文档未说明。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: testing-guidelines
description: Guide for writing tests. Use when adding new functionality, fixing bugs, or when tests are needed. Emphasizes integration tests, real-world fixtures, and regression coverage.Testing Guidelines
Follow these principles when writing tests for this codebase.
Core Principles
1. Mock External Services, Use Real Fixtures
ALWAYS mock third-party network services. ALWAYS use fixtures based on real-world data.
- Fixtures must be scrubbed of PII (use dummy data like
foo@example.com,user-123) - Capture real API responses, then sanitize them
- Never make actual network calls in tests
2. Prefer Integration Tests Over Unit Tests
Focus on end-to-end style tests that validate inputs and outputs, not implementation details.
- Test the public interface, not internal methods
- Unit tests are valuable for edge cases in pure functions, but integration tests are the priority
- If refactoring breaks tests but behavior is unchanged, the tests were too coupled to implementation
3. Minimize Edge Case Testing
Don't test every variant of a problem.
- Cover the common path thoroughly
- Skip exhaustive input permutations
- Skip unlikely edge cases that add maintenance burden without value
- One representative test per category of input is usually sufficient
4. Always Add Regression Tests for Bugs
When a bug is identified, ALWAYS add a test that would have caught it.
- The test should fail before the fix and pass after
- Name it descriptively to document the bug
- This prevents the same bug from recurring
Note: Regression tests are for unintentional broken behavior (bugs), not intentional changes. Intentional feature removals, deprecations, or breaking changes do NOT need regression tests—these are design decisions, not defects.
5. Cover Every User Entry Point
ALWAYS have at least one basic test for each customer/user entry point.
- CLI commands, API endpoints, public/exported functions
- Test the common/happy path first
- This proves the entry point works at all
Note: "Entry point" means the public interface—exported functions, CLI commands, API routes. Internal/private functions are NOT entry points, even if they handle user-facing flags or options. Test entry points; internal functions get coverage through those tests.
6. Tests Validate Before Manual QA
Tests are how we validate ANY functionality works before manual testing.
- Write tests first or alongside code, not as an afterthought
- If you can't test it, reconsider the design
- Passing tests should give confidence to ship
Technical Guidelines
File Organization
- Test files use
*.test.tsextension - Co-locate tests with source:
foo.ts→foo.test.ts
Test Isolation
Every test must:
- Run independently without affecting other tests
- Use temporary directories for file operations
- Clean up resources in
afterEachhooks
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { mkdirSync, rmSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { tmpdir } from 'node:os';
describe('my feature', () => {
let tempDir: string;
beforeEach(() => {
tempDir = join(tmpdir(), `warden-test-${Date.now()}`);
mkdirSync(tempDir, { recursive: true });
});
afterEach(() => {
rmSync(tempDir, { recursive: true, force: true });
});
it('does something with files', () => {
writeFileSync(join(tempDir, 'test.ts'), 'content');
// ... test code
});
});
Pure Function Tests
For pure functions without side effects, no special setup is needed:
import { describe, it, expect } from 'vitest';
import { matchGlob } from './matcher.js';
describe('matchGlob', () => {
it('matches exact paths', () => {
expect(matchGlob('src/index.ts', 'src/index.ts')).toBe(true);
});
});
Running Tests
pnpm test # Run all tests in watch mode
pnpm test:run # Run all tests once
Checklist Before Submitting
- [ ] New entry points have at least one happy-path test
- [ ] Bug fixes (not intentional changes) include a regression test
- [ ] External services are mocked with sanitized fixtures
- [ ] Tests validate behavior, not implementation
- [ ] No shared state between tests
当前收录版本
1.0.0
安全与评测信息
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供全面的测试编写指南,涵盖核心原则、技术细节和最佳实践
- 强调集成测试、真实场景测试数据和回归测试覆盖,实用性强
亮点
- 触发场景描述清晰明确:添加新功能、修复缺陷或需要测试时
- description 精准覆盖使用边界
亮点
- 文档结构清晰,分章节组织,包含代码示例和检查清单
- frontmatter 完整,内容详实且易于理解
亮点
- 指南逻辑完整,无明显执行漏洞
- 提供具体的代码示例和运行命令,可操作性强
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
保存或修改文件
先确认输出目录和同名文件是否会被覆盖;重要文件保留备份,优先写入新的输出目录。
主文档提及 · 第 98 行
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
来源文档未说明。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。