Agent skill · software engineering · davila7
testing-patterns
Jest testing patterns, factory functions, mocking strategies, and TDD workflow. Use when writing unit tests, creating test factories, or following TDD red-green-refactor cycle.
Why this skill is useful
Provides specific Jest testing patterns and utilities that enhance unit testing practices beyond generic knowledge.
What it needs
About 3k tokens when loaded. Last updated 2026-08-06. 30,138 stars on the source repository.
What this skill does
Testing Patterns and Utilities Testing Philosophy Test-Driven Development (TDD): Write failing test FIRST Implement minimal code to pass Refactor after green Never write production code without a failing test Behavior-Driven Testing: Test behavior, not implementation Focus on public APIs and business requirements Avoid testing implementation details Use descriptive test names that describe behavior Factory Pattern: Create getMockX(overrides?: Partial<X>) functions Provide sensible defaults Allow overriding specific properties Keep tests DRY and maintainable Test Utilities Custom Render Function Create a custom render that wraps components with required providers: Usage: Factory Pattern Component Props Factory Data Factory Mocking Patterns Mocking Modules Mocking GraphQL Hooks Test Structure Query Patterns User Interaction Patterns Anti-Patterns to Avoid Testing Mock Behavior Instead of Real Behavior Not Using Factories Best Practices 1. Always use factory functions for props and data 2. Test behavior, not implementation 3. Use descriptive test names 4. Organize with describe blocks 5. Clear mocks between tests 6. Keep tests focused - one behavior per test Running Tests Integration with Other Skills react-ui-patterns: Test all UI states (loading, error, empty, success) systematic-debugging: Write test that reproduces bug before fixing
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills davila7/testing-patterns