[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7FC5V35CEW7HZXBE5R0PM6B":3,"skill-same:01M7FC5V35CEW7HZXBE5R0PM6B":51},{"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":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":29,"updatedAt":30,"install":31,"resources":44},"01M7FC5V35CEW7HZXBE5R0PM6B","tdd-workflow",null,"Use this skill when writing new features, fixing bugs, or refactoring code. Enforces test-driven development with 80%+ coverage including unit, integration, and E2E tests.","shaikhsarib\u002FDeep","shaikhsarib","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F187104861?v=4","01M7FBPVVHJVH9BRXCMHQ8VJH3","Shaikh Sarib Umer","01M7FBPVW3WGBVSZBRH0ACF278",0,"MIT","https:\u002F\u002Fgithub.com\u002Fshaikhsarib\u002FDeep\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fecc\u002Fupstream\u002F.agents\u002Fskills\u002Ftdd-workflow\u002FSKILL.md",[],[],"2026-11-16 10:05:34",false,"---\nname: tdd-workflow\ndescription: Use this skill when writing new features, fixing bugs, or refactoring code. Enforces test-driven development with 80%+ coverage including unit, integration, and E2E tests.\nlicense: MIT\n---\n\n# Test-Driven Development Workflow\n\nThis skill ensures all code development follows TDD principles with comprehensive test coverage.\n\n## When to Activate\n\n- Writing new features or functionality\n- Fixing bugs or issues\n- Refactoring existing code\n- Adding API endpoints\n- Creating new components\n\n## Core Principles\n\n### 1. Tests BEFORE Code\nALWAYS write tests first, then implement code to make tests pass.\n\n### 2. Coverage Requirements\n- Minimum 80% coverage (unit + integration + E2E)\n- All edge cases covered\n- Error scenarios tested\n- Boundary conditions verified\n\n### 3. Test Types\n\n#### Unit Tests\n- Individual functions and utilities\n- Component logic\n- Pure functions\n- Helpers and utilities\n\n#### Integration Tests\n- API endpoints\n- Database operations\n- Service interactions\n- External API calls\n\n#### E2E Tests (Playwright)\n- Critical user flows\n- Complete workflows\n- Browser automation\n- UI interactions\n\n## TDD Workflow Steps\n\n### Step 0: Detect the Test Runner\n\nDo not assume `npm test`. The commands in the steps and examples below use `\u003Ctest>`, `\u003Ctest-watch>`, and `\u003Ccoverage>` as placeholders for the project's actual runner. Resolve them once before starting:\n\n1. **Run the package-manager detector** (ships with ECC):\n\n   ```bash\n   node scripts\u002Fsetup-package-manager.js --detect\n   ```\n\n   It resolves the package manager (npm \u002F pnpm \u002F yarn \u002F bun) from, in order: `CLAUDE_PACKAGE_MANAGER`, `.claude\u002Fpackage-manager.json`, the `package.json` `packageManager` field, the lockfile, then global config.\n\n2. **Distinguish the package manager from the test runner — they are not the same.** A project can use Bun to install dependencies yet still run Jest or Vitest. Inspect `package.json` `scripts.test` and the test files:\n   - `scripts.test` invokes `jest` \u002F `vitest` -> run through the detected PM (`npm test`, `pnpm test`, `yarn test`, or `bun run test`).\n   - `scripts.test` is `bun test`, or test files `import { test, expect } from \"bun:test\"`, or there is no jest\u002Fvitest config but Bun is present -> use **Bun's native runner** (`bun test`). See [Bun Native Test Pattern](#bun-native-test-pattern-buntest) below.\n\nRunner command matrix:\n\n| Runner | `\u003Ctest>` | `\u003Ctest-watch>` | `\u003Ccoverage>` | `\u003Clint>` |\n|--------|----------|----------------|--------------|----------|\n| npm | `npm test` | `npm test -- --watch` | `npm run test:coverage` | `npm run lint` |\n| pnpm | `pnpm test` | `pnpm test --watch` | `pnpm test:coverage` | `pnpm lint` |\n| yarn | `yarn test` | `yarn test --watch` | `yarn test:coverage` | `yarn lint` |\n| Bun (script runs jest\u002Fvitest) | `bun run test` | `bun run test --watch` | `bun run test:coverage` | `bun run lint` |\n| Bun (native `bun:test`) | `bun test` | `bun test --watch` | `bun test --coverage` | `bun run lint` |\n\n> `bun test` (Bun's built-in runner) is **not** the same as `bun run test` (which runs the `package.json` `test` script). Picking the wrong one is a common failure — e.g. invoking Jest through `npx`\u002F`bun run` in an ESM-only project breaks, while `bun test` runs the suite natively. Confirm which the project expects before the RED gate, then substitute `\u003Ctest>` \u002F `\u003Ccoverage>` everywhere `npm test` appears below.\n\n### Step 1: Write User Journeys\n```\nAs a [role], I want to [action], so that [benefit]\n\nExample:\nAs a user, I want to search for markets semantically,\nso that I can find relevant markets even without exact keywords.\n```\n\n### Step 2: Generate Test Cases\nFor each user journey, create comprehensive test cases:\n\n```typescript\ndescribe('Semantic Search', () => {\n  it('returns relevant markets for query', async () => {\n    \u002F\u002F Test implementation\n  })\n\n  it('handles empty query gracefully', async () => {\n    \u002F\u002F Test edge case\n  })\n\n  it('falls back to substring search when Redis unavailable', async () => {\n    \u002F\u002F Test fallback behavior\n  })\n\n  it('sorts results by similarity score', async () => {\n    \u002F\u002F Test sorting logic\n  })\n})\n```\n\n### Step 3: Run Tests (They Should Fail)\n```bash\n\u003Ctest>\n# Tests should fail - we haven't implemented yet\n```\n\n### Step 4: Implement Code\nWrite minimal code to make tests pass:\n\n```typescript\n\u002F\u002F Implementation guided by tests\nexport async function searchMarkets(query: string) {\n  \u002F\u002F Implementation here\n}\n```\n\n### Step 5: Run Tests Again\n```bash\n\u003Ctest>\n# Tests should now pass\n```\n\n### Step 6: Refactor\nImprove code quality while keeping tests green:\n- Remove duplication\n- Improve naming\n- Optimize performance\n- Enhance readability\n\n### Step 7: Verify Coverage\n```bash\n\u003Ccoverage>\n# Verify 80%+ coverage achieved\n```\n\n## Testing Patterns\n\n### Unit Test Pattern (Jest\u002FVitest)\n```typescript\nimport { render, screen, fireEvent } from '@testing-library\u002Freact'\nimport { Button } from '.\u002FButton'\n\ndescribe('Button Component', () => {\n  it('renders with correct text', () => {\n    render(\u003CButton>Click me\u003C\u002FButton>)\n    expect(screen.getByText('Click me')).toBeInTheDocument()\n  })\n\n  it('calls onClick when clicked', () => {\n    const handleClick = jest.fn()\n    render(\u003CButton onClick={handleClick}>Click\u003C\u002FButton>)\n\n    fireEvent.click(screen.getByRole('button'))\n\n    expect(handleClick).toHaveBeenCalledTimes(1)\n  })\n\n  it('is disabled when disabled prop is true', () => {\n    render(\u003CButton disabled>Click\u003C\u002FButton>)\n    expect(screen.getByRole('button')).toBeDisabled()\n  })\n})\n```\n\n### Bun Native Test Pattern (`bun:test`)\n\nWhen the project uses Bun's built-in runner (see [Step 0](#step-0-detect-the-test-runner)), import from `bun:test` and run with `bun test` — not `bun run test`. The API is Jest-like, so `describe` \u002F `it` \u002F `expect` and most matchers carry over. See the `bun-runtime` skill for runtime, install, and bundler details.\n\n```typescript\nimport { describe, it, expect, mock } from 'bun:test'\nimport { searchMarkets } from '.\u002Fsearch'\n\ndescribe('searchMarkets', () => {\n  it('returns an empty list for an empty query', async () => {\n    expect(await searchMarkets('')).toEqual([])\n  })\n\n  it('sorts results by similarity score', async () => {\n    const results = await searchMarkets('election')\n    expect(results).toEqual([...results].sort((a, b) => b.score - a.score))\n  })\n})\n```\n\n```bash\nbun test              # run once (RED\u002FGREEN gate)\nbun test --watch      # watch mode during development\nbun test --coverage   # coverage report\n```\n\n- Mock modules with `mock.module(...)` \u002F `mock(...)` from `bun:test` instead of `jest.mock(...)`.\n- Configure coverage thresholds in `bunfig.toml` under `[test]` (e.g. `coverageThreshold`) rather than the Jest `coverageThresholds` config block.\n\n### API Integration Test Pattern\n```typescript\nimport { NextRequest } from 'next\u002Fserver'\nimport { GET } from '.\u002Froute'\n\ndescribe('GET \u002Fapi\u002Fmarkets', () => {\n  it('returns markets successfully', async () => {\n    const request = new NextRequest('http:\u002F\u002Flocalhost\u002Fapi\u002Fmarkets')\n    const response = await GET(request)\n    const data = await response.json()\n\n    expect(response.status).toBe(200)\n    expect(data.success).toBe(true)\n    expect(Array.isArray(data.data)).toBe(true)\n  })\n\n  it('validates query parameters', async () => {\n    const request = new NextRequest('http:\u002F\u002Flocalhost\u002Fapi\u002Fmarkets?limit=invalid')\n    const response = await GET(request)\n\n    expect(response.status).toBe(400)\n  })\n\n  it('handles database errors gracefully', async () => {\n    \u002F\u002F Mock database failure\n    const request = new NextRequest('http:\u002F\u002Flocalhost\u002Fapi\u002Fmarkets')\n    \u002F\u002F Test error handling\n  })\n})\n```\n\n### E2E Test Pattern (Playwright)\n```typescript\nimport { test, expect } from '@playwright\u002Ftest'\n\ntest('user can search and filter markets', async ({ page }) => {\n  \u002F\u002F Navigate to markets page\n  await page.goto('\u002F')\n  await page.click('a[href=\"\u002Fmarkets\"]')\n\n  \u002F\u002F Verify page loaded\n  await expect(page.locator('h1')).toContainText('Markets')\n\n  \u002F\u002F Search for markets\n  await page.fill('input[placeholder=\"Search markets\"]', 'election')\n\n  \u002F\u002F Wait for debounce and results\n  await page.waitForTimeout(600)\n\n  \u002F\u002F Verify search results displayed\n  const results = page.locator('[data-testid=\"market-card\"]')\n  await expect(results).toHaveCount(5, { timeout: 5000 })\n\n  \u002F\u002F Verify results contain search term\n  const firstResult = results.first()\n  await expect(firstResult).toContainText('election', { ignoreCase: true })\n\n  \u002F\u002F Filter by status\n  await page.click('button:has-text(\"Active\")')\n\n  \u002F\u002F Verify filtered results\n  await expect(results).toHaveCount(3)\n})\n\ntest('user can create a new market', async ({ page }) => {\n  \u002F\u002F Login first\n  await page.goto('\u002Fcreator-dashboard')\n\n  \u002F\u002F Fill market creation form\n  await page.fill('input[name=\"name\"]', 'Test Market')\n  await page.fill('textarea[name=\"description\"]', 'Test description')\n  await page.fill('input[name=\"endDate\"]', '2025-12-31')\n\n  \u002F\u002F Submit form\n  await page.click('button[type=\"submit\"]')\n\n  \u002F\u002F Verify success message\n  await expect(page.locator('text=Market created successfully')).toBeVisible()\n\n  \u002F\u002F Verify redirect to market page\n  await expect(page).toHaveURL(\u002F\\\u002Fmarkets\\\u002Ftest-market\u002F)\n})\n```\n\n## Test File Organization\n\n```\nsrc\u002F\n├── components\u002F\n│   ├── Button\u002F\n│   │   ├── Button.tsx\n│   │   ├── Button.test.tsx          # Unit tests\n│   │   └── Button.stories.tsx       # Storybook\n│   └── MarketCard\u002F\n│       ├── MarketCard.tsx\n│       └── MarketCard.test.tsx\n├── app\u002F\n│   └── api\u002F\n│       └── markets\u002F\n│           ├── route.ts\n│           └── route.test.ts         # Integration tests\n└── e2e\u002F\n    ├── markets.spec.ts               # E2E tests\n    ├── trading.spec.ts\n    └── auth.spec.ts\n```\n\n## Mocking External Services\n\n### Supabase Mock\n```typescript\njest.mock('@\u002Flib\u002Fsupabase', () => ({\n  supabase: {\n    from: jest.fn(() => ({\n      select: jest.fn(() => ({\n        eq: jest.fn(() => Promise.resolve({\n          data: [{ id: 1, name: 'Test Market' }],\n          error: null\n        }))\n      }))\n    }))\n  }\n}))\n```\n\n### Redis Mock\n```typescript\njest.mock('@\u002Flib\u002Fredis', () => ({\n  searchMarketsByVector: jest.fn(() => Promise.resolve([\n    { slug: 'test-market', similarity_score: 0.95 }\n  ])),\n  checkRedisHealth: jest.fn(() => Promise.resolve({ connected: true }))\n}))\n```\n\n### OpenAI Mock\n```typescript\njest.mock('@\u002Flib\u002Fopenai', () => ({\n  generateEmbedding: jest.fn(() => Promise.resolve(\n    new Array(1536).fill(0.1) \u002F\u002F Mock 1536-dim embedding\n  ))\n}))\n```\n\n## Test Coverage Verification\n\n### Run Coverage Report\n```bash\n\u003Ccoverage>\n```\n\n### Coverage Thresholds\n```json\n{\n  \"jest\": {\n    \"coverageThresholds\": {\n      \"global\": {\n        \"branches\": 80,\n        \"functions\": 80,\n        \"lines\": 80,\n        \"statements\": 80\n      }\n    }\n  }\n}\n```\n\n## Common Testing Mistakes to Avoid\n\n### FAIL: WRONG: Testing Implementation Details\n```typescript\n\u002F\u002F Don't test internal state\nexpect(component.state.count).toBe(5)\n```\n\n### PASS: CORRECT: Test User-Visible Behavior\n```typescript\n\u002F\u002F Test what users see\nexpect(screen.getByText('Count: 5')).toBeInTheDocument()\n```\n\n### FAIL: WRONG: Brittle Selectors\n```typescript\n\u002F\u002F Breaks easily\nawait page.click('.css-class-xyz')\n```\n\n### PASS: CORRECT: Semantic Selectors\n```typescript\n\u002F\u002F Resilient to changes\nawait page.click('button:has-text(\"Submit\")')\nawait page.click('[data-testid=\"submit-button\"]')\n```\n\n### FAIL: WRONG: No Test Isolation\n```typescript\n\u002F\u002F Tests depend on each other\ntest('creates user', () => { \u002F* ... *\u002F })\ntest('updates same user', () => { \u002F* depends on previous test *\u002F })\n```\n\n### PASS: CORRECT: Independent Tests\n```typescript\n\u002F\u002F Each test sets up its own data\ntest('creates user', () => {\n  const user = createTestUser()\n  \u002F\u002F Test logic\n})\n\ntest('updates user', () => {\n  const user = createTestUser()\n  \u002F\u002F Update logic\n})\n```\n\n## Continuous Testing\n\n### Watch Mode During Development\n```bash\n\u003Ctest-watch>\n# Tests run automatically on file changes\n```\n\n### Pre-Commit Hook\n```bash\n# Runs before every commit\n\u003Ctest> && \u003Clint>\n```\n\n### CI\u002FCD Integration\n```yaml\n# GitHub Actions\n- name: Run Tests\n  run: \u003Ccoverage>\n- name: Upload Coverage\n  uses: codecov\u002Fcodecov-action@v3\n```\n\n## Best Practices\n\n1. **Write Tests First** - Always TDD\n2. **One Assert Per Test** - Focus on single behavior\n3. **Descriptive Test Names** - Explain what's tested\n4. **Arrange-Act-Assert** - Clear test structure\n5. **Mock External Dependencies** - Isolate unit tests\n6. **Test Edge Cases** - Null, undefined, empty, large\n7. **Test Error Paths** - Not just happy paths\n8. **Keep Tests Fast** - Unit tests \u003C 50ms each\n9. **Clean Up After Tests** - No side effects\n10. **Review Coverage Reports** - Identify gaps\n\n## Success Metrics\n\n- 80%+ code coverage achieved\n- All tests passing (green)\n- No skipped or disabled tests\n- Fast test execution (\u003C 30s for unit tests)\n- E2E tests cover critical user flows\n- Tests catch bugs before production\n\n---\n\n**Remember**: Tests are not optional. They are the safety net that enables confident refactoring, rapid development, and production reliability.\n","# Test-Driven Development Workflow\n\nThis skill ensures all code development follows TDD principles with comprehensive test coverage.\n\n## When to Activate\n\n- Writing new features or functionality\n- Fixing bugs or issues\n- Refactoring existing code\n- Adding API endpoints\n- Creating new components\n\n## Core Principles\n\n### 1. Tests BEFORE Code\nALWAYS write tests first, then implement code to make tests pass.\n\n### 2. Coverage Requirements\n- Minimum 80% coverage (unit + integration + E2E)\n- All edge cases covered\n- Error scenarios tested\n- Boundary conditions verified\n\n### 3. Test Types\n\n#### Unit Tests\n- Individual functions and utilities\n- Component logic\n- Pure functions\n- Helpers and utilities\n\n#### Integration Tests\n- API endpoints\n- Database operations\n- Service interactions\n- External API calls\n\n#### E2E Tests (Playwright)\n- Critical user flows\n- Complete workflows\n- Browser automation\n- UI interactions\n\n## TDD Workflow Steps\n\n### Step 0: Detect the Test Runner\n\nDo not assume `npm test`. The commands in the steps and examples below use `\u003Ctest>`, `\u003Ctest-watch>`, and `\u003Ccoverage>` as placeholders for the project's actual runner. Resolve them once before starting:\n\n1. **Run the package-manager detector** (ships with ECC):\n\n   ```bash\n   node scripts\u002Fsetup-package-manager.js --detect\n   ```\n\n   It resolves the package manager (npm \u002F pnpm \u002F yarn \u002F bun) from, in order: `CLAUDE_PACKAGE_MANAGER`, `.claude\u002Fpackage-manager.json`, the `package.json` `packageManager` field, the lockfile, then global config.\n\n2. **Distinguish the package manager from the test runner — they are not the same.** A project can use Bun to install dependencies yet still run Jest or Vitest. Inspect `package.json` `scripts.test` and the test files:\n   - `scripts.test` invokes `jest` \u002F `vitest` -> run through the detected PM (`npm test`, `pnpm test`, `yarn test`, or `bun run test`).\n   - `scripts.test` is `bun test`, or test files `import { test, expect } from \"bun:test\"`, or there is no jest\u002Fvitest config but Bun is present -> use **Bun's native runner** (`bun test`). See [Bun Native Test Pattern](#bun-native-test-pattern-buntest) below.\n\nRunner command matrix:\n\n| Runner | `\u003Ctest>` | `\u003Ctest-watch>` | `\u003Ccoverage>` | `\u003Clint>` |\n|--------|----------|----------------|--------------|----------|\n| npm | `npm test` | `npm test -- --watch` | `npm run test:coverage` | `npm run lint` |\n| pnpm | `pnpm test` | `pnpm test --watch` | `pnpm test:coverage` | `pnpm lint` |\n| yarn | `yarn test` | `yarn test --watch` | `yarn test:coverage` | `yarn lint` |\n| Bun (script runs jest\u002Fvitest) | `bun run test` | `bun run test --watch` | `bun run test:coverage` | `bun run lint` |\n| Bun (native `bun:test`) | `bun test` | `bun test --watch` | `bun test --coverage` | `bun run lint` |\n\n> `bun test` (Bun's built-in runner) is **not** the same as `bun run test` (which runs the `package.json` `test` script). Picking the wrong one is a common failure — e.g. invoking Jest through `npx`\u002F`bun run` in an ESM-only project breaks, while `bun test` runs the suite natively. Confirm which the project expects before the RED gate, then substitute `\u003Ctest>` \u002F `\u003Ccoverage>` everywhere `npm test` appears below.\n\n### Step 1: Write User Journeys\n```\nAs a [role], I want to [action], so that [benefit]\n\nExample:\nAs a user, I want to search for markets semantically,\nso that I can find relevant markets even without exact keywords.\n```\n\n### Step 2: Generate Test Cases\nFor each user journey, create comprehensive test cases:\n\n```typescript\ndescribe('Semantic Search', () => {\n  it('returns relevant markets for query', async () => {\n    \u002F\u002F Test implementation\n  })\n\n  it('handles empty query gracefully', async () => {\n    \u002F\u002F Test edge case\n  })\n\n  it('falls back to substring search when Redis unavailable', async () => {\n    \u002F\u002F Test fallback behavior\n  })\n\n  it('sorts results by similarity score', async () => {\n    \u002F\u002F Test sorting logic\n  })\n})\n```\n\n### Step 3: Run Tests (They Should Fail)\n```bash\n\u003Ctest>\n# Tests should fail - we haven't implemented yet\n```\n\n### Step 4: Implement Code\nWrite minimal code to make tests pass:\n\n```typescript\n\u002F\u002F Implementation guided by tests\nexport async function searchMarkets(query: string) {\n  \u002F\u002F Implementation here\n}\n```\n\n### Step 5: Run Tests Again\n```bash\n\u003Ctest>\n# Tests should now pass\n```\n\n### Step 6: Refactor\nImprove code quality while keeping tests green:\n- Remove duplication\n- Improve naming\n- Optimize performance\n- Enhance readability\n\n### Step 7: Verify Coverage\n```bash\n\u003Ccoverage>\n# Verify 80%+ coverage achieved\n```\n\n## Testing Patterns\n\n### Unit Test Pattern (Jest\u002FVitest)\n```typescript\nimport { render, screen, fireEvent } from '@testing-library\u002Freact'\nimport { Button } from '.\u002FButton'\n\ndescribe('Button Component', () => {\n  it('renders with correct text', () => {\n    render(\u003CButton>Click me\u003C\u002FButton>)\n    expect(screen.getByText('Click me')).toBeInTheDocument()\n  })\n\n  it('calls onClick when clicked', () => {\n    const handleClick = jest.fn()\n    render(\u003CButton onClick={handleClick}>Click\u003C\u002FButton>)\n\n    fireEvent.click(screen.getByRole('button'))\n\n    expect(handleClick).toHaveBeenCalledTimes(1)\n  })\n\n  it('is disabled when disabled prop is true', () => {\n    render(\u003CButton disabled>Click\u003C\u002FButton>)\n    expect(screen.getByRole('button')).toBeDisabled()\n  })\n})\n```\n\n### Bun Native Test Pattern (`bun:test`)\n\nWhen the project uses Bun's built-in runner (see [Step 0](#step-0-detect-the-test-runner)), import from `bun:test` and run with `bun test` — not `bun run test`. The API is Jest-like, so `describe` \u002F `it` \u002F `expect` and most matchers carry over. See the `bun-runtime` skill for runtime, install, and bundler details.\n\n```typescript\nimport { describe, it, expect, mock } from 'bun:test'\nimport { searchMarkets } from '.\u002Fsearch'\n\ndescribe('searchMarkets', () => {\n  it('returns an empty list for an empty query', async () => {\n    expect(await searchMarkets('')).toEqual([])\n  })\n\n  it('sorts results by similarity score', async () => {\n    const results = await searchMarkets('election')\n    expect(results).toEqual([...results].sort((a, b) => b.score - a.score))\n  })\n})\n```\n\n```bash\nbun test              # run once (RED\u002FGREEN gate)\nbun test --watch      # watch mode during development\nbun test --coverage   # coverage report\n```\n\n- Mock modules with `mock.module(...)` \u002F `mock(...)` from `bun:test` instead of `jest.mock(...)`.\n- Configure coverage thresholds in `bunfig.toml` under `[test]` (e.g. `coverageThreshold`) rather than the Jest `coverageThresholds` config block.\n\n### API Integration Test Pattern\n```typescript\nimport { NextRequest } from 'next\u002Fserver'\nimport { GET } from '.\u002Froute'\n\ndescribe('GET \u002Fapi\u002Fmarkets', () => {\n  it('returns markets successfully', async () => {\n    const request = new NextRequest('http:\u002F\u002Flocalhost\u002Fapi\u002Fmarkets')\n    const response = await GET(request)\n    const data = await response.json()\n\n    expect(response.status).toBe(200)\n    expect(data.success).toBe(true)\n    expect(Array.isArray(data.data)).toBe(true)\n  })\n\n  it('validates query parameters', async () => {\n    const request = new NextRequest('http:\u002F\u002Flocalhost\u002Fapi\u002Fmarkets?limit=invalid')\n    const response = await GET(request)\n\n    expect(response.status).toBe(400)\n  })\n\n  it('handles database errors gracefully', async () => {\n    \u002F\u002F Mock database failure\n    const request = new NextRequest('http:\u002F\u002Flocalhost\u002Fapi\u002Fmarkets')\n    \u002F\u002F Test error handling\n  })\n})\n```\n\n### E2E Test Pattern (Playwright)\n```typescript\nimport { test, expect } from '@playwright\u002Ftest'\n\ntest('user can search and filter markets', async ({ page }) => {\n  \u002F\u002F Navigate to markets page\n  await page.goto('\u002F')\n  await page.click('a[href=\"\u002Fmarkets\"]')\n\n  \u002F\u002F Verify page loaded\n  await expect(page.locator('h1')).toContainText('Markets')\n\n  \u002F\u002F Search for markets\n  await page.fill('input[placeholder=\"Search markets\"]', 'election')\n\n  \u002F\u002F Wait for debounce and results\n  await page.waitForTimeout(600)\n\n  \u002F\u002F Verify search results displayed\n  const results = page.locator('[data-testid=\"market-card\"]')\n  await expect(results).toHaveCount(5, { timeout: 5000 })\n\n  \u002F\u002F Verify results contain search term\n  const firstResult = results.first()\n  await expect(firstResult).toContainText('election', { ignoreCase: true })\n\n  \u002F\u002F Filter by status\n  await page.click('button:has-text(\"Active\")')\n\n  \u002F\u002F Verify filtered results\n  await expect(results).toHaveCount(3)\n})\n\ntest('user can create a new market', async ({ page }) => {\n  \u002F\u002F Login first\n  await page.goto('\u002Fcreator-dashboard')\n\n  \u002F\u002F Fill market creation form\n  await page.fill('input[name=\"name\"]', 'Test Market')\n  await page.fill('textarea[name=\"description\"]', 'Test description')\n  await page.fill('input[name=\"endDate\"]', '2025-12-31')\n\n  \u002F\u002F Submit form\n  await page.click('button[type=\"submit\"]')\n\n  \u002F\u002F Verify success message\n  await expect(page.locator('text=Market created successfully')).toBeVisible()\n\n  \u002F\u002F Verify redirect to market page\n  await expect(page).toHaveURL(\u002F\\\u002Fmarkets\\\u002Ftest-market\u002F)\n})\n```\n\n## Test File Organization\n\n```\nsrc\u002F\n├── components\u002F\n│   ├── Button\u002F\n│   │   ├── Button.tsx\n│   │   ├── Button.test.tsx          # Unit tests\n│   │   └── Button.stories.tsx       # Storybook\n│   └── MarketCard\u002F\n│       ├── MarketCard.tsx\n│       └── MarketCard.test.tsx\n├── app\u002F\n│   └── api\u002F\n│       └── markets\u002F\n│           ├── route.ts\n│           └── route.test.ts         # Integration tests\n└── e2e\u002F\n    ├── markets.spec.ts               # E2E tests\n    ├── trading.spec.ts\n    └── auth.spec.ts\n```\n\n## Mocking External Services\n\n### Supabase Mock\n```typescript\njest.mock('@\u002Flib\u002Fsupabase', () => ({\n  supabase: {\n    from: jest.fn(() => ({\n      select: jest.fn(() => ({\n        eq: jest.fn(() => Promise.resolve({\n          data: [{ id: 1, name: 'Test Market' }],\n          error: null\n        }))\n      }))\n    }))\n  }\n}))\n```\n\n### Redis Mock\n```typescript\njest.mock('@\u002Flib\u002Fredis', () => ({\n  searchMarketsByVector: jest.fn(() => Promise.resolve([\n    { slug: 'test-market', similarity_score: 0.95 }\n  ])),\n  checkRedisHealth: jest.fn(() => Promise.resolve({ connected: true }))\n}))\n```\n\n### OpenAI Mock\n```typescript\njest.mock('@\u002Flib\u002Fopenai', () => ({\n  generateEmbedding: jest.fn(() => Promise.resolve(\n    new Array(1536).fill(0.1) \u002F\u002F Mock 1536-dim embedding\n  ))\n}))\n```\n\n## Test Coverage Verification\n\n### Run Coverage Report\n```bash\n\u003Ccoverage>\n```\n\n### Coverage Thresholds\n```json\n{\n  \"jest\": {\n    \"coverageThresholds\": {\n      \"global\": {\n        \"branches\": 80,\n        \"functions\": 80,\n        \"lines\": 80,\n        \"statements\": 80\n      }\n    }\n  }\n}\n```\n\n## Common Testing Mistakes to Avoid\n\n### FAIL: WRONG: Testing Implementation Details\n```typescript\n\u002F\u002F Don't test internal state\nexpect(component.state.count).toBe(5)\n```\n\n### PASS: CORRECT: Test User-Visible Behavior\n```typescript\n\u002F\u002F Test what users see\nexpect(screen.getByText('Count: 5')).toBeInTheDocument()\n```\n\n### FAIL: WRONG: Brittle Selectors\n```typescript\n\u002F\u002F Breaks easily\nawait page.click('.css-class-xyz')\n```\n\n### PASS: CORRECT: Semantic Selectors\n```typescript\n\u002F\u002F Resilient to changes\nawait page.click('button:has-text(\"Submit\")')\nawait page.click('[data-testid=\"submit-button\"]')\n```\n\n### FAIL: WRONG: No Test Isolation\n```typescript\n\u002F\u002F Tests depend on each other\ntest('creates user', () => { \u002F* ... *\u002F })\ntest('updates same user', () => { \u002F* depends on previous test *\u002F })\n```\n\n### PASS: CORRECT: Independent Tests\n```typescript\n\u002F\u002F Each test sets up its own data\ntest('creates user', () => {\n  const user = createTestUser()\n  \u002F\u002F Test logic\n})\n\ntest('updates user', () => {\n  const user = createTestUser()\n  \u002F\u002F Update logic\n})\n```\n\n## Continuous Testing\n\n### Watch Mode During Development\n```bash\n\u003Ctest-watch>\n# Tests run automatically on file changes\n```\n\n### Pre-Commit Hook\n```bash\n# Runs before every commit\n\u003Ctest> && \u003Clint>\n```\n\n### CI\u002FCD Integration\n```yaml\n# GitHub Actions\n- name: Run Tests\n  run: \u003Ccoverage>\n- name: Upload Coverage\n  uses: codecov\u002Fcodecov-action@v3\n```\n\n## Best Practices\n\n1. **Write Tests First** - Always TDD\n2. **One Assert Per Test** - Focus on single behavior\n3. **Descriptive Test Names** - Explain what's tested\n4. **Arrange-Act-Assert** - Clear test structure\n5. **Mock External Dependencies** - Isolate unit tests\n6. **Test Edge Cases** - Null, undefined, empty, large\n7. **Test Error Paths** - Not just happy paths\n8. **Keep Tests Fast** - Unit tests \u003C 50ms each\n9. **Clean Up After Tests** - No side effects\n10. **Review Coverage Reports** - Identify gaps\n\n## Success Metrics\n\n- 80%+ code coverage achieved\n- All tests passing (green)\n- No skipped or disabled tests\n- Fast test execution (\u003C 30s for unit tests)\n- E2E tests cover critical user flows\n- Tests catch bugs before production\n\n---\n\n**Remember**: Tests are not optional. They are the safety net that enables confident refactoring, rapid development, and production reliability.\n",{"name":5,"license":15,"description":7},"main","08be1051c10948e2802b58608c7a2ef9f410a4b6",".agents\u002Fskills\u002Fecc\u002Fupstream\u002F.agents\u002Fskills\u002Ftdd-workflow","https:\u002F\u002Fgithub.com\u002Fshaikhsarib\u002FDeep","https:\u002F\u002Fgithub.com\u002Fshaikhsarib","I want use this platform for education purpose only. i am student currently  pursue bachelor in software development in TISS (SSE - School Skill Education). ","2026-11-07 23:13:19",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add shaikhsarib\u002FDeep --skill tdd-workflow",{"tool":37,"command":38},"bunx","bunx skills add shaikhsarib\u002FDeep --skill tdd-workflow",{"tool":40,"command":41},"pnpm","pnpm dlx skills add shaikhsarib\u002FDeep --skill tdd-workflow","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fshaikhsarib\u002FDeep\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fecc\u002Fupstream\u002F.agents\u002Fskills\u002Ftdd-workflow\u002FSKILL.md",true,[45],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"agents\u002Fopenai.yaml","REFERENCE","参考文档",268,"https:\u002F\u002Fgithub.com\u002Fshaikhsarib\u002FDeep\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fecc\u002Fupstream\u002F.agents\u002Fskills\u002Ftdd-workflow\u002Fagents\u002Fopenai.yaml",[52,60,67,74,81,88],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":56,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M7FFBPBB683WH30DHN4K2069","energy-procurement","Procure electricity and natural gas for commercial and industrial facilities: tariff and rate-schedule optimization, demand-charge mitigation, supplier RFPs, fixed\u002Findex\u002Fblock-and-index hedging, renewable PPA and REC evaluation, and sustainability reporting. Use when procuring energy, optimizing utility tariffs, managing demand charges, evaluating PPAs, or building energy budgets and hedge strategies.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fshaikhsarib\u002FDeep\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fecc\u002Fupstream\u002Fskills\u002Fenergy-procurement\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M7FF764D2RQP4TJCS9FNTMJ7","data-throughput-accelerator","Diagnose and accelerate large data movement — ingestion, backfill, export, ETL, warehouse loading, manifest catch-up, and table synchronization — by isolating the true bottleneck, benchmarking variants, and codifying the fastest path with a hard accounting block proving rows and timestamps cohere. Use when a pipeline or backfill is too slow and must get faster without losing data correctness.","https:\u002F\u002Fgithub.com\u002Fshaikhsarib\u002FDeep\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fecc\u002Fupstream\u002Fskills\u002Fdata-throughput-accelerator\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":56,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M7FF6BJD1NMWCV7J0PD5R3WB","customs-trade-compliance","Codified customs and trade compliance expertise — HS\u002FHTS tariff classification with GRI rules, commercial invoices and entry documentation, Incoterms 2020, FTA qualification and duty optimization (USMCA, RCEP, FTZs, drawback), denied-party screening, and penalty mitigation across US, EU, UK, and APAC jurisdictions. Use when classifying goods, preparing import\u002Fexport documentation, screening restricted parties, responding to customs audits or CF-28\u002Fpenalty notices, or optimizing duties.","https:\u002F\u002Fgithub.com\u002Fshaikhsarib\u002FDeep\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fecc\u002Fupstream\u002Fskills\u002Fcustoms-trade-compliance\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":56,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M7FF0FJHKPWEXHS3KAN7PAP6","carrier-relationship-management","Manage truckload, LTL, and intermodal carrier portfolios: sourcing and FMCSA vetting, freight rate and fuel-surcharge negotiation, RFPs and routing guides, carrier scorecards, allocation, and renewals. Use when onboarding carriers, running freight RFPs, negotiating rates, evaluating carrier performance, reallocating freight, or building freight strategy.","https:\u002F\u002Fgithub.com\u002Fshaikhsarib\u002FDeep\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fecc\u002Fupstream\u002Fskills\u002Fcarrier-relationship-management\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M7FEYXWH7MJ2Z39J3K2NNNYV","benchmark","Measure performance baselines and detect regressions across browser Core Web Vitals (LCP, INP, CLS, page weight), API endpoint latency percentiles, and build\u002Ftest feedback times, with before\u002Fafter comparison stored in git-tracked .ecc\u002Fbenchmarks JSON. Use when checking page speed, responding to 'it feels slow' reports, verifying launch performance targets, or comparing stack alternatives.","https:\u002F\u002Fgithub.com\u002Fshaikhsarib\u002FDeep\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fecc\u002Fupstream\u002Fskills\u002Fbenchmark\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":19},"01M7FEYRS0CC0MG3XKW1BGWGYC","benchmark-optimization-loop","Convert 'make it faster' requests into a bounded measured optimization loop — baseline first, generate one-hypothesis variants, benchmark each against a correctness gate, and promote the fastest safe variant with reproducible commands. Use when asked to speed something up, try many variants, run recursive optimization, benchmark latency\u002Fthroughput\u002Fcost, or pick the best implementation by repeated measured tests.","https:\u002F\u002Fgithub.com\u002Fshaikhsarib\u002FDeep\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fecc\u002Fupstream\u002Fskills\u002Fbenchmark-optimization-loop\u002FSKILL.md",[],[]]