testing-patterns

📁 yonatangross/orchestkit 📅 13 days ago
35
总安装量
32
周安装量
#10577
全站排名
安装命令
npx skills add https://github.com/yonatangross/orchestkit --skill testing-patterns

Agent 安装分布

gemini-cli 30
opencode 29
github-copilot 29
claude-code 28
codex 28
cursor 27

Skill 文档

Testing Patterns

Comprehensive patterns for building production test suites. Each category has individual rule files in rules/ loaded on-demand.

Quick Reference

Category Rules Impact When to Use
Unit Testing 3 CRITICAL AAA pattern, parametrized tests, fixture scoping
Integration Testing 3 HIGH API endpoints, database tests, component integration
E2E Testing 3 HIGH Playwright, AI agents, page objects
Pytest Advanced 3 HIGH Custom markers, xdist parallel, plugins
API Mocking 3 HIGH MSW 2.x, VCR.py, LLM API mocking
Test Data 3 MEDIUM Factories, fixtures, seeding/cleanup
Verification 3 MEDIUM Property-based, stateful, contract testing
Performance 3 MEDIUM k6 load tests, Locust, test types
LLM Testing 3 HIGH Mock responses, DeepEval, structured output
Accessibility 3 MEDIUM jest-axe, Playwright axe, CI gates
Execution 2 HIGH Parallel runs (xdist/matrix), coverage thresholds/reporting
Validation 2 HIGH Zod schema testing, tRPC/Prisma end-to-end type safety
Evidence 1 MEDIUM Task completion verification, exit codes, evidence protocol

Total: 35 rules across 13 categories

Quick Start

# pytest: AAA pattern with fixtures
@pytest.fixture
def user(db_session):
    return UserFactory.create(role="admin")

def test_user_can_publish(user, article):
    result = article.publish(by=user)
    assert result.status == "published"
// Vitest + MSW: API integration test
const server = setupServer(
  http.get('/api/users', () => HttpResponse.json([{ id: 1 }]))
);
test('renders user list', async () => {
  render(<UserList />);
  expect(await screen.findByText('User 1')).toBeInTheDocument();
});

Unit Testing

Isolated business logic tests with fast, deterministic execution.

Rule File Key Pattern
AAA Pattern rules/unit-aaa-pattern.md Arrange-Act-Assert with Vitest/pytest
Parametrized Tests rules/unit-parametrized.md test.each, @pytest.mark.parametrize, indirect
Fixture Scoping rules/unit-fixture-scoping.md function/module/session scope selection

Integration Testing

Component interactions, API endpoints, and database integration.

Rule File Key Pattern
API Testing rules/integration-api.md Supertest, httpx AsyncClient, FastAPI TestClient
Database Testing rules/integration-database.md In-memory SQLite, transaction rollback, test containers
Component Integration rules/integration-component.md React Testing Library, QueryClientProvider

E2E Testing

End-to-end validation with Playwright 1.58+.

Rule File Key Pattern
Playwright Core rules/e2e-playwright.md Semantic locators, auto-wait, flaky detection
AI Agents rules/e2e-ai-agents.md Planner/Generator/Healer, init-agents
Page Objects rules/e2e-page-objects.md Page object model, visual regression

Pytest Advanced

Advanced pytest infrastructure for scalable test suites.

Rule File Key Pattern
Markers + Parallel rules/pytest-execution.md Custom markers, pyproject.toml, xdist loadscope, worker DB isolation
Plugins & Hooks rules/pytest-plugins.md conftest plugins, factory fixtures, async mode

API Mocking

Network-level mocking for deterministic tests.

Rule File Key Pattern
MSW 2.x rules/mocking-msw.md http/graphql/ws handlers, server.use() override
VCR.py rules/mocking-vcr.md Record/replay cassettes, sensitive data filtering
LLM API Mocking rules/llm-mocking.md Custom matchers, async VCR, CI record modes

Test Data

Fixture and factory patterns for test data management.

Rule File Key Pattern
Factory Patterns rules/data-factories.md FactoryBoy, faker, TypeScript factories
JSON Fixtures rules/data-fixtures.md Fixture composition, conftest loading
Seeding & Cleanup rules/data-seeding-cleanup.md Database seeding, autouse cleanup, isolation

Verification

Advanced verification patterns beyond example-based testing.

Rule File Key Pattern
Property-Based rules/verification-techniques.md Hypothesis strategies, roundtrip/idempotence
Stateful Testing rules/verification-stateful.md RuleBasedStateMachine, Schemathesis
Contract Testing rules/verification-contract.md Pact consumer/provider, broker CI/CD

Performance

Load and stress testing for capacity validation.

Rule File Key Pattern
k6 Patterns rules/perf-k6.md Stages, thresholds, custom metrics
Locust rules/perf-locust.md HttpUser tasks, on_start auth
Test Types rules/perf-types.md Load/stress/spike/soak profiles

LLM Testing

Testing patterns for AI/LLM applications.

Rule File Key Pattern
Mock Responses rules/llm-mocking.md AsyncMock, patch model_factory
LLM Evaluation rules/llm-evaluation.md DeepEval metrics, schema validation, timeout testing

Accessibility

Automated accessibility testing for WCAG compliance.

Rule File Key Pattern
A11y Testing rules/a11y-testing.md jest-axe, CI gates, PR blocking, component-level validation
Playwright axe rules/a11y-playwright.md Page-level wcag2aa scanning

Execution

Test execution strategies for parallel runs and coverage collection.

Rule File Key Pattern
Execution rules/execution.md Parallel execution, coverage reporting, CI optimization

Validation

Schema validation testing with Zod, tRPC, and end-to-end type safety.

Rule File Key Pattern
Zod Schema rules/validation-zod-schema.md safeParse testing, branded types, assertNever
End-to-End Types rules/validation-end-to-end.md tRPC, Prisma, Pydantic, schema rejection tests

Evidence

Evidence collection for verifiable task completion.

Rule File Key Pattern
Evidence Verification rules/verification-evidence.md Exit codes, test/build/quality evidence, protocol

Key Decisions

Decision Recommendation
Unit framework Vitest (TS), pytest (Python)
E2E framework Playwright 1.58+ with semantic locators
API mocking MSW 2.x (frontend), VCR.py (backend)
Test data Factories over fixtures
Coverage targets 90% business logic, 70% integration, 100% critical paths
Performance tool k6 (JS), Locust (Python)
A11y testing jest-axe + Playwright axe-core
Runtime validation Zod (safeParse at boundaries)
E2E type safety tRPC (no codegen)
Branded types Zod .brand() for ID confusion prevention
Evidence minimum Exit code 0 + timestamp
Coverage standard 70% production, 80% gold

Detailed Documentation

Resource Description
scripts/ Templates: conftest, page objects, MSW handlers, k6 scripts
checklists/ Pre-flight checklists for each testing category
references/ API references: Playwright, MSW 2.x, DeepEval, strategies
examples/ Complete test examples and patterns

Related Skills

  • test-standards-enforcer – AAA and naming enforcement
  • run-tests – Test execution orchestration
  • golden-dataset-validation – Golden dataset testing
  • observability-monitoring – Metrics and monitoring