testing-patterns

Guide unit testing with TDD, BDD, factory functions, and module mocking.

Updated Jan 8, 2026
One-click install
npx skills add https://github.com/AndyAnh174/BanThuoc-SEO --skill testing-patterns-andyanh174
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-patterns
Source: https://github.com/AndyAnh174/BanThuoc-SEO/tree/main/.agent/skills/testing-patterns
Command: npx skills add https://github.com/AndyAnh174/BanThuoc-SEO --skill testing-patterns-andyanh174

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the challenges of writing effective, maintainable, and robust unit tests by providing clear patterns and utilities for common testing scenarios.

Core Features & Use Cases

  • TDD & BDD: Guides users through Test-Driven Development and Behavior-Driven Testing principles.
  • Factory Functions: Demonstrates how to create reusable factories for mock data and component props to keep tests DRY.
  • Mocking Strategies: Covers techniques for mocking modules, API calls, and GraphQL hooks.
  • Use Case: When developing a new React Native component, use this Skill's patterns to set up factories for its props and mock its dependencies, ensuring comprehensive test coverage from the start.

Quick Start

Use the testing-patterns skill to generate a factory function for mock user data with optional overrides.

Frequently Asked Questions about testing-patterns

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

FAQPage Schema
How do I create reusable mock data for Jest unit tests?

To create reusable mock data, implement factory functions that generate base objects with optional overrides. This pattern keeps your Jest unit tests DRY by centralizing mock data generation for components and APIs.

What is the best way to mock API calls and GraphQL hooks in React Native?

The best way to mock API calls and GraphQL hooks in React Native is using module mocking strategies. By intercepting module imports, you can simulate API responses and control component behavior during unit tests.

How do I start with Test-Driven Development for frontend components?

Start Test-Driven Development (TDD) for frontend components by writing failing tests first, then implementing the component logic. This approach emphasizes Behavior-Driven Development (BDD) principles to ensure robust test coverage from the start.

Can I use these testing patterns for both frontend and backend applications?

Yes, you can use these testing patterns for both frontend and backend applications. The guidance covers universal unit testing strategies, including mocking modules and creating maintainable test suites applicable across your software stack.

Why does my test suite break when I update component props?

Your test suite breaks because hardcoded props lack flexibility. By using factory functions for component props, you provide default values with optional overrides, ensuring tests remain maintainable and robust against UI changes.

Does this Skill include testing patterns for Jest specifically?

Yes, this Skill includes testing patterns applicable to Jest. It provides comprehensive guidance on module mocking, factory functions for mock data, and Test-Driven Development principles to build maintainable test suites.