一键导入
testing-patterns
Testing strategies and patterns for quality assurance
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Testing strategies and patterns for quality assurance
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Pull request lifecycle domain knowledge — branch strategy detection, PR size classification, confidence-scored review, git-aware context, PR analytics, dependency management, and split/merge/describe operations.
Production readiness audit domains, weighted scoring criteria, and check specifications for the /preflight workflow.
Application scaffolding orchestrator. Creates full-stack applications from requirements, selects tech stack, coordinates agents.
Production deployment workflows, rollback strategies, and CI/CD best practices.
Internationalization and localization patterns for multi-language applications
Mobile UI/UX patterns for iOS and Android. Touch-first, platform-respectful design with React Native/Expo focus.
| name | testing-patterns |
| description | Testing strategies and patterns for quality assurance |
| triggers | ["context","test","tdd","jest","vitest"] |
Purpose: Apply professional testing strategies for quality assurance
This skill provides comprehensive testing patterns for unit, integration, and end-to-end testing.
/\
/E2E\ ← Few, slow, expensive
/──────\
/Integra-\ ← Some, medium speed
/ tion \
/────────────\
/ Unit \ ← Many, fast, cheap
/────────────────\
describe("UserService", () => {
it("should create a user with valid data", async () => {
// Arrange
const userData = { email: "test@example.com", name: "Test" };
const mockRepository = {
create: jest.fn().mockResolvedValue({ id: "1", ...userData }),
};
const service = new UserService(mockRepository);
// Act
const result = await service.createUser(userData);
// Assert
expect(result.id).toBe("1");
expect(result.email).toBe("test@example.com");
expect(mockRepository.create).toHaveBeenCalledWith(userData);
});
});
// Pattern: should_[expected]_when_[condition]
it('should throw ValidationError when email is invalid', () => { ... });
it('should return empty array when no users exist', () => { ... });
it('should hash password when creating user', () => { ... });
describe("POST /api/users", () => {
beforeAll(async () => {
await setupTestDatabase();
});
afterAll(async () => {
await teardownTestDatabase();
});
it("should create user and return 201", async () => {
const response = await request(app)
.post("/api/users")
.send({ email: "test@example.com", password: "SecurePass123!" })
.expect(201);
expect(response.body.data.email).toBe("test@example.com");
});
});
const mockSendEmail = jest.fn().mockResolvedValue({ sent: true });
jest.mock("./emailService", () => ({
sendEmail: jest.fn().mockResolvedValue({ sent: true }),
}));
const spy = jest.spyOn(userService, "validate");
await userService.createUser(data);
expect(spy).toHaveBeenCalled();
| Metric | Target |
|---|---|
| Lines | ≥80% |
| Branches | ≥75% |
| Functions | ≥80% |
| Statements | ≥80% |
| Pattern | Usage |
|---|---|
| AAA | All unit tests |
| Given-When-Then | BDD style |
| Mocking | Isolate dependencies |
| Fixtures | Reusable test data |
| Factories | Generate test objects |
| Snapshot | UI components |