test-driven-development

Guides red-green-refactor test-driven development with strict test naming and structure rules.

3|Updated Apr 2, 2026
One-click install
npx skills add https://github.com/OktayCopurlu/ai-shared --skill test-driven-development-oktaycopurlu
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/OktayCopurlu/ai-shared/tree/main/.github/workflows/skills/test-driven-development
Command: npx skills add https://github.com/OktayCopurlu/ai-shared --skill test-driven-development-oktaycopurlu

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing tests after implementation often produces shallow happy-path checks that miss regressions and encode poor structure. This Skill enforces a disciplined red-green-refactor cycle so every behavior gets a failing test first, then minimal implementation, then refactoring. ## Core Features & Use Cases - Red-Green-Refactor Cycle: Write one failing test, confirm it fails for the right reason, implement the minimum code to pass, then refactor while tests stay green. - Test Naming & Structure Rules: Enforces describe('when <scenario>') / it('<present-tense behavior>') conventions, one assertion focus per test, no should/when/if in it titles, and no multi-phase tests. - Bug Fix TDD: Reproduce a bug with a failing regression test before fixing it, ensuring the fix is verified and guarded against recurrence. - Use Case: When asked to add a new feature to a Vue component, write a failing test for the new behavior first, implement the minimal code to pass, then refactor — repeating vertically per behavior rather than writing all tests upfront. ## Quick Start Use test-driven development to implement this feature, writing a failing test for each behavior before the code that makes it pass.

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
How do I practice test-driven development step by step?▼

Follow the red-green-refactor cycle: write one failing test for a single behavior and confirm it fails for the right reason, write the minimum code to make it pass, then refactor while keeping tests green. Repeat vertically per behavior rather than writing all tests first.

How should I name unit tests with describe and it blocks?▼

Use an outer describe for the unit, nested describe('when <scenario>') for conditions, and it('<present-tense behavior>') for outcomes. Never put 'when', 'if', or 'should' in an it title, and avoid repeating the scenario inside the it description.

Can TDD be used for fixing bugs?▼

Yes. Write a test that reproduces the bug and confirm it fails for the same reason, then fix the bug so the test passes, and refactor if needed. This creates a permanent regression guard for the fixed behavior.

What should be mocked in unit tests?▼

Mock only external dependencies such as APIs, timers, and third-party libraries — never internal modules. For Vue child components, prefer stubs: { Child: true } and assert on props via findComponent rather than hand-rolled stub templates.

When is test-driven development not the right approach?▼

TDD is not for debugging existing failures without writing new code — use a debugging workflow instead — nor for reviewing test coverage in existing code, which belongs to a code review pass.