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.
By sickn33 · 1,089 installs
npx skills add sickn33/agentic-awesome-skills --skill testing-patterns
Source repository · Upstream listing
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
When to Use
This skill is applicable to execute the workflow or actions described in the overview.
Limitations
Use this skill only when the task clearly matches the scope described above.
Do not treat the output as a substitute for environment specific validation, testing, or expert review.
Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.