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-code

Installs 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
1pproenca avatarrails-testingpproenca/dot-skillsRuby on Rails testing best practices for writing effective, maintainable test suites with RSpec. This skill should be used when writing, reviewing, or refactori301skills.sh installs
2patricio0312rev avatarapi-mock-serverpatricio0312rev/skillsCreates mock API servers for testing and development with MSW, json-server, or custom handlers. Use when users request "API mocking", "mock server", "MSW setup"297skills.sh installs
3tech-leads-club avatarplaywright-skilltech-leads-club/agent-skillsComplete browser automation with Playwright. Auto-detects dev servers, writes clean test scripts to /tmp. Test pages, fill forms, take screenshots, check respon297skills.sh installs
4desplega-ai avatarqa-usedesplega-ai/qa-useE2E testing and browser automation with qa-use CLI. Use when the user needs to run tests, verify features, automate browser interactions, or debug test failures295skills.sh installs
5gohypergiant avataraccelint-react-testinggohypergiant/agent-skillsUse when writing, reviewing, or refactoring React component tests with Testing Library. Load when you see render(), screen, fireEvent, userEvent, waitFor, or *.282skills.sh installs
6pproenca avatarios-testingpproenca/dot-skillsTesting practices for iOS 26 / Swift 6.2 clinic modular MVVM-C applications. Covers unit/UI/snapshot testing, protocol-based mocks, async actor isolation, and d281skills.sh installs