TDD Mastery Core Cycle: Red-Green-Refactor 1. Red - Write a failing test that defines the desired behavior 2. Green - Write the minimum code to make the test pass 3. Refactor - Clean up while keeping tests green Never write production code without a failing test first. Each cycle should take 2-10 minutes. Test Structure Use the Arrange-Act-Assert pattern consistently: Name tests as or . Jest / Vitest Patterns Use / for mocks. Prefer dependency injection over module mocking. Use for shared setup, never share mutable state between tests. pytest Patterns Use for exceptions. Use for shared fixtur…