tdd

Enforce failing tests before implementation in the zoppy-api NestJS project.

Updated Mar 1, 2026
One-click install
npx skills add https://github.com/Zoppy-crm/.github --skill tdd-zoppy-crm
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tdd
Source: https://github.com/Zoppy-crm/.github/tree/main/skills/backend/tdd
Command: npx skills add https://github.com/Zoppy-crm/.github --skill tdd-zoppy-crm

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Ensures tests are written before implementation to prevent regressions, clarify expected behavior, and reduce flaky or brittle test suites in the zoppy-api NestJS codebase.

Core Features & Use Cases

  • Red-Green-Refactor workflow: Explicit guidance to write failing tests first, implement the minimal code to pass, and refactor safely.
  • Layer-specific testing: Maps unit, integration, and E2E tests to domain, application, and HTTP layers with in-memory SQLite via TestUtils for deterministic runs.
  • Mocking & anti-flakiness rules: Advises only mocking external services, never mocking domains, and includes lifecycle hooks and cleanup practices for reliable tests.

Quick Start

Create failing tests for the target NestJS domain or controller, run them to confirm failure, then implement the minimal code until all tests pass following Red-Green-Refactor.

Frequently Asked Questions about tdd

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

FAQPage Schema
How do I structure unit, integration, and e2e tests in a NestJS project?

NestJS testing structure maps unit tests to src/domain, integration tests to src/application, and E2E controller tests to src/access/http. This layer-specific approach uses co-located spec files to ensure deterministic test runs.

What is the best way to enforce a failing-first testing workflow?

A failing-first testing workflow requires writing failing tests before implementation, confirming the failure, and then writing minimal code to pass. This Red-Green-Refactor cycle clarifies expected behavior and prevents regressions.

Why does my NestJS test suite keep producing flaky results?

Flaky test suites often occur when mocking internal domains instead of external services. You can fix this by using in-memory SQLite via TestUtils and applying structured lifecycle hooks for deterministic test runs.

When should I mock external services during integration testing?

During integration testing, you should only mock external services and never mock internal domains. This explicit mocking rule isolates external dependencies while preserving true domain logic for reliable behavior validation.

Can I use in-memory SQLite for deterministic E2E controller tests?

Yes, you can use in-memory SQLite via TestUtils for E2E controller tests. Configuring in-memory SQLite provides a fast, isolated database state that ensures deterministic test runs without persistent data side effects.