Skip to content
Back to skills

Testing Patterns

ASecurity

Choose and implement unit/integration/E2E tests that catch real regressions in this monorepo.

  • 5 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added September 2, 2026
developmentsqltestingapi

Works with

  • api

Security analysis

A100/100

Scanned November 9, 2026

npx -y skills add kookr-ai/kookr --skill testing-patterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Testing Patterns?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Testing Patterns
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/kookr-ai-testing-patterns/badge)](https://www.skillsdirectory.com/skills/kookr-ai-testing-patterns)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: testing-patterns
group: testing
description: Choose and implement unit/integration/E2E tests that catch real regressions in this monorepo.
keywords: testing, integration tests, route registration test, sql template assertion, reproduction first, env parity, flaky test, vitest bun
related: tdd-workflow
---
# Testing Patterns
## When to Use
- A bug is reported and root cause is unclear.
- Mock-heavy tests pass while production fails.
- Route exists in code but returns 404 at runtime.
- SQL cast/type mismatch appears only in integration runs.

## Quick Reference
| Need | Best Test Type | Why |
|---|---|---|
| Business logic branch behavior | Unit | Fast, isolated feedback |
| Route wiring + middleware + DI | Integration | Catches registration/order/config failures |
| SQL cast/template correctness | Integration with real DB driver path | Mocks miss SQL string/type issues |
| Browser flow/regression | E2E | Validates full stack and UX behavior |

## Patterns
| Pattern | Rule | Verification |
|---|---|---|
| Reproduction-first | Encode minimal failing scenario before broad refactor | Test fails before fix |
| Route-registration test | Assert route is mounted and reachable in app bootstrap context | Prevent silent 404 from missed registration |
| SQL template assertions | Assert generated SQL contains expected casts/placeholders and binds | Catch `::text[]` vs `::uuid[]` class of bugs |
| Environment parity preflight | Align ports/env flags/service deps with target runtime | “Works locally only” incidents drop |
| Contract boundary tests | Validate request/response envelopes against shared schemas | Detect docs/impl drift early |
| Coverage task stopping rule | Stop after 2 iterations with <2% coverage delta or once task target is met | Final output reports coverage % and delta from start |

## Environment Parity Checklist
| Item | Expected |
|---|---|
| API/DB/Redis ports | Match documented dev/test mapping |
| Feature flags | Explicit values for branch under test |
| Mock gates | Disabled unless test explicitly targets mock path |
| Worker/autonomy mode | Set intentionally, not inherited stale state |

## Common Pitfalls
| Pitfall | Why It Fails | Safer Alternative |
|---|---|---|
| Starting with large integration suite for unknown bug | Slow and noisy | Reproduce minimal failure first |
| Pure unit coverage for route bugs | Misses registration/middleware | Add route-registration integration tests |
| SQL mocked as plain function return | Hides cast/placeholder defects | Assert SQL template + run integration query path |
| Flaky retries without root cause | Masks nondeterminism | Stabilize clock/network/state dependencies |

## See Also
- [[tdd-workflow]]

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.