testing-patterns

Write Jest unit tests using TDD, factory functions, and mocking strategies.

1|Updated Feb 6, 2026
One-click install
npx skills add https://github.com/Adam-Guerin/Asmblr --skill testing-patterns-adam-guerin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-patterns
Source: https://github.com/Adam-Guerin/Asmblr/tree/main/skills/testing-patterns
Command: npx skills add https://github.com/Adam-Guerin/Asmblr --skill testing-patterns-adam-guerin

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides a comprehensive guide to writing effective unit tests using Jest, covering essential patterns like TDD, factory functions, and mocking strategies to improve code quality and maintainability.

Core Features & Use Cases

  • TDD Workflow: Implement the red-green-refactor cycle for test-driven development.
  • Factory Functions: Create reusable functions for generating mock data and component props, ensuring DRY tests.
  • Mocking Strategies: Learn to mock modules and specific functions (e.g., GraphQL hooks) for isolated testing.
  • Use Case: When developing a new React Native component, use this Skill's patterns to write tests that cover rendering, user interactions, and edge cases, ensuring the component behaves as expected.

Quick Start

Use the testing-patterns skill to write a new unit test for the MyComponent using a factory function for its props.

Frequently Asked Questions about testing-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write unit tests using Jest with factory functions for mock data?

Jest unit tests use factory functions to generate reusable mock data and component props. This pattern ensures DRY tests by centralizing mock creation, improving test maintainability and code reusability across your test suite.

What is the red-green-refactor cycle in TDD and how do I apply it?

The red-green-refactor cycle in TDD involves writing a failing test, implementing code to pass it, then refactoring. Apply this workflow in Jest to drive software design, ensure behavior-driven testing, and maintain code quality.

How do I mock modules and GraphQL hooks for isolated testing in Jest?

Mock modules and GraphQL hooks in Jest for isolated testing by replacing specific functions with controlled mocks. This strategy ensures test isolation by preventing external dependencies from affecting unit test behavior.

Can I use Jest testing patterns for React Native component development?

Yes, Jest testing patterns apply to React Native component development. Use these patterns to write tests covering component rendering, user interactions, and edge cases, ensuring the component behaves as expected.

Why does my Jest test fail when testing components with external dependencies?

Jest tests fail with external dependencies due to inadequate test isolation. Implement mocking strategies to replace modules and specific functions like GraphQL hooks, ensuring component tests remain isolated and behavior-driven.