Skip to main content
skill

testing-patterns — Claude Code skill: Jest patterns and TDD

A Claude skill that hands the agent Jest testing patterns: data factories, module mocks and the red-green-refactor loop.

Install into Claude Code · claude-code-templates All methods and platforms ↓
npx claude-code-templates@latest --skill development/testing-patterns
Open on GitHub

What testing-patterns does

The skill sets rules for how the agent writes tests: a failing test comes first, then the smallest implementation that passes, then refactoring once it is green. It ships templates for Jest and React Native Testing Library — a custom render that wraps components in providers, prop and data factories like getMockUser(overrides), and module or GraphQL hook mocks through jest.mock and jest.requireMock.

Test structure gets its own section: describe groups, beforeEach with jest.clearAllMocks(), queries via getByText, queryByText and waitFor, interactions via fireEvent. There is also a list of anti-patterns, including asserting on a mock call instead of real behaviour and duplicating test data without factories.

The examples assume Jest, @testing-library/react-native and TypeScript, so on a different runner you will rewrite them. Running tests is covered with npm test, npm run test:coverage and npm test ComponentName.test.tsx.

What it helps with

  • write a failing test before the implementation
  • build a mock data factory with field overrides
  • mock a module or a GraphQL hook inside a test
  • wrap a component in providers when rendering
  • split tests into groups and clear mocks between them

Example prompts for the agent

  • write a test for LoginForm following testing-patterns
  • create a getMockUser factory with the admin role
  • mock useGetItemsQuery and assert the empty list state

How to install testing-patterns

1claude-code-templates

npx claude-code-templates@latest --skill development/testing-patterns

2Skills CLI (Vercel)

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

3Manually: put the files in place

~/.claude/skills/testing-patterns/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/testing-patterns/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about testing-patterns

How do I install testing-patterns in Claude?

Use the templates CLI: npx claude-code-templates@latest --skill development/testing-patterns. Alternatively run npx skills add davila7/claude-code-templates --skill testing-patterns -a claude-code. The skill file lands at ~/.claude/skills/testing-patterns/SKILL.md.

What does testing-patterns do?

It gives the agent ready-made testing patterns: prop and data factories, module and hook mocks, a describe layout with mock cleanup. It also spells out the TDD cycle and common anti-patterns.

What stack do the examples use?

Jest, @testing-library/react-native and TypeScript. With another runner or testing library you adapt the templates yourself.

Similar skills

Everything for Testing and QA →

From the same set205

The whole set →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor