Skip to content

Jest and React Native Testing Library patterns with factory functions, mocking strategies, and a TDD red-green-refactor workflow.

CCM score
63 of 100
skills.sh installs
306
GitHub stars
34.3K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers test utilities, factory-based test data, module and GraphQL hook mocking, and test structure with describe blocks
  • Includes a custom renderWithTheme wrapper, props and data factories following getMockX(overrides?), and query and interaction examples
  • Flags anti-patterns such as asserting on mock calls instead of rendered behavior, and duplicated inline test data
  • Designed for React Native teams writing unit tests and following TDD

Install

$ npx -y skills add davila7/claude-code-templates --skill testing-patterns -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

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';

Details

Repository
github.com/davila7/claude-code-templates
Categories
Testing & QA, Frontend & UI Code, Mobile Apps
First seen
Jun 3, 2026

Questions

What does the testing-patterns skill do?

testing-patterns gives an agent Jest testing patterns, factory functions, mocking strategies and a TDD red-green-refactor workflow. It guides writing unit tests, building test factories such as getMockX overrides, and mocking modules and GraphQL hooks.

How do I install testing-patterns?

Run npx -y skills add davila7/claude-code-templates --skill testing-patterns -y in your project. After that, testing-patterns lets the agent write Jest unit tests that follow the TDD cycle and reusable test data factories.

Which other skills are in the Testing & QA category with testing-patterns?

testing-patterns sits in the Testing & QA category with tdd, migrate-to-shoehorn, test-driven-development, webapp-testing and break-ui. Its own focus is factory-based Jest test data, mocking patterns and React Native style query and interaction examples.

When should an agent use the testing-patterns skill?

testing-patterns applies when an agent writes unit tests, creates test factories, or follows the TDD red-green-refactor cycle. It also covers custom render helpers that wrap components with providers, and anti-patterns such as testing mock behavior instead of real behavior.

More from davila7/claude-code-templates

All 398

Similar to Testing Patterns

More Testing & QA