askill
testing

testingSafety --Repository

Testing strategies based on Clean Architecture layers. Trigger: Invoke when writing tests to enforce layer-specific mocking strategies (Unit vs Integration)

0 stars
1.2k downloads
Updated 1/22/2026

Package Files

Loading files...
SKILL.md

🧠 Rules by Layer

1. Domain Layer (src/domain)

  • Type: Pure Unit Tests.
  • Mocks: ❌ NONE.
  • Focus: Test business logic, Zod schema validations (.parse()), and utility functions.
  • Example: expect(productSchema.parse(invalidData)).toThrow().

2. Application Layer (src/application)

  • Type: Unit Tests.
  • Mocks: βœ… Mock Infrastructure Repositories and Zustand Stores.
  • Focus:
    • Test queryOptions generation keys.
    • Test complex hooks logic (use renderHook).
    • Test Zustand actions (state mutations).
  • Tooling: vi.spyOn, mockZustand.

3. Infrastructure Layer (src/infrastructure)

  • Type: Integration Tests.
  • Mocks: βœ… Mock HTTP Network (use msw or nock).
  • Focus:
    • Verify Repositories call the correct endpoints.
    • Verify Mappers correctly transform API DTOs -> Domain Entities.
    • Verify DTOs match expected API shapes.

4. Presentation Layer (src/presentation)

  • Type: Component Integration Tests.
  • Mocks: βœ… Mock Application Layer Hooks (e.g., useProductDetail).
  • Forbidden: ❌ NEVER mock axios, fetch, or useQuery directly in components.
  • Focus:
    • Test UI rendering based on data states (Success, Empty).
    • Test User Interactions (Click, Type) firing handlers.
    • Test Accessibility (aria-labels).
  • Tooling: render, screen, userEvent.

πŸ“ Conventions

  • Naming: Filename.test.tsx or Filename.spec.ts.
  • Location: Co-located next to the source file.
  • Async: Always use await screen.findBy* for async elements, never wait().

Keywords

vitest, react-testing-library, rtl, user-event, msw, unit-testing, integration-testing, mocks.

Install

Download ZIP
Requires askill CLI v1.0+β–Ά

AI Quality Score

AI review pending.

Metadata

Licenseunknown
Version-
Updated1/22/2026
Publisherjmgomezdev

Tags

apitesting