unit-testing-framework by aj-geddes/useful-ai-prompts
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill unit-testing-framework遵循行业最佳实践和 AAA(准备-执行-断言)模式,编写快速、独立、可读且可维护的高效单元测试。
最小工作示例:
// Jest/JavaScript example
describe("UserService", () => {
describe("createUser", () => {
it("should create user with valid data", async () => {
// Arrange - Set up test data and dependencies
const userData = {
email: "john@example.com",
firstName: "John",
lastName: "Doe",
};
const mockDatabase = createMockDatabase();
const service = new UserService(mockDatabase);
// Act - Execute the function being tested
const result = await service.createUser(userData);
// Assert - Verify the outcome
expect(result.id).toBeDefined();
expect(result.email).toBe("john@example.com");
expect(mockDatabase.save).toHaveBeenCalledWith(
expect.objectContaining(userData),
);
});
});
});
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
references/ 目录下的详细实现:
| 指南 | 内容 |
|---|---|
| 测试结构(AAA 模式) | 测试结构(AAA 模式) |
| 按语言分类的测试用例 | 按语言分类的测试用例 |
| 模拟与测试替身 | 模拟与测试替身 |
| 测试异步代码 | 测试异步代码,测试覆盖率 |
| 测试边界情况 | 测试边界情况 |
| 示例:完整测试套件 | import { UserService } from "./user-service"; |
每周安装次数
121
代码仓库
GitHub 星标数
121
首次出现
2026年1月21日
安全审计
安装于
opencode98
gemini-cli97
codex96
cursor91
claude-code88
github-copilot81
Write effective unit tests that are fast, isolated, readable, and maintainable following industry best practices and AAA (Arrange-Act-Assert) pattern.
Minimal working example:
// Jest/JavaScript example
describe("UserService", () => {
describe("createUser", () => {
it("should create user with valid data", async () => {
// Arrange - Set up test data and dependencies
const userData = {
email: "john@example.com",
firstName: "John",
lastName: "Doe",
};
const mockDatabase = createMockDatabase();
const service = new UserService(mockDatabase);
// Act - Execute the function being tested
const result = await service.createUser(userData);
// Assert - Verify the outcome
expect(result.id).toBeDefined();
expect(result.email).toBe("john@example.com");
expect(mockDatabase.save).toHaveBeenCalledWith(
expect.objectContaining(userData),
);
});
});
});
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Test Structure (AAA Pattern) | Test Structure (AAA Pattern) |
| Test Cases by Language | Test Cases by Language |
| Mocking & Test Doubles | Mocking & Test Doubles |
| Testing Async Code | Testing Async Code, Test Coverage |
| Testing Edge Cases | Testing Edge Cases |
| Example: Complete Test Suite | import { UserService } from "./user-service"; |
Weekly Installs
121
Repository
GitHub Stars
121
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode98
gemini-cli97
codex96
cursor91
claude-code88
github-copilot81
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
118,000 周安装
竞争对手研究指南:SEO、内容、反向链接与定价分析工具
386 周安装
Nuxt UI v4 组件库 | 125+ 生产级组件,支持 Nuxt 4、Tailwind CSS v4 与 AI 集成
82 周安装
AI/SaaS产品电子邮件营销策略指南:EDM与Newsletter、送达率配置、SEO协同
386 周安装
测试驱动开发TDD完整指南:红绿重构循环、核心原则与实践方法
384 周安装
Notion CLI 命令行工具:管理 Notion API、Workers 和文件上传的终极指南
397 周安装
Salesforce Agentforce 会话追踪与可观测性分析技能 - 提取Parquet数据,调试AI智能体
392 周安装