| name | tdd-red |
| description | Write failing tests FIRST before any implementation. RED phase of RED-GREEN-REFACTOR cycle. Non-negotiable before implementing features. |
TDD Red Phase
TRAP 8 Defense: Tests before implementation
The Rule
Write a failing test that describes the desired behavior BEFORE writing any implementation code.
RED Phase Requirements
- Test MUST fail - If it passes immediately, you're testing the wrong thing
- Test MUST be specific - Testing exact expected behavior
- Test MUST be minimal - Only test one thing
- Test MUST compile - TypeScript clean
Test Template
describe('FeatureName', () => {
it('should [expected behavior] when [condition]', () => {
const input = createTestInput();
const result = featureUnderTest(input);
expect(result).toBe(expectedValue);
});
});
Before Writing Test
Ask yourself:
- What is the smallest behavior I can test?
- What exact input/output do I expect?
- Am I testing behavior, not implementation?
- Will this test fail for the right reason?
After Test Written
- Run the test with project test command
- Confirm it FAILS
- Read the failure message - it should describe missing behavior
- Proceed to GREEN phase ONLY after red confirmed
Verification
pnpm test:fast -- --run <test-file>
RED Phase Complete When
Failure Mode
If you skip RED:
⛔ TDD VIOLATION
Attempted: Write implementation without failing test
ACTION: Stop. Write failing test first.
Next Phase
After RED confirmed → Proceed to GREEN phase (minimal implementation to pass test)