test-driven-development

Guides red-green-refactor TDD workflows with Jest, Supertest, and Playwright tests.

Updated Apr 4, 2026
One-click install
npx skills add https://github.com/SleyiW/iWana-neXt --skill test-driven-development-sleyiw
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/SleyiW/iWana-neXt/tree/main/.agents/skills/test-driven-development
Command: npx skills add https://github.com/SleyiW/iWana-neXt --skill test-driven-development-sleyiw

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? It prevents writing production code before tests by enforcing a verified red-green-refactor cycle, ensuring tests describe real behavior instead of mock behavior or after-the-fact coverage. ## Core Features & Use Cases - Red-Green-Refactor Enforcement: Requires a failing test verified for the right reason before any implementation, with minimal code to pass. - Layered Testing Strategy: Applies Jest unit tests, Supertest integration tests for NestJS HTTP contracts, and Playwright E2E flows per layer. - Anti-Pattern Detection: Identifies testing mock behavior, test-only production methods, incomplete mocks, and over-mocking through gate functions and checklists. - Use Case: When adding a new API endpoint, write a failing Supertest contract test first, verify it fails correctly, implement the minimum handler, then refactor while keeping the suite green. ## Quick Start Use the test-driven-development skill to implement this feature starting with a failing test before writing any production code.

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
How do I apply TDD with Jest and Supertest?

Write a minimal failing test first, verify it fails for the right reason, then implement only the code needed to pass. Use Jest for isolated logic and Supertest for HTTP contract and NestJS module integration tests.

What is the red-green-refactor cycle in TDD?

Red-green-refactor means writing a failing test (red), implementing the minimum code to pass it (green), then improving the design while keeping tests passing (refactor). The initial failure must be verified before implementation begins.

When should I use Playwright instead of unit tests?

Use Playwright for E2E flows when behavior crosses multiple layers, such as full user journeys through frontend and backend. Use Jest unit or component tests for isolated logic where they provide real clarity.

Why is testing mock behavior a bad practice?

Asserting on mocked elements verifies the mock exists, not that the component works, so the test proves nothing about real behavior. Test the real component or unmock it, and only mock to isolate slow or external dependencies.

Should production classes have methods only used in tests?

No, test-only methods pollute production code and can be dangerous if called accidentally. Move test-only cleanup or setup logic into dedicated test utility modules instead of the production class.

When should TDD not be applied dogmatically?

Avoid dogmatic TDD when the test layer is wrong for the behavior, when snapshots replace real assertions, or when design is inflated before tests demand it. Escalate if project constraints prevent validating critical behavior with reasonable tests.