testing-patterns
Testing patterns for unit, integration, and end-to-end tests. Use when writing tests, setting up test fixtures, or validating RLS enforcement. Routes to existing test conventions.
- License 许可
- MIT
- 最近更新
- 2026-10-18
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- testing-patterns
- description
- Testing patterns for unit, integration, and end-to-end tests. Use when writing tests, setting up test fixtures, or validating RLS enforcement. Routes to existing test conventions.
02 资源文件 3
- 资产文件assets/.gitkeep—
- 参考文档references/.gitkeep—
- 脚本scripts/.gitkeep—
03 SKILL.md 正文
Testing Patterns Skill
Purpose
Guide consistent and effective testing. Routes to existing test patterns and provides evidence templates.
When This Skill Applies
- Writing unit or integration tests
- Setting up test fixtures with RLS
- Running test suites
- Packaging test evidence
Critical Rules
FORBIDDEN
// Direct Prisma calls bypass RLS
const user = await prisma.user.findUnique({ where: { user_id } });
// Shared test state causes flaky tests
let sharedUser: User;
beforeAll(() => { sharedUser = createUser(); });
CORRECT
// Use RLS context helpers
const user = await withSystemContext(prisma, "test", async (client) => {
return client.user.findUnique({ where: { user_id } });
});
// Isolated test state
beforeEach(() => {
const testUser = createTestUser();
});
// Unique identifiers
const userId = `user-${crypto.randomUUID()}`;
Test Commands
{{TEST_UNIT_COMMAND}} # Unit tests
{{TEST_INTEGRATION_COMMAND}} # Integration tests
{{TEST_E2E_COMMAND}} # E2E tests (Playwright)
{{CI_VALIDATE_COMMAND}} # Full validation
Test Directory Structure
__tests__/
├── unit/ # Fast, isolated tests
├── integration/ # API and database tests
├── e2e/ # End-to-end tests
└── setup.ts # Global setup
Evidence Template
**Test Execution Evidence**
**Test Suite**: [unit/integration/e2e]
**Files Changed**: [list files]
**Test Results:**
- Total Tests: [X]
- Passed: [X]
- Failed: [0]
**Commands Run:**
```bash
{{TEST_UNIT_COMMAND}} --coverage
## Reference
- **Jest Config**: `jest.config.js`
- **RLS Context**: `lib/rls-context.ts`
- **Pattern Library**: `patterns_library/testing/`
04 同仓库更多 Skills
stripe-patterns
暂无简介
payment-patterns
暂无简介
testing-patterns
Testing patterns for Jest and Playwright. Use when writing tests, setting up test fixtures, or validating RLS enforcement. Routes to existing test conventions.
team-coordination
Agent Teams orchestration patterns for multi-agent SAFe workflows. Use when spawning agent teams, coordinating teammates, enforcing quality gates via task dependencies, or orchestrating the 11-agent SAFe pipeline. Covers team creation, messaging, shared task lists, and SAFe gate enforcement. Do NOT use for single-agent or simple subagent workflows.
task-compilation
Compile broad audit goals into structured proof obligations with 9 mandatory fields. Used after decomposition by the Threat Modeler agent.
storage-layout-analysis
Proxy patterns, slot collisions, upgrade safety. Used during decomposition to identify storage-related vulnerabilities in upgradeable contracts.