
Testing Patterns
This is a practical reference for Jest testing with a strong emphasis on factory functions and TDD workflow. It covers the getMockX pattern for creating test data with sensible defaults and overrides, custom render functions that wrap providers, and mocking strategies for modules and GraphQL hooks. The real value is in the opinionated structure: it pushes you to write failing tests first, use descriptive test names focused on behavior rather than implementation, and organize tests into rendering, interactions, and edge cases. The anti-patterns section is helpful for catching common mistakes like testing mock behavior instead of actual component output. Works well if you want consistent test patterns across a codebase rather than ad hoc approaches.
- skills.sh installs
- 306
- GitHub stars
- 33.2K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add davila7/claude-code-templates --skill testing-patterns --agent claude-codeInstalls into .claude/skills of the current project.
Files
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:
// src/utils/testUtils.tsx
import { render } from '@testing-library/react-native';
import { ThemeProvider } from './theme';
export const renderWithTheme = (ui: React.ReactElement) => {
return render(
<ThemeProvider>{ui}</ThemeProvider>
);
};
Usage:
import { renderWithTheme } from 'utils/testUtils';
import { screen } from '@testing-library/react-native';
Sponsors
Details
- Repository
- github.com/davila7/claude-code-templates
- Categories
- Testing & QA, Documentation, Code Review & Quality, Automation & Workflows
- First seen
- Jun 3, 2026
More from davila7/claude-code-templates
All 618- Llamaguard304
- Red Team Tactics304
- Awq Quantization303
- Implementing Llms Litgpt303
- Verification Before Completion302
- Fluidsim301
- Gh Address Comments301
- Invoice Organizer300
- Pymoo300
- Domain Name Brainstormer299
- Neurokit2299
- Regulatory Affairs Head299
- Openrlhf Training298
- Sparse Autoencoder Training298
- Mamba Architecture297
- Rdkit297
- Scikit Bio297
- Agent Management296
- Kegg Database295
- Torch Geometric294
- Langfuse291
- Commit Work290
- Quality Manager Qmr290
- Tdd Workflow290