[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6EMQGFJGFFZJBZA8D35Q3G7":3,"skill-same:01M6EMQGFJGFFZJBZA8D35Q3G7":77},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":44,"commitSha":45,"skillDirectory":46,"forksCount":47,"repositoryHtmlUrl":48,"repositoryHomepageUrl":49,"ownerHtmlUrl":50,"ownerBlogUrl":6,"ownerDescription":51,"updatedAt":52,"install":53,"resources":66},"01M6EMQGFJGFFZJBZA8D35Q3G7","tdd-enforcer",null,"Use when implementing new features. Enforces TDD workflow - write tests FIRST, then implementation. Ensures AAA pattern, proper coverage, and quality test design.","ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Fbarnhardt-enterprises-inc\u002Ftdd-enforcer\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"tdd","tdd enforcer","read","design","tests","pattern","implementation","test design","use","coverage","write","workflow","grep","quality","Bash","first","tdd workflow","write tests","test","2026-11-10 10:12:30",false,"---\nname: tdd-enforcer\ndescription: Use when implementing new features. Enforces TDD workflow - write tests FIRST, then implementation. Ensures AAA pattern, proper coverage, and quality test design.\nallowed-tools: Read, Grep, Bash\n---\n\n# TDD Workflow Enforcer\n\n## When to Use\n- Implementing new features\n- Adding functionality\n- Fixing bugs\n- Refactoring code\n\n## TDD Process (MANDATORY)\n\n### 1. Write Tests FIRST (RED Phase)\n- Define behavior through tests\n- Use AAA pattern (Arrange, Act, Assert)\n- Tests MUST fail initially\n- Clear test names describe expected behavior\n\n### 2. Verify Tests Fail (Confirmation)\n- Run tests: `npm test`\n- Confirm failure for the RIGHT reason\n- Test should fail because feature doesn't exist, not because of syntax error\n\n### 3. Write Implementation (GREEN Phase)\n- Write minimal code to pass tests\n- No gold plating or extra features\n- Focus solely on making tests pass\n\n### 4. Verify Tests Pass (Validation)\n- Run tests: `npm test`\n- All new tests must be green\n- All existing tests must still pass\n\n### 5. Refactor (REFACTOR Phase)\n- Improve code quality\n- Remove duplication\n- Enhance readability\n- Tests stay green throughout\n\n## Coverage Requirements\n\n- Overall: 75%+\n- Business Logic (src\u002Fservices\u002F): 90%+\n- Utilities (src\u002Futils\u002F): 90%+\n- UI Components: 60%+\n- E2E tests for critical user flows\n\n## AAA Pattern (Arrange, Act, Assert)\n\n```typescript\ndescribe('AuthService', () => {\n  describe('register', () => {\n    it('should create user with hashed password', async () => {\n      \u002F\u002F ARRANGE: Setup test data\n      const userData = {\n        email: 'test@example.com',\n        password: 'Pass123!',\n      }\n\n      \u002F\u002F ACT: Execute the behavior\n      const result = await authService.register(userData)\n\n      \u002F\u002F ASSERT: Verify outcome\n      expect(result.id).toBeDefined()\n      expect(result.email).toBe(userData.email)\n      expect(result).not.toHaveProperty('password') \u002F\u002F Never return password\n    })\n\n    it('should reject weak passwords', async () => {\n      \u002F\u002F ARRANGE\n      const userData = {\n        email: 'test@example.com',\n        password: '123', \u002F\u002F Too weak\n      }\n\n      \u002F\u002F ACT & ASSERT\n      await expect(authService.register(userData)).rejects.toThrow(\n        'Password must be at least 8 characters'\n      )\n    })\n  })\n})\n```\n\n## Test Structure\n\n### Describe Blocks\n```typescript\n\u002F\u002F ✅ DO: Organize by module\u002Fclass\ndescribe('UserService', () => {\n  \u002F\u002F ✅ DO: Organize by method\n  describe('findById', () => {\n    it('should return user when found', () => {})\n    it('should return null when not found', () => {})\n    it('should throw error for invalid id', () => {})\n  })\n\n  describe('create', () => {\n    it('should create user with valid data', () => {})\n    it('should validate email format', () => {})\n    it('should hash password before saving', () => {})\n  })\n})\n```\n\n### Test Names\n```typescript\n\u002F\u002F ✅ DO: Descriptive test names\nit('should return 400 when email is invalid', () => {})\nit('should hash password with bcrypt before saving', () => {})\nit('should send welcome email after registration', () => {})\n\n\u002F\u002F ❌ DON'T: Vague test names\nit('works', () => {})\nit('test user creation', () => {})\nit('should work correctly', () => {})\n```\n\n## Testing Different Layers\n\n### Unit Tests (Business Logic)\n\n```typescript\n\u002F\u002F src\u002Fservices\u002Fauth.service.test.ts\nimport { AuthService } from '.\u002Fauth.service'\nimport { prismaMock } from '..\u002Ftest\u002Fprisma-mock'\nimport bcrypt from 'bcrypt'\n\ndescribe('AuthService', () => {\n  describe('login', () => {\n    it('should return user and token for valid credentials', async () => {\n      \u002F\u002F ARRANGE\n      const hashedPassword = await bcrypt.hash('password123', 10)\n      const mockUser = {\n        id: '1',\n        email: 'user@test.com',\n        password: hashedPassword,\n      }\n      prismaMock.user.findUnique.mockResolvedValue(mockUser)\n\n      \u002F\u002F ACT\n      const result = await authService.login({\n        email: 'user@test.com',\n        password: 'password123',\n      })\n\n      \u002F\u002F ASSERT\n      expect(result.user.email).toBe('user@test.com')\n      expect(result.token).toBeDefined()\n      expect(result.user).not.toHaveProperty('password')\n    })\n\n    it('should throw error for wrong password', async () => {\n      \u002F\u002F ARRANGE\n      const hashedPassword = await bcrypt.hash('password123', 10)\n      const mockUser = {\n        id: '1',\n        email: 'user@test.com',\n        password: hashedPassword,\n      }\n      prismaMock.user.findUnique.mockResolvedValue(mockUser)\n\n      \u002F\u002F ACT & ASSERT\n      await expect(\n        authService.login({\n          email: 'user@test.com',\n          password: 'wrongpassword',\n        })\n      ).rejects.toThrow('Invalid credentials')\n    })\n  })\n})\n```\n\n### Integration Tests (API Routes)\n\n```typescript\n\u002F\u002F src\u002Fapp\u002Fapi\u002Fauth\u002Fregister\u002Froute.test.ts\nimport { POST } from '.\u002Froute'\n\ndescribe('POST \u002Fapi\u002Fauth\u002Fregister', () => {\n  it('should create user and return 201', async () => {\n    \u002F\u002F ARRANGE\n    const request = new Request('http:\u002F\u002Flocalhost\u002Fapi\u002Fauth\u002Fregister', {\n      method: 'POST',\n      body: JSON.stringify({\n        email: 'newuser@test.com',\n        password: 'SecurePass123!',\n        name: 'Test User',\n      }),\n    })\n\n    \u002F\u002F ACT\n    const response = await POST(request)\n    const data = await response.json()\n\n    \u002F\u002F ASSERT\n    expect(response.status).toBe(201)\n    expect(data.user.email).toBe('newuser@test.com')\n    expect(data.token).toBeDefined()\n    expect(data.user).not.toHaveProperty('password')\n  })\n\n  it('should return 400 for invalid email', async () => {\n    \u002F\u002F ARRANGE\n    const request = new Request('http:\u002F\u002Flocalhost\u002Fapi\u002Fauth\u002Fregister', {\n      method: 'POST',\n      body: JSON.stringify({\n        email: 'invalid-email',\n        password: 'SecurePass123!',\n      }),\n    })\n\n    \u002F\u002F ACT\n    const response = await POST(request)\n    const data = await response.json()\n\n    \u002F\u002F ASSERT\n    expect(response.status).toBe(400)\n    expect(data.error).toContain('email')\n  })\n})\n```\n\n### Component Tests (UI)\n\n```typescript\n\u002F\u002F src\u002Fcomponents\u002FLoginForm.test.tsx\nimport { render, screen, fireEvent, waitFor } from '@testing-library\u002Freact'\nimport { LoginForm } from '.\u002FLoginForm'\n\ndescribe('LoginForm', () => {\n  it('should call onSubmit with email and password', async () => {\n    \u002F\u002F ARRANGE\n    const mockOnSubmit = vi.fn().mockResolvedValue(undefined)\n    render(\u003CLoginForm onSubmit={mockOnSubmit} \u002F>)\n\n    \u002F\u002F ACT\n    fireEvent.change(screen.getByLabelText(\u002Femail\u002Fi), {\n      target: { value: 'user@test.com' },\n    })\n    fireEvent.change(screen.getByLabelText(\u002Fpassword\u002Fi), {\n      target: { value: 'password123' },\n    })\n    fireEvent.click(screen.getByRole('button', { name: \u002Flogin\u002Fi }))\n\n    \u002F\u002F ASSERT\n    await waitFor(() => {\n      expect(mockOnSubmit).toHaveBeenCalledWith({\n        email: 'user@test.com',\n        password: 'password123',\n      })\n    })\n  })\n\n  it('should display error message when login fails', async () => {\n    \u002F\u002F ARRANGE\n    const mockOnSubmit = vi\n      .fn()\n      .mockRejectedValue(new Error('Invalid credentials'))\n    render(\u003CLoginForm onSubmit={mockOnSubmit} \u002F>)\n\n    \u002F\u002F ACT\n    fireEvent.change(screen.getByLabelText(\u002Femail\u002Fi), {\n      target: { value: 'user@test.com' },\n    })\n    fireEvent.change(screen.getByLabelText(\u002Fpassword\u002Fi), {\n      target: { value: 'wrongpassword' },\n    })\n    fireEvent.click(screen.getByRole('button', { name: \u002Flogin\u002Fi }))\n\n    \u002F\u002F ASSERT\n    await waitFor(() => {\n      expect(screen.getByText(\u002Finvalid credentials\u002Fi)).toBeInTheDocument()\n    })\n  })\n\n  it('should disable submit button while loading', async () => {\n    \u002F\u002F ARRANGE\n    const mockOnSubmit = vi\n      .fn()\n      .mockImplementation(() => new Promise(resolve => setTimeout(resolve, 100)))\n    render(\u003CLoginForm onSubmit={mockOnSubmit} \u002F>)\n\n    \u002F\u002F ACT\n    fireEvent.change(screen.getByLabelText(\u002Femail\u002Fi), {\n      target: { value: 'user@test.com' },\n    })\n    fireEvent.change(screen.getByLabelText(\u002Fpassword\u002Fi), {\n      target: { value: 'password123' },\n    })\n    const submitButton = screen.getByRole('button', { name: \u002Flogin\u002Fi })\n    fireEvent.click(submitButton)\n\n    \u002F\u002F ASSERT\n    expect(submitButton).toBeDisabled()\n    await waitFor(() => {\n      expect(submitButton).not.toBeDisabled()\n    })\n  })\n})\n```\n\n### E2E Tests (Critical Flows)\n\n```typescript\n\u002F\u002F tests\u002Fe2e\u002Fauth.spec.ts\nimport { test, expect } from '@playwright\u002Ftest'\n\ntest.describe('Authentication Flow', () => {\n  test('user can register and login', async ({ page }) => {\n    \u002F\u002F ARRANGE\n    const email = `test-${Date.now()}@example.com`\n    const password = 'SecurePass123!'\n\n    \u002F\u002F ACT: Register\n    await page.goto('\u002Fregister')\n    await page.fill('[name=\"email\"]', email)\n    await page.fill('[name=\"password\"]', password)\n    await page.fill('[name=\"confirmPassword\"]', password)\n    await page.click('button[type=\"submit\"]')\n\n    \u002F\u002F ASSERT: Redirected to dashboard\n    await expect(page).toHaveURL('\u002Fdashboard')\n    await expect(page.locator('h1')).toContainText('Dashboard')\n\n    \u002F\u002F ACT: Logout\n    await page.click('[data-testid=\"user-menu\"]')\n    await page.click('text=Logout')\n\n    \u002F\u002F ASSERT: Redirected to login\n    await expect(page).toHaveURL('\u002Flogin')\n\n    \u002F\u002F ACT: Login\n    await page.fill('[name=\"email\"]', email)\n    await page.fill('[name=\"password\"]', password)\n    await page.click('button[type=\"submit\"]')\n\n    \u002F\u002F ASSERT: Back to dashboard\n    await expect(page).toHaveURL('\u002Fdashboard')\n  })\n})\n```\n\n## Test Quality Requirements\n\n### ✅ DO: Test behavior, not implementation\n```typescript\n\u002F\u002F ✅ DO\nit('should display error message when login fails', async () => {\n  \u002F\u002F Test what the user sees\n  await expect(screen.getByText(\u002Finvalid credentials\u002Fi)).toBeInTheDocument()\n})\n\n\u002F\u002F ❌ DON'T\nit('should call setError with \"Invalid credentials\"', async () => {\n  \u002F\u002F Testing implementation detail\n  expect(setError).toHaveBeenCalledWith('Invalid credentials')\n})\n```\n\n### ✅ DO: Test edge cases\n```typescript\nit('should handle empty input', () => {})\nit('should handle very long input (> 1000 chars)', () => {})\nit('should handle special characters in email', () => {})\nit('should handle concurrent requests', () => {})\n```\n\n### ✅ DO: Test error conditions\n```typescript\nit('should handle database connection failure', () => {})\nit('should handle network timeout', () => {})\nit('should handle invalid JSON response', () => {})\n```\n\n### ✅ DO: Use test data builders\n```typescript\n\u002F\u002F Test data builders for cleaner tests\nconst userBuilder = {\n  default: () => ({\n    email: 'test@example.com',\n    password: 'Pass123!',\n    name: 'Test User',\n  }),\n  withEmail: (email: string) => ({\n    ...userBuilder.default(),\n    email,\n  }),\n  withoutName: () => ({\n    email: 'test@example.com',\n    password: 'Pass123!',\n  }),\n}\n\nit('should create user with default data', () => {\n  const user = userBuilder.default()\n  \u002F\u002F ...\n})\n\nit('should create user without name', () => {\n  const user = userBuilder.withoutName()\n  \u002F\u002F ...\n})\n```\n\n## Coverage Verification\n\n```bash\n# Run tests with coverage\nnpm run test:coverage\n\n# Check coverage thresholds\nnpm test -- --coverage --coverageThreshold='{\"global\":{\"lines\":75,\"functions\":75,\"branches\":75}}'\n```\n\n## Common TDD Mistakes\n\n### ❌ DON'T: Write implementation first\n```typescript\n\u002F\u002F Wrong order\n1. Write function\n2. Write tests\n3. Tests pass (or fix tests to pass)\n```\n\n### ✅ DO: Write tests first\n```typescript\n\u002F\u002F Correct order (TDD)\n1. Write test (RED)\n2. Verify test fails\n3. Write minimal implementation (GREEN)\n4. Verify test passes\n5. Refactor (REFACTOR)\n```\n\n### ❌ DON'T: Test implementation details\n```typescript\n\u002F\u002F Bad: Testing internal state\nexpect(component.state.loading).toBe(true)\n\n\u002F\u002F Good: Testing observable behavior\nexpect(screen.getByTestId('spinner')).toBeInTheDocument()\n```\n\n### ❌ DON'T: Write one giant test\n```typescript\n\u002F\u002F Bad: One test does everything\nit('should handle entire user flow', () => {\n  \u002F\u002F 100 lines of test code\n})\n\n\u002F\u002F Good: Split into focused tests\nit('should validate email format', () => {})\nit('should hash password', () => {})\nit('should create user in database', () => {})\nit('should send welcome email', () => {})\n```\n\n## Checklist Before Committing\n\n- [ ] All new features have tests written FIRST\n- [ ] Tests failed initially (RED)\n- [ ] Implementation makes tests pass (GREEN)\n- [ ] Code refactored for quality (REFACTOR)\n- [ ] Coverage thresholds met (75%+ overall, 90%+ business logic)\n- [ ] All tests use AAA pattern\n- [ ] Test names are descriptive\n- [ ] Edge cases tested\n- [ ] Error conditions tested\n- [ ] E2E tests for critical user flows\n","# TDD Workflow Enforcer\n\n## When to Use\n- Implementing new features\n- Adding functionality\n- Fixing bugs\n- Refactoring code\n\n## TDD Process (MANDATORY)\n\n### 1. Write Tests FIRST (RED Phase)\n- Define behavior through tests\n- Use AAA pattern (Arrange, Act, Assert)\n- Tests MUST fail initially\n- Clear test names describe expected behavior\n\n### 2. Verify Tests Fail (Confirmation)\n- Run tests: `npm test`\n- Confirm failure for the RIGHT reason\n- Test should fail because feature doesn't exist, not because of syntax error\n\n### 3. Write Implementation (GREEN Phase)\n- Write minimal code to pass tests\n- No gold plating or extra features\n- Focus solely on making tests pass\n\n### 4. Verify Tests Pass (Validation)\n- Run tests: `npm test`\n- All new tests must be green\n- All existing tests must still pass\n\n### 5. Refactor (REFACTOR Phase)\n- Improve code quality\n- Remove duplication\n- Enhance readability\n- Tests stay green throughout\n\n## Coverage Requirements\n\n- Overall: 75%+\n- Business Logic (src\u002Fservices\u002F): 90%+\n- Utilities (src\u002Futils\u002F): 90%+\n- UI Components: 60%+\n- E2E tests for critical user flows\n\n## AAA Pattern (Arrange, Act, Assert)\n\n```typescript\ndescribe('AuthService', () => {\n  describe('register', () => {\n    it('should create user with hashed password', async () => {\n      \u002F\u002F ARRANGE: Setup test data\n      const userData = {\n        email: 'test@example.com',\n        password: 'Pass123!',\n      }\n\n      \u002F\u002F ACT: Execute the behavior\n      const result = await authService.register(userData)\n\n      \u002F\u002F ASSERT: Verify outcome\n      expect(result.id).toBeDefined()\n      expect(result.email).toBe(userData.email)\n      expect(result).not.toHaveProperty('password') \u002F\u002F Never return password\n    })\n\n    it('should reject weak passwords', async () => {\n      \u002F\u002F ARRANGE\n      const userData = {\n        email: 'test@example.com',\n        password: '123', \u002F\u002F Too weak\n      }\n\n      \u002F\u002F ACT & ASSERT\n      await expect(authService.register(userData)).rejects.toThrow(\n        'Password must be at least 8 characters'\n      )\n    })\n  })\n})\n```\n\n## Test Structure\n\n### Describe Blocks\n```typescript\n\u002F\u002F ✅ DO: Organize by module\u002Fclass\ndescribe('UserService', () => {\n  \u002F\u002F ✅ DO: Organize by method\n  describe('findById', () => {\n    it('should return user when found', () => {})\n    it('should return null when not found', () => {})\n    it('should throw error for invalid id', () => {})\n  })\n\n  describe('create', () => {\n    it('should create user with valid data', () => {})\n    it('should validate email format', () => {})\n    it('should hash password before saving', () => {})\n  })\n})\n```\n\n### Test Names\n```typescript\n\u002F\u002F ✅ DO: Descriptive test names\nit('should return 400 when email is invalid', () => {})\nit('should hash password with bcrypt before saving', () => {})\nit('should send welcome email after registration', () => {})\n\n\u002F\u002F ❌ DON'T: Vague test names\nit('works', () => {})\nit('test user creation', () => {})\nit('should work correctly', () => {})\n```\n\n## Testing Different Layers\n\n### Unit Tests (Business Logic)\n\n```typescript\n\u002F\u002F src\u002Fservices\u002Fauth.service.test.ts\nimport { AuthService } from '.\u002Fauth.service'\nimport { prismaMock } from '..\u002Ftest\u002Fprisma-mock'\nimport bcrypt from 'bcrypt'\n\ndescribe('AuthService', () => {\n  describe('login', () => {\n    it('should return user and token for valid credentials', async () => {\n      \u002F\u002F ARRANGE\n      const hashedPassword = await bcrypt.hash('password123', 10)\n      const mockUser = {\n        id: '1',\n        email: 'user@test.com',\n        password: hashedPassword,\n      }\n      prismaMock.user.findUnique.mockResolvedValue(mockUser)\n\n      \u002F\u002F ACT\n      const result = await authService.login({\n        email: 'user@test.com',\n        password: 'password123',\n      })\n\n      \u002F\u002F ASSERT\n      expect(result.user.email).toBe('user@test.com')\n      expect(result.token).toBeDefined()\n      expect(result.user).not.toHaveProperty('password')\n    })\n\n    it('should throw error for wrong password', async () => {\n      \u002F\u002F ARRANGE\n      const hashedPassword = await bcrypt.hash('password123', 10)\n      const mockUser = {\n        id: '1',\n        email: 'user@test.com',\n        password: hashedPassword,\n      }\n      prismaMock.user.findUnique.mockResolvedValue(mockUser)\n\n      \u002F\u002F ACT & ASSERT\n      await expect(\n        authService.login({\n          email: 'user@test.com',\n          password: 'wrongpassword',\n        })\n      ).rejects.toThrow('Invalid credentials')\n    })\n  })\n})\n```\n\n### Integration Tests (API Routes)\n\n```typescript\n\u002F\u002F src\u002Fapp\u002Fapi\u002Fauth\u002Fregister\u002Froute.test.ts\nimport { POST } from '.\u002Froute'\n\ndescribe('POST \u002Fapi\u002Fauth\u002Fregister', () => {\n  it('should create user and return 201', async () => {\n    \u002F\u002F ARRANGE\n    const request = new Request('http:\u002F\u002Flocalhost\u002Fapi\u002Fauth\u002Fregister', {\n      method: 'POST',\n      body: JSON.stringify({\n        email: 'newuser@test.com',\n        password: 'SecurePass123!',\n        name: 'Test User',\n      }),\n    })\n\n    \u002F\u002F ACT\n    const response = await POST(request)\n    const data = await response.json()\n\n    \u002F\u002F ASSERT\n    expect(response.status).toBe(201)\n    expect(data.user.email).toBe('newuser@test.com')\n    expect(data.token).toBeDefined()\n    expect(data.user).not.toHaveProperty('password')\n  })\n\n  it('should return 400 for invalid email', async () => {\n    \u002F\u002F ARRANGE\n    const request = new Request('http:\u002F\u002Flocalhost\u002Fapi\u002Fauth\u002Fregister', {\n      method: 'POST',\n      body: JSON.stringify({\n        email: 'invalid-email',\n        password: 'SecurePass123!',\n      }),\n    })\n\n    \u002F\u002F ACT\n    const response = await POST(request)\n    const data = await response.json()\n\n    \u002F\u002F ASSERT\n    expect(response.status).toBe(400)\n    expect(data.error).toContain('email')\n  })\n})\n```\n\n### Component Tests (UI)\n\n```typescript\n\u002F\u002F src\u002Fcomponents\u002FLoginForm.test.tsx\nimport { render, screen, fireEvent, waitFor } from '@testing-library\u002Freact'\nimport { LoginForm } from '.\u002FLoginForm'\n\ndescribe('LoginForm', () => {\n  it('should call onSubmit with email and password', async () => {\n    \u002F\u002F ARRANGE\n    const mockOnSubmit = vi.fn().mockResolvedValue(undefined)\n    render(\u003CLoginForm onSubmit={mockOnSubmit} \u002F>)\n\n    \u002F\u002F ACT\n    fireEvent.change(screen.getByLabelText(\u002Femail\u002Fi), {\n      target: { value: 'user@test.com' },\n    })\n    fireEvent.change(screen.getByLabelText(\u002Fpassword\u002Fi), {\n      target: { value: 'password123' },\n    })\n    fireEvent.click(screen.getByRole('button', { name: \u002Flogin\u002Fi }))\n\n    \u002F\u002F ASSERT\n    await waitFor(() => {\n      expect(mockOnSubmit).toHaveBeenCalledWith({\n        email: 'user@test.com',\n        password: 'password123',\n      })\n    })\n  })\n\n  it('should display error message when login fails', async () => {\n    \u002F\u002F ARRANGE\n    const mockOnSubmit = vi\n      .fn()\n      .mockRejectedValue(new Error('Invalid credentials'))\n    render(\u003CLoginForm onSubmit={mockOnSubmit} \u002F>)\n\n    \u002F\u002F ACT\n    fireEvent.change(screen.getByLabelText(\u002Femail\u002Fi), {\n      target: { value: 'user@test.com' },\n    })\n    fireEvent.change(screen.getByLabelText(\u002Fpassword\u002Fi), {\n      target: { value: 'wrongpassword' },\n    })\n    fireEvent.click(screen.getByRole('button', { name: \u002Flogin\u002Fi }))\n\n    \u002F\u002F ASSERT\n    await waitFor(() => {\n      expect(screen.getByText(\u002Finvalid credentials\u002Fi)).toBeInTheDocument()\n    })\n  })\n\n  it('should disable submit button while loading', async () => {\n    \u002F\u002F ARRANGE\n    const mockOnSubmit = vi\n      .fn()\n      .mockImplementation(() => new Promise(resolve => setTimeout(resolve, 100)))\n    render(\u003CLoginForm onSubmit={mockOnSubmit} \u002F>)\n\n    \u002F\u002F ACT\n    fireEvent.change(screen.getByLabelText(\u002Femail\u002Fi), {\n      target: { value: 'user@test.com' },\n    })\n    fireEvent.change(screen.getByLabelText(\u002Fpassword\u002Fi), {\n      target: { value: 'password123' },\n    })\n    const submitButton = screen.getByRole('button', { name: \u002Flogin\u002Fi })\n    fireEvent.click(submitButton)\n\n    \u002F\u002F ASSERT\n    expect(submitButton).toBeDisabled()\n    await waitFor(() => {\n      expect(submitButton).not.toBeDisabled()\n    })\n  })\n})\n```\n\n### E2E Tests (Critical Flows)\n\n```typescript\n\u002F\u002F tests\u002Fe2e\u002Fauth.spec.ts\nimport { test, expect } from '@playwright\u002Ftest'\n\ntest.describe('Authentication Flow', () => {\n  test('user can register and login', async ({ page }) => {\n    \u002F\u002F ARRANGE\n    const email = `test-${Date.now()}@example.com`\n    const password = 'SecurePass123!'\n\n    \u002F\u002F ACT: Register\n    await page.goto('\u002Fregister')\n    await page.fill('[name=\"email\"]', email)\n    await page.fill('[name=\"password\"]', password)\n    await page.fill('[name=\"confirmPassword\"]', password)\n    await page.click('button[type=\"submit\"]')\n\n    \u002F\u002F ASSERT: Redirected to dashboard\n    await expect(page).toHaveURL('\u002Fdashboard')\n    await expect(page.locator('h1')).toContainText('Dashboard')\n\n    \u002F\u002F ACT: Logout\n    await page.click('[data-testid=\"user-menu\"]')\n    await page.click('text=Logout')\n\n    \u002F\u002F ASSERT: Redirected to login\n    await expect(page).toHaveURL('\u002Flogin')\n\n    \u002F\u002F ACT: Login\n    await page.fill('[name=\"email\"]', email)\n    await page.fill('[name=\"password\"]', password)\n    await page.click('button[type=\"submit\"]')\n\n    \u002F\u002F ASSERT: Back to dashboard\n    await expect(page).toHaveURL('\u002Fdashboard')\n  })\n})\n```\n\n## Test Quality Requirements\n\n### ✅ DO: Test behavior, not implementation\n```typescript\n\u002F\u002F ✅ DO\nit('should display error message when login fails', async () => {\n  \u002F\u002F Test what the user sees\n  await expect(screen.getByText(\u002Finvalid credentials\u002Fi)).toBeInTheDocument()\n})\n\n\u002F\u002F ❌ DON'T\nit('should call setError with \"Invalid credentials\"', async () => {\n  \u002F\u002F Testing implementation detail\n  expect(setError).toHaveBeenCalledWith('Invalid credentials')\n})\n```\n\n### ✅ DO: Test edge cases\n```typescript\nit('should handle empty input', () => {})\nit('should handle very long input (> 1000 chars)', () => {})\nit('should handle special characters in email', () => {})\nit('should handle concurrent requests', () => {})\n```\n\n### ✅ DO: Test error conditions\n```typescript\nit('should handle database connection failure', () => {})\nit('should handle network timeout', () => {})\nit('should handle invalid JSON response', () => {})\n```\n\n### ✅ DO: Use test data builders\n```typescript\n\u002F\u002F Test data builders for cleaner tests\nconst userBuilder = {\n  default: () => ({\n    email: 'test@example.com',\n    password: 'Pass123!',\n    name: 'Test User',\n  }),\n  withEmail: (email: string) => ({\n    ...userBuilder.default(),\n    email,\n  }),\n  withoutName: () => ({\n    email: 'test@example.com',\n    password: 'Pass123!',\n  }),\n}\n\nit('should create user with default data', () => {\n  const user = userBuilder.default()\n  \u002F\u002F ...\n})\n\nit('should create user without name', () => {\n  const user = userBuilder.withoutName()\n  \u002F\u002F ...\n})\n```\n\n## Coverage Verification\n\n```bash\n# Run tests with coverage\nnpm run test:coverage\n\n# Check coverage thresholds\nnpm test -- --coverage --coverageThreshold='{\"global\":{\"lines\":75,\"functions\":75,\"branches\":75}}'\n```\n\n## Common TDD Mistakes\n\n### ❌ DON'T: Write implementation first\n```typescript\n\u002F\u002F Wrong order\n1. Write function\n2. Write tests\n3. Tests pass (or fix tests to pass)\n```\n\n### ✅ DO: Write tests first\n```typescript\n\u002F\u002F Correct order (TDD)\n1. Write test (RED)\n2. Verify test fails\n3. Write minimal implementation (GREEN)\n4. Verify test passes\n5. Refactor (REFACTOR)\n```\n\n### ❌ DON'T: Test implementation details\n```typescript\n\u002F\u002F Bad: Testing internal state\nexpect(component.state.loading).toBe(true)\n\n\u002F\u002F Good: Testing observable behavior\nexpect(screen.getByTestId('spinner')).toBeInTheDocument()\n```\n\n### ❌ DON'T: Write one giant test\n```typescript\n\u002F\u002F Bad: One test does everything\nit('should handle entire user flow', () => {\n  \u002F\u002F 100 lines of test code\n})\n\n\u002F\u002F Good: Split into focused tests\nit('should validate email format', () => {})\nit('should hash password', () => {})\nit('should create user in database', () => {})\nit('should send welcome email', () => {})\n```\n\n## Checklist Before Committing\n\n- [ ] All new features have tests written FIRST\n- [ ] Tests failed initially (RED)\n- [ ] Implementation makes tests pass (GREEN)\n- [ ] Code refactored for quality (REFACTOR)\n- [ ] Coverage thresholds met (75%+ overall, 90%+ business logic)\n- [ ] All tests use AAA pattern\n- [ ] Test names are descriptive\n- [ ] Edge cases tested\n- [ ] Error conditions tested\n- [ ] E2E tests for critical user flows\n",{"name":5,"description":7,"allowed-tools":43},"Read, Grep, Bash","main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002Faiskillstore\u002Fmarketplace\u002Fbarnhardt-enterprises-inc\u002Ftdd-enforcer",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":8,"skillName":5,"commands":54,"prompt":64,"zipAvailable":65},[55,58,61],{"tool":56,"command":57},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill tdd-enforcer",{"tool":59,"command":60},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill tdd-enforcer",{"tool":62,"command":63},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill tdd-enforcer","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Fbarnhardt-enterprises-inc\u002Ftdd-enforcer\u002FSKILL.md",true,[67,73],{"path":68,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":71,"sourceHtmlUrl":72},"references\u002Fpatterns.md","REFERENCE","参考文档",6806,"https:\u002F\u002Fgithub.com\u002FTorchiaHub\u002FSkills\u002Fblob\u002Fmaster\u002F01-Inbox\u002Fdownloads\u002Fgithub-awesome-copilot\u002F20260429T115304Z\u002Fsource\u002Fskills\u002Freact18-string-refs\u002Freferences\u002Fpatterns.md",{"path":74,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":75,"sourceHtmlUrl":76},"skill-report.json",13147,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Fbarnhardt-enterprises-inc\u002Ftdd-enforcer\u002Fskill-report.json",[78,87,96,105,111,117],{"skillNo":79,"name":80,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":38},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[],[84,85,86],"model","model hierarchy","model hierarchy skill",{"skillNo":88,"name":89,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":38},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[],[93,94,95],"MCP","zoom","zoom mcp",{"skillNo":97,"name":98,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":38},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[102,103,104,94],"sdk","zoom apps sdk","apps",{"skillNo":106,"name":107,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":38},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[107],{"skillNo":112,"name":113,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":38},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[],[113],{"skillNo":118,"name":119,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":120,"categories":121,"keywords":122,"publishedAt":38},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[119]]