Unit Testing

Unit testing patterns and best practices for frontend and backend. Test isolation, mocks, coverage, and structure. Trigger: When writing or reviewing unit tests for any layer.

majiayu000 Updated 567 repo stars

File contents

Unit Testing Skill

When to Use

  • Writing unit tests for frontend or backend
  • Reviewing test coverage and isolation
  • Refactoring test structure

Critical Patterns

Frontend

  • Use RTL for user-centric tests
  • Mock dependencies and hooks
  • Test UI logic in isolation

Backend

  • Use Jest for logic isolation
  • Mock I/O and external services
  • Test pure functions and modules

Decision Tree

  • UI or logic? → Use RTL or Jest
  • Need mocks? → Use jest.mock or manual mocks
  • Async code? → Use async/await in tests

Edge Cases

  • Flaky async tests
  • Mocking native modules
  • Coverage gaps

majiayu000/claude-skill-registry-data/tree/main/testing/unit-testing-joabgonzalez-ai-agents-framework commit a00d2d5bd1

Frequently asked questions

npx skillmds@latest add majiayu000/unit-testing-5