Agent Skills: Testing Strategy

>-

UncategorizedID: jagreehal/jagreehal-claude-skills/testing-strategy

Install this agent skill to your local

pnpm dlx add-skill https://github.com/jagreehal/jagreehal-claude-skills/tree/HEAD/skills/testing-strategy

Skill Files

Browse the full folder contents for testing-strategy.

Download Skill

Loading file tree…

skills/testing-strategy/SKILL.md

Skill Metadata

Name
testing-strategy
Description
>-

Testing Strategy

Critical rules

  • Pyramid: many fast unit tests → fewer integration → thin load/chaos top.
  • Unit tests mock deps with mock<DepsType>() / mockDeep — never vi.mock for app modules.
  • Integration tests use real localhost DB only; guardrails must throw on non-localhost URLs.
  • Name by type: *.test.ts (unit), *.test.int.ts (integration), load/*.js, chaos/*.
  • Hard to test = design smell (fn-args-deps mocks only what the function uses).
  • Faker for realistic unique fixtures so tests parallelize without cleanup.
  • Before long setup/Prisma/Faker examples, read the matching resource below.

Workflow

  1. Pick the layer by the question:
    • Logic / injectable deps? → Unit (mock deps, ms)
    • Crosses real boundary (DB, FS)? → Integration (.test.int.ts, localhost)
    • Concurrent traffic / SLOs? → Load (performance-testing)
    • Survive dependency failure? → Chaos (performance-testing)
  2. Unit: typed mocks from the deps interface; assert Results and values (writing-tests).
  3. Integration: real DB, seed unique Faker data, query only that data.
  4. Ensure vitest.setup.ts enforces localhost DB + vi.clearAllMocks() between tests.
  5. Prisma fluent API: mockDeep<PrismaClient>() (+ $transaction callback helper).
  6. Load/chaos: critical paths only — see performance-testing.

Resources

Validation

  • [ ] Each test at the right pyramid layer
  • [ ] Unit: mock<DepsType>(), no app-module vi.mock
  • [ ] Integration: .test.int.ts + localhost-only guardrail
  • [ ] Prisma via mockDeep; Faker unique IDs/emails for parallel runs
  • [ ] Setup clears mocks between tests

Constraints

  • Not the red-green-refactor loop (tdd-workflow) or assertion craft (writing-tests).
  • Deep k6 profiles and Toxiproxy live in performance-testing.
  • Adjacent: fn-args-deps, result-types.