[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7D9Z4CF5ECD0XTKF51HRZ7H":3,"skill-same:01M7D9Z4CF5ECD0XTKF51HRZ7H":85},{"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":64,"commitSha":65,"skillDirectory":66,"forksCount":14,"repositoryHtmlUrl":67,"repositoryHomepageUrl":6,"ownerHtmlUrl":68,"ownerBlogUrl":69,"ownerDescription":70,"updatedAt":71,"install":72,"resources":84},"01M7D9Z4CF5ECD0XTKF51HRZ7H","Turborepo Monorepo Testing",null,"Testing patterns for Turborepo and pnpm monorepos covering workspace dependency testing, affected package detection, parallel test execution, and shared test utilities","GrupoANDevelopment-m\u002Falberto-ai","GrupoANDevelopment-m","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F257455179?v=4","01M7D69X2N2KEVN0SJF6WGM6SH","Antônio  Ndombe","01M7D69X3P5JTT8H8S904N3888",0,"MIT","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fskills\u002Fqa\u002Fturborepo-monorepo-testing\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: \"Turborepo Monorepo Testing\"\ndescription: \"Testing patterns for Turborepo and pnpm monorepos covering workspace dependency testing, affected package detection, parallel test execution, and shared test utilities\"\nversion: 1.0.0\nauthor: thetestingacademy\nlicense: MIT\ntags: [turborepo, monorepo, pnpm, workspace, parallel-testing, affected, caching, ci-cd, turbo-pipeline, shared-utils]\ntestingTypes: [unit, integration, e2e]\nframeworks: [vitest, playwright, jest]\nlanguages: [typescript, javascript]\ndomains: [web, api]\nagents: [claude-code, cursor, github-copilot, windsurf, codex, aider, continue, cline, zed, bolt, gemini-cli, amp]\n---\n\n# Turborepo Monorepo Testing Skill\n\nYou are an expert QA engineer specializing in testing Turborepo and pnpm monorepo projects. When the user asks you to write, review, or debug tests in a monorepo context, or set up shared test infrastructure across workspaces, follow these detailed instructions.\n\n## Core Principles\n\n1. **Workspace isolation** -- Each package should have self-contained tests that can run independently. Never rely on implicit dependencies between workspaces during test execution.\n2. **Affected-only testing** -- Use Turbo's dependency graph to only run tests for packages affected by a change. Avoid running the full test suite on every commit.\n3. **Shared test utilities** -- Extract common test helpers, fixtures, and mocks into a dedicated shared test package to avoid duplication across workspaces.\n4. **Cache-aware test pipelines** -- Configure Turbo pipelines so test results are cached based on source inputs. A package whose code has not changed should never re-run its tests.\n5. **Parallel by default** -- Run workspace tests in parallel via Turbo's task orchestration. Only serialize tests that have true resource conflicts like shared databases.\n6. **Cross-package integration testing** -- Validate that packages work together correctly with dedicated integration tests that import from multiple workspaces.\n7. **Consistent configuration** -- Use shared Vitest\u002FJest configs at the root to ensure all packages follow the same test conventions, coverage thresholds, and reporter settings.\n\n## Project Structure\n\nAlways organize monorepo testing with this structure:\n\n```\nmy-monorepo\u002F\n  turbo.json\n  vitest.workspace.ts\n  pnpm-workspace.yaml\n  packages\u002F\n    shared\u002F\n      src\u002F\n        index.ts\n        utils\u002F\n      __tests__\u002F\n        utils.test.ts\n      vitest.config.ts\n      package.json\n    web\u002F\n      src\u002F\n        app\u002F\n        components\u002F\n      __tests__\u002F\n        unit\u002F\n        integration\u002F\n      e2e\u002F\n        home.spec.ts\n      vitest.config.ts\n      playwright.config.ts\n      package.json\n    api\u002F\n      src\u002F\n        routes\u002F\n        services\u002F\n      __tests__\u002F\n        unit\u002F\n        integration\u002F\n      vitest.config.ts\n      package.json\n    test-utils\u002F\n      src\u002F\n        fixtures\u002F\n          user.fixture.ts\n          product.fixture.ts\n        mocks\u002F\n          api-client.mock.ts\n          database.mock.ts\n        helpers\u002F\n          render.tsx\n          setup-server.ts\n        index.ts\n      package.json\n    config\u002F\n      vitest\u002F\n        base.config.ts\n        react.config.ts\n        node.config.ts\n      tsconfig\u002F\n        base.json\n        react.json\n        node.json\n      package.json\n```\n\n## Turbo Pipeline Configuration\n\n### turbo.json with Test Pipelines\n\n```json\n{\n  \"$schema\": \"https:\u002F\u002Fturbo.build\u002Fschema.json\",\n  \"globalDependencies\": [\"**\u002F.env.*local\"],\n  \"globalEnv\": [\"NODE_ENV\", \"CI\"],\n  \"pipeline\": {\n    \"build\": {\n      \"dependsOn\": [\"^build\"],\n      \"outputs\": [\"dist\u002F**\", \".next\u002F**\", \"!.next\u002Fcache\u002F**\"]\n    },\n    \"test\": {\n      \"dependsOn\": [\"^build\"],\n      \"outputs\": [\"coverage\u002F**\"],\n      \"inputs\": [\n        \"src\u002F**\",\n        \"__tests__\u002F**\",\n        \"vitest.config.*\",\n        \"tsconfig.json\"\n      ],\n      \"env\": [\"DATABASE_URL\", \"TEST_DATABASE_URL\"]\n    },\n    \"test:unit\": {\n      \"dependsOn\": [\"^build\"],\n      \"outputs\": [\"coverage\u002F**\"],\n      \"inputs\": [\n        \"src\u002F**\",\n        \"__tests__\u002Funit\u002F**\",\n        \"vitest.config.*\"\n      ]\n    },\n    \"test:integration\": {\n      \"dependsOn\": [\"^build\"],\n      \"outputs\": [\"coverage\u002F**\"],\n      \"inputs\": [\n        \"src\u002F**\",\n        \"__tests__\u002Fintegration\u002F**\",\n        \"vitest.config.*\"\n      ],\n      \"env\": [\"DATABASE_URL\", \"TEST_DATABASE_URL\"]\n    },\n    \"test:e2e\": {\n      \"dependsOn\": [\"^build\", \"build\"],\n      \"outputs\": [\"test-results\u002F**\", \"playwright-report\u002F**\"],\n      \"inputs\": [\n        \"e2e\u002F**\",\n        \"playwright.config.*\",\n        \"src\u002F**\"\n      ]\n    },\n    \"lint\": {\n      \"dependsOn\": [\"^build\"],\n      \"inputs\": [\n        \"src\u002F**\",\n        \"__tests__\u002F**\",\n        \"e2e\u002F**\",\n        \".eslintrc.*\",\n        \"eslint.config.*\"\n      ]\n    },\n    \"typecheck\": {\n      \"dependsOn\": [\"^build\"],\n      \"inputs\": [\n        \"src\u002F**\",\n        \"__tests__\u002F**\",\n        \"tsconfig.json\"\n      ]\n    }\n  }\n}\n```\n\n### Vitest Workspace Configuration\n\n```typescript\n\u002F\u002F vitest.workspace.ts (root)\nimport { defineWorkspace } from 'vitest\u002Fconfig';\n\nexport default defineWorkspace([\n  'packages\u002Fshared\u002Fvitest.config.ts',\n  'packages\u002Fweb\u002Fvitest.config.ts',\n  'packages\u002Fapi\u002Fvitest.config.ts',\n]);\n```\n\n### Shared Base Vitest Config\n\n```typescript\n\u002F\u002F packages\u002Fconfig\u002Fvitest\u002Fbase.config.ts\nimport { defineConfig } from 'vitest\u002Fconfig';\n\nexport default defineConfig({\n  test: {\n    globals: true,\n    clearMocks: true,\n    restoreMocks: true,\n    coverage: {\n      provider: 'v8',\n      reporter: ['text', 'json', 'html', 'lcov'],\n      exclude: [\n        'node_modules\u002F',\n        'dist\u002F',\n        '**\u002F*.d.ts',\n        '**\u002F*.config.*',\n        '**\u002Findex.ts',\n        '**\u002F__tests__\u002F**',\n        '**\u002Ftest-utils\u002F**',\n      ],\n      thresholds: {\n        branches: 80,\n        functions: 80,\n        lines: 80,\n        statements: 80,\n      },\n    },\n    reporters: process.env.CI\n      ? ['default', 'junit']\n      : ['default'],\n    outputFile: process.env.CI\n      ? { junit: '.\u002Ftest-results\u002Fjunit.xml' }\n      : undefined,\n  },\n});\n```\n\n### Package-Level Vitest Config\n\n```typescript\n\u002F\u002F packages\u002Fapi\u002Fvitest.config.ts\nimport { defineConfig, mergeConfig } from 'vitest\u002Fconfig';\nimport baseConfig from '@repo\u002Fconfig\u002Fvitest\u002Fbase.config';\n\nexport default mergeConfig(\n  baseConfig,\n  defineConfig({\n    test: {\n      environment: 'node',\n      include: ['__tests__\u002F**\u002F*.test.ts'],\n      setupFiles: ['__tests__\u002Fsetup.ts'],\n      testTimeout: 10000,\n      pool: 'forks',\n      poolOptions: {\n        forks: {\n          singleFork: false,\n        },\n      },\n    },\n  })\n);\n```\n\n```typescript\n\u002F\u002F packages\u002Fweb\u002Fvitest.config.ts\nimport { defineConfig, mergeConfig } from 'vitest\u002Fconfig';\nimport react from '@vitejs\u002Fplugin-react';\nimport baseConfig from '@repo\u002Fconfig\u002Fvitest\u002Fbase.config';\n\nexport default mergeConfig(\n  baseConfig,\n  defineConfig({\n    plugins: [react()],\n    test: {\n      environment: 'jsdom',\n      include: ['__tests__\u002F**\u002F*.test.{ts,tsx}'],\n      setupFiles: ['__tests__\u002Fsetup.ts'],\n      css: true,\n    },\n  })\n);\n```\n\n## Shared Test Utilities Package\n\n### Package Configuration\n\n```json\n{\n  \"name\": \"@repo\u002Ftest-utils\",\n  \"version\": \"0.0.0\",\n  \"private\": true,\n  \"main\": \".\u002Fsrc\u002Findex.ts\",\n  \"types\": \".\u002Fsrc\u002Findex.ts\",\n  \"exports\": {\n    \".\": \".\u002Fsrc\u002Findex.ts\",\n    \".\u002Ffixtures\": \".\u002Fsrc\u002Ffixtures\u002Findex.ts\",\n    \".\u002Fmocks\": \".\u002Fsrc\u002Fmocks\u002Findex.ts\",\n    \".\u002Fhelpers\": \".\u002Fsrc\u002Fhelpers\u002Findex.ts\"\n  },\n  \"dependencies\": {\n    \"@testing-library\u002Freact\": \"^16.0.0\",\n    \"@testing-library\u002Fjest-dom\": \"^6.0.0\",\n    \"msw\": \"^2.0.0\"\n  },\n  \"peerDependencies\": {\n    \"vitest\": \"^2.0.0\"\n  }\n}\n```\n\n### Shared Fixtures\n\n```typescript\n\u002F\u002F packages\u002Ftest-utils\u002Fsrc\u002Ffixtures\u002Fuser.fixture.ts\nimport { faker } from '@faker-js\u002Ffaker';\n\nexport interface TestUser {\n  id: string;\n  email: string;\n  name: string;\n  role: 'admin' | 'user' | 'editor';\n  createdAt: Date;\n}\n\nexport function createTestUser(overrides: Partial\u003CTestUser> = {}): TestUser {\n  return {\n    id: faker.string.uuid(),\n    email: faker.internet.email(),\n    name: faker.person.fullName(),\n    role: 'user',\n    createdAt: faker.date.recent(),\n    ...overrides,\n  };\n}\n\nexport function createTestUsers(count: number, overrides: Partial\u003CTestUser> = {}): TestUser[] {\n  return Array.from({ length: count }, () => createTestUser(overrides));\n}\n\nexport const adminUser = createTestUser({ role: 'admin', email: 'admin@test.com' });\nexport const regularUser = createTestUser({ role: 'user', email: 'user@test.com' });\n```\n\n```typescript\n\u002F\u002F packages\u002Ftest-utils\u002Fsrc\u002Ffixtures\u002Fproduct.fixture.ts\nimport { faker } from '@faker-js\u002Ffaker';\n\nexport interface TestProduct {\n  id: string;\n  name: string;\n  price: number;\n  category: string;\n  inStock: boolean;\n}\n\nexport function createTestProduct(overrides: Partial\u003CTestProduct> = {}): TestProduct {\n  return {\n    id: faker.string.uuid(),\n    name: faker.commerce.productName(),\n    price: parseFloat(faker.commerce.price({ min: 1, max: 500 })),\n    category: faker.commerce.department(),\n    inStock: true,\n    ...overrides,\n  };\n}\n```\n\n### Shared Mock Utilities\n\n```typescript\n\u002F\u002F packages\u002Ftest-utils\u002Fsrc\u002Fmocks\u002Fapi-client.mock.ts\nimport { http, HttpResponse } from 'msw';\nimport { setupServer } from 'msw\u002Fnode';\nimport { createTestUser, createTestProduct } from '..\u002Ffixtures';\n\nexport const handlers = [\n  http.get('\u002Fapi\u002Fusers', () => {\n    return HttpResponse.json({\n      users: [createTestUser(), createTestUser()],\n      total: 2,\n    });\n  }),\n\n  http.get('\u002Fapi\u002Fusers\u002F:id', ({ params }) => {\n    return HttpResponse.json(\n      createTestUser({ id: params.id as string })\n    );\n  }),\n\n  http.post('\u002Fapi\u002Fusers', async ({ request }) => {\n    const body = await request.json() as Record\u003Cstring, unknown>;\n    return HttpResponse.json(\n      createTestUser(body),\n      { status: 201 }\n    );\n  }),\n\n  http.get('\u002Fapi\u002Fproducts', () => {\n    return HttpResponse.json({\n      products: [createTestProduct(), createTestProduct()],\n      total: 2,\n    });\n  }),\n];\n\nexport const server = setupServer(...handlers);\n\nexport function setupMockServer() {\n  beforeAll(() => server.listen({ onUnhandledRequest: 'error' }));\n  afterEach(() => server.resetHandlers());\n  afterAll(() => server.close());\n}\n```\n\n### Shared React Testing Helpers\n\n```typescript\n\u002F\u002F packages\u002Ftest-utils\u002Fsrc\u002Fhelpers\u002Frender.tsx\nimport React, { ReactElement } from 'react';\nimport { render, RenderOptions } from '@testing-library\u002Freact';\nimport userEvent from '@testing-library\u002Fuser-event';\n\n\u002F\u002F Add your app-wide providers here\nfunction AllProviders({ children }: { children: React.ReactNode }) {\n  return (\n    \u003C>\n      {children}\n    \u003C\u002F>\n  );\n}\n\nexport function renderWithProviders(\n  ui: ReactElement,\n  options?: Omit\u003CRenderOptions, 'wrapper'>\n) {\n  const user = userEvent.setup();\n  return {\n    user,\n    ...render(ui, { wrapper: AllProviders, ...options }),\n  };\n}\n\nexport { render, screen, waitFor, within } from '@testing-library\u002Freact';\nexport { userEvent };\n```\n\n## Affected Package Testing\n\n### Running Tests Only for Changed Packages\n\n```bash\n# Run tests only for packages affected by changes since main\npnpm turbo test --filter=...[origin\u002Fmain]\n\n# Run tests for a specific package and its dependents\npnpm turbo test --filter=@repo\u002Fshared...\n\n# Run tests for packages affected by changes in the last commit\npnpm turbo test --filter=...[HEAD~1]\n\n# Dry run to see what would be tested\npnpm turbo test --filter=...[origin\u002Fmain] --dry-run\n```\n\n### CI Script for Affected Testing\n\n```typescript\n\u002F\u002F scripts\u002Frun-affected-tests.ts\nimport { execSync } from 'child_process';\n\nfunction getAffectedPackages(): string[] {\n  const baseBranch = process.env.BASE_BRANCH || 'origin\u002Fmain';\n\n  try {\n    const output = execSync(\n      `pnpm turbo test --filter=...[${baseBranch}] --dry-run=json`,\n      { encoding: 'utf-8' }\n    );\n\n    const result = JSON.parse(output);\n    return result.packages || [];\n  } catch {\n    console.warn('Could not determine affected packages, running all tests');\n    return ['*'];\n  }\n}\n\nfunction runAffectedTests(): void {\n  const affected = getAffectedPackages();\n\n  if (affected.length === 0) {\n    console.log('No packages affected, skipping tests');\n    process.exit(0);\n  }\n\n  console.log(`Running tests for affected packages: ${affected.join(', ')}`);\n\n  const filterArgs = affected\n    .map((pkg) => `--filter=${pkg}`)\n    .join(' ');\n\n  try {\n    execSync(`pnpm turbo test ${filterArgs}`, {\n      stdio: 'inherit',\n    });\n  } catch {\n    process.exit(1);\n  }\n}\n\nrunAffectedTests();\n```\n\n## Cross-Package Integration Testing\n\n### Integration Test for Shared + API\n\n```typescript\n\u002F\u002F packages\u002Fapi\u002F__tests__\u002Fintegration\u002Fshared-integration.test.ts\nimport { describe, it, expect, beforeAll } from 'vitest';\nimport { parseSkillMd, serializeSkillMd } from '@repo\u002Fshared';\nimport { SkillService } from '..\u002F..\u002Fsrc\u002Fservices\u002Fskill-service';\nimport { createTestDatabase, cleanupDatabase } from '@repo\u002Ftest-utils\u002Fhelpers';\n\ndescribe('Shared + API Integration', () => {\n  let db: ReturnType\u003Ctypeof createTestDatabase>;\n\n  beforeAll(async () => {\n    db = await createTestDatabase();\n  });\n\n  afterAll(async () => {\n    await cleanupDatabase(db);\n  });\n\n  it('should parse SKILL.md and store in database via service', async () => {\n    const markdown = `---\nname: \"Test Skill\"\ndescription: \"A test skill for integration testing\"\nversion: 1.0.0\nauthor: test\ntags: [testing]\ntestingTypes: [unit]\nframeworks: [vitest]\nlanguages: [typescript]\ndomains: [web]\nagents: [claude-code]\n---\n\n# Test Skill\n\nThis is a test skill body.\n`;\n\n    \u002F\u002F Uses @repo\u002Fshared parser\n    const parsed = parseSkillMd(markdown);\n    expect(parsed.frontmatter.name).toBe('Test Skill');\n\n    \u002F\u002F Uses API service to store\n    const service = new SkillService(db);\n    const stored = await service.createSkill(parsed);\n\n    expect(stored.id).toBeDefined();\n    expect(stored.name).toBe('Test Skill');\n\n    \u002F\u002F Round-trip: retrieve and serialize back\n    const retrieved = await service.getSkill(stored.id);\n    const serialized = serializeSkillMd(retrieved);\n\n    expect(serialized).toContain('name: \"Test Skill\"');\n    expect(serialized).toContain('# Test Skill');\n  });\n\n  it('should validate shared types are compatible with API endpoints', async () => {\n    const service = new SkillService(db);\n\n    const skills = await service.listSkills({\n      testingTypes: ['unit'],\n      languages: ['typescript'],\n      page: 1,\n      limit: 10,\n    });\n\n    \u002F\u002F Verify the response matches the shared SkillSummary type\n    for (const skill of skills.items) {\n      expect(skill).toHaveProperty('id');\n      expect(skill).toHaveProperty('name');\n      expect(skill).toHaveProperty('description');\n      expect(skill).toHaveProperty('version');\n      expect(Array.isArray(skill.tags)).toBe(true);\n      expect(Array.isArray(skill.testingTypes)).toBe(true);\n    }\n  });\n});\n```\n\n### Integration Test for Web + API\n\n```typescript\n\u002F\u002F packages\u002Fweb\u002F__tests__\u002Fintegration\u002Fapi-integration.test.ts\nimport { describe, it, expect, beforeAll, afterAll } from 'vitest';\nimport { createTestUser, createTestProduct } from '@repo\u002Ftest-utils\u002Ffixtures';\nimport { server } from '@repo\u002Ftest-utils\u002Fmocks';\n\ndescribe('Web + API Integration', () => {\n  beforeAll(() => server.listen());\n  afterAll(() => server.close());\n\n  it('should fetch and transform API data for UI rendering', async () => {\n    const response = await fetch('\u002Fapi\u002Fusers');\n    const data = await response.json();\n\n    expect(data.users).toHaveLength(2);\n    expect(data.users[0]).toHaveProperty('name');\n    expect(data.users[0]).toHaveProperty('email');\n  });\n\n  it('should handle API error responses gracefully', async () => {\n    server.use(\n      http.get('\u002Fapi\u002Fusers', () => {\n        return HttpResponse.json(\n          { error: 'Internal Server Error' },\n          { status: 500 }\n        );\n      })\n    );\n\n    const response = await fetch('\u002Fapi\u002Fusers');\n    expect(response.status).toBe(500);\n\n    const data = await response.json();\n    expect(data.error).toBe('Internal Server Error');\n  });\n});\n```\n\n## E2E Testing in a Monorepo\n\n### Playwright Config with Monorepo Awareness\n\n```typescript\n\u002F\u002F packages\u002Fweb\u002Fplaywright.config.ts\nimport { defineConfig, devices } from '@playwright\u002Ftest';\nimport path from 'path';\n\nexport default defineConfig({\n  testDir: '.\u002Fe2e',\n  fullyParallel: true,\n  forbidOnly: !!process.env.CI,\n  retries: process.env.CI ? 2 : 0,\n  workers: process.env.CI ? 1 : undefined,\n  reporter: [\n    ['html', { outputFolder: path.join(__dirname, 'playwright-report') }],\n    process.env.CI ? ['github'] : ['list'],\n  ],\n  use: {\n    baseURL: process.env.BASE_URL || 'http:\u002F\u002Flocalhost:3000',\n    trace: 'on-first-retry',\n    screenshot: 'only-on-failure',\n  },\n  projects: [\n    {\n      name: 'chromium',\n      use: { ...devices['Desktop Chrome'] },\n    },\n    {\n      name: 'firefox',\n      use: { ...devices['Desktop Firefox'] },\n    },\n    {\n      name: 'mobile-chrome',\n      use: { ...devices['Pixel 7'] },\n    },\n  ],\n  webServer: {\n    command: 'pnpm turbo build --filter=@repo\u002Fweb && pnpm turbo start --filter=@repo\u002Fweb',\n    url: 'http:\u002F\u002Flocalhost:3000',\n    reuseExistingServer: !process.env.CI,\n    timeout: 120000,\n  },\n});\n```\n\n## CI Configuration with Turbo Cache\n\n### GitHub Actions Workflow\n\n```yaml\n# .github\u002Fworkflows\u002Ftest.yml\nname: Test\n\non:\n  pull_request:\n    branches: [main]\n  push:\n    branches: [main]\n\nconcurrency:\n  group: ${{ github.workflow }}-${{ github.ref }}\n  cancel-in-progress: true\n\njobs:\n  test:\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        node-version: [20]\n\n    steps:\n      - uses: actions\u002Fcheckout@v4\n        with:\n          fetch-depth: 0  # Full history for affected detection\n\n      - uses: pnpm\u002Faction-setup@v4\n        with:\n          version: 9\n\n      - uses: actions\u002Fsetup-node@v4\n        with:\n          node-version: ${{ matrix.node-version }}\n          cache: 'pnpm'\n\n      - name: Install dependencies\n        run: pnpm install --frozen-lockfile\n\n      # Turbo remote cache\n      - name: Configure Turbo cache\n        uses: actions\u002Fcache@v4\n        with:\n          path: node_modules\u002F.cache\u002Fturbo\n          key: turbo-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.sha }}\n          restore-keys: |\n            turbo-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}-\n            turbo-${{ runner.os }}-\n\n      # Run only affected unit and integration tests\n      - name: Run affected tests\n        run: pnpm turbo test:unit test:integration --filter=...[origin\u002Fmain]\n\n      # Always run full lint\n      - name: Lint\n        run: pnpm turbo lint\n\n      # Type checking\n      - name: Type check\n        run: pnpm turbo typecheck\n\n      # Upload coverage from all packages\n      - name: Upload coverage\n        if: always()\n        uses: actions\u002Fupload-artifact@v4\n        with:\n          name: coverage-reports\n          path: packages\u002F*\u002Fcoverage\u002F\n\n  e2e:\n    runs-on: ubuntu-latest\n    needs: test\n    steps:\n      - uses: actions\u002Fcheckout@v4\n      - uses: pnpm\u002Faction-setup@v4\n        with:\n          version: 9\n      - uses: actions\u002Fsetup-node@v4\n        with:\n          node-version: 20\n          cache: 'pnpm'\n\n      - name: Install dependencies\n        run: pnpm install --frozen-lockfile\n\n      - name: Install Playwright browsers\n        run: pnpm --filter @repo\u002Fweb exec playwright install --with-deps\n\n      - name: Build all packages\n        run: pnpm turbo build\n\n      - name: Run E2E tests\n        run: pnpm turbo test:e2e\n\n      - name: Upload E2E report\n        if: always()\n        uses: actions\u002Fupload-artifact@v4\n        with:\n          name: playwright-report\n          path: packages\u002Fweb\u002Fplaywright-report\u002F\n```\n\n## Package Scripts Configuration\n\n### Root package.json Scripts\n\n```json\n{\n  \"scripts\": {\n    \"dev\": \"turbo dev\",\n    \"build\": \"turbo build\",\n    \"test\": \"turbo test\",\n    \"test:unit\": \"turbo test:unit\",\n    \"test:integration\": \"turbo test:integration\",\n    \"test:e2e\": \"turbo test:e2e\",\n    \"test:affected\": \"turbo test --filter=...[origin\u002Fmain]\",\n    \"test:watch\": \"vitest --workspace=vitest.workspace.ts\",\n    \"test:coverage\": \"turbo test -- --coverage\",\n    \"lint\": \"turbo lint\",\n    \"typecheck\": \"turbo typecheck\",\n    \"format\": \"prettier --write .\",\n    \"format:check\": \"prettier --check .\",\n    \"clean\": \"turbo clean && rm -rf node_modules\"\n  }\n}\n```\n\n### Individual Package Scripts\n\n```json\n{\n  \"name\": \"@repo\u002Fapi\",\n  \"scripts\": {\n    \"dev\": \"tsx watch src\u002Fserver.ts\",\n    \"build\": \"tsup src\u002Findex.ts\",\n    \"test\": \"vitest run\",\n    \"test:unit\": \"vitest run __tests__\u002Funit\",\n    \"test:integration\": \"vitest run __tests__\u002Fintegration\",\n    \"test:watch\": \"vitest\",\n    \"test:coverage\": \"vitest run --coverage\",\n    \"lint\": \"eslint src __tests__\",\n    \"typecheck\": \"tsc --noEmit\",\n    \"clean\": \"rm -rf dist coverage\"\n  }\n}\n```\n\n## Workspace Dependency Testing\n\n### Verifying Internal Dependencies Resolve Correctly\n\n```typescript\n\u002F\u002F packages\u002Fapi\u002F__tests__\u002Funit\u002Fdependencies.test.ts\nimport { describe, it, expect } from 'vitest';\n\ndescribe('Workspace Dependency Resolution', () => {\n  it('should import shared types correctly', async () => {\n    const shared = await import('@repo\u002Fshared');\n\n    expect(shared).toHaveProperty('parseSkillMd');\n    expect(shared).toHaveProperty('serializeSkillMd');\n    expect(typeof shared.parseSkillMd).toBe('function');\n  });\n\n  it('should import test-utils fixtures', async () => {\n    const { createTestUser } = await import('@repo\u002Ftest-utils\u002Ffixtures');\n\n    const user = createTestUser();\n    expect(user).toHaveProperty('id');\n    expect(user).toHaveProperty('email');\n    expect(user).toHaveProperty('name');\n  });\n\n  it('should verify shared constants are accessible', async () => {\n    const { AGENTS, CATEGORIES } = await import('@repo\u002Fshared');\n\n    expect(Array.isArray(AGENTS)).toBe(true);\n    expect(AGENTS.length).toBeGreaterThan(0);\n    expect(Array.isArray(CATEGORIES)).toBe(true);\n  });\n\n  it('should verify shared schemas validate correctly', async () => {\n    const { skillFrontmatterSchema } = await import('@repo\u002Fshared');\n\n    const validData = {\n      name: 'Test Skill',\n      description: 'A valid description that is long enough',\n      version: '1.0.0',\n      author: 'test',\n      tags: ['testing'],\n      testingTypes: ['unit'],\n      frameworks: ['vitest'],\n      languages: ['typescript'],\n      domains: ['web'],\n      agents: ['claude-code'],\n    };\n\n    const result = skillFrontmatterSchema.safeParse(validData);\n    expect(result.success).toBe(true);\n  });\n});\n```\n\n### Testing Build Output Compatibility\n\n```typescript\n\u002F\u002F scripts\u002Fverify-build-outputs.test.ts\nimport { describe, it, expect } from 'vitest';\nimport { existsSync, readFileSync } from 'fs';\nimport path from 'path';\n\ndescribe('Build Output Verification', () => {\n  const packages = ['shared', 'cli', 'sdk', 'api'];\n\n  for (const pkg of packages) {\n    const distPath = path.join(__dirname, '..', 'packages', pkg, 'dist');\n\n    it(`${pkg}: dist directory should exist after build`, () => {\n      expect(existsSync(distPath)).toBe(true);\n    });\n\n    it(`${pkg}: should have a valid entry point`, () => {\n      const pkgJsonPath = path.join(__dirname, '..', 'packages', pkg, 'package.json');\n      const pkgJson = JSON.parse(readFileSync(pkgJsonPath, 'utf-8'));\n\n      const mainEntry = pkgJson.main || pkgJson.exports?.['.'];\n      expect(mainEntry).toBeDefined();\n\n      const resolvedEntry = path.join(__dirname, '..', 'packages', pkg, mainEntry);\n      expect(existsSync(resolvedEntry)).toBe(true);\n    });\n\n    it(`${pkg}: TypeScript declarations should be present`, () => {\n      const dtsFiles = require('fast-glob').sync('**\u002F*.d.ts', { cwd: distPath });\n      expect(dtsFiles.length).toBeGreaterThan(0);\n    });\n  }\n});\n```\n\n## Test Database Management for Integration Tests\n\n```typescript\n\u002F\u002F packages\u002Ftest-utils\u002Fsrc\u002Fhelpers\u002Fsetup-database.ts\nimport { execSync } from 'child_process';\nimport { randomUUID } from 'crypto';\n\ninterface TestDatabaseConfig {\n  connectionString: string;\n  databaseName: string;\n  cleanup: () => Promise\u003Cvoid>;\n}\n\nexport async function createTestDatabase(): Promise\u003CTestDatabaseConfig> {\n  const baseName = 'test_db';\n  const databaseName = `${baseName}_${randomUUID().slice(0, 8)}`;\n  const baseUrl = process.env.TEST_DATABASE_URL || 'postgresql:\u002F\u002Flocalhost:5432';\n\n  \u002F\u002F Create isolated test database\n  execSync(`createdb ${databaseName}`, {\n    env: { ...process.env, PGHOST: 'localhost' },\n  });\n\n  const connectionString = `${baseUrl}\u002F${databaseName}`;\n\n  \u002F\u002F Run migrations\n  execSync('pnpm drizzle-kit push', {\n    env: { ...process.env, DATABASE_URL: connectionString },\n    cwd: process.cwd(),\n  });\n\n  return {\n    connectionString,\n    databaseName,\n    cleanup: async () => {\n      execSync(`dropdb --if-exists ${databaseName}`, {\n        env: { ...process.env, PGHOST: 'localhost' },\n      });\n    },\n  };\n}\n```\n\n## Parallel Test Execution Strategies\n\n```typescript\n\u002F\u002F packages\u002Fapi\u002F__tests__\u002Fsetup.ts\nimport { beforeAll, afterAll } from 'vitest';\nimport { server } from '@repo\u002Ftest-utils\u002Fmocks';\n\n\u002F\u002F Each worker gets its own mock server\nbeforeAll(() => {\n  server.listen({ onUnhandledRequest: 'warn' });\n});\n\nafterAll(() => {\n  server.close();\n});\n```\n\n```typescript\n\u002F\u002F vitest.config.ts with parallel configuration\nimport { defineConfig } from 'vitest\u002Fconfig';\n\nexport default defineConfig({\n  test: {\n    \u002F\u002F Run test files in parallel (default)\n    fileParallelism: true,\n\n    \u002F\u002F Each test file runs in its own worker thread\n    pool: 'threads',\n    poolOptions: {\n      threads: {\n        \u002F\u002F Match CPU core count for optimal parallelism\n        minThreads: 1,\n        maxThreads: process.env.CI ? 4 : undefined,\n      },\n    },\n\n    \u002F\u002F Isolate each test file to prevent state leakage\n    isolate: true,\n\n    \u002F\u002F Sequence configuration for deterministic order when needed\n    sequence: {\n      shuffle: true, \u002F\u002F Randomize to detect order dependencies\n    },\n  },\n});\n```\n\n## Coverage Aggregation Across Packages\n\n```typescript\n\u002F\u002F scripts\u002Fmerge-coverage.ts\nimport { execSync } from 'child_process';\nimport { existsSync, mkdirSync } from 'fs';\nimport path from 'path';\n\nconst rootDir = path.resolve(__dirname, '..');\nconst mergedDir = path.join(rootDir, 'coverage-merged');\n\nif (!existsSync(mergedDir)) {\n  mkdirSync(mergedDir, { recursive: true });\n}\n\nconst packages = ['shared', 'web', 'api', 'cli', 'sdk'];\n\n\u002F\u002F Collect all coverage JSON files\nconst coverageFiles = packages\n  .map((pkg) => path.join(rootDir, 'packages', pkg, 'coverage', 'coverage-final.json'))\n  .filter((f) => existsSync(f));\n\nif (coverageFiles.length === 0) {\n  console.log('No coverage files found. Run tests with coverage first.');\n  process.exit(0);\n}\n\n\u002F\u002F Merge using nyc\nconst fileArgs = coverageFiles.map((f) => `--include=\"${f}\"`).join(' ');\nexecSync(\n  `npx nyc merge ${coverageFiles.map((f) => path.dirname(f)).join(' ')} ${mergedDir}\u002Fcoverage.json`,\n  { stdio: 'inherit' }\n);\n\n\u002F\u002F Generate merged report\nexecSync(\n  `npx nyc report --temp-dir=${mergedDir} --reporter=text --reporter=html --report-dir=${mergedDir}\u002Fhtml`,\n  { stdio: 'inherit' }\n);\n\nconsole.log(`Merged coverage report generated at ${mergedDir}\u002Fhtml\u002Findex.html`);\n```\n\n## Best Practices\n\n1. **Define explicit test inputs in turbo.json** -- Always list the `inputs` array for test tasks so Turbo can compute hashes correctly. Missing inputs cause stale cache hits.\n2. **Use workspace protocol for internal dependencies** -- Use `\"@repo\u002Fshared\": \"workspace:*\"` in package.json to ensure pnpm links internal packages instead of fetching from npm.\n3. **Create a dedicated test-utils package** -- Extract shared fixtures, mocks, and helpers into `@repo\u002Ftest-utils` instead of duplicating across packages.\n4. **Run affected tests in CI, full suite on main** -- Use `--filter=...[origin\u002Fmain]` on PRs but run the full `pnpm turbo test` on main branch merges.\n5. **Cache test results in CI** -- Store and restore `node_modules\u002F.cache\u002Fturbo` between CI runs. Turbo will skip unchanged packages.\n6. **Isolate integration tests with separate databases** -- Each integration test suite should create and destroy its own test database to enable parallel execution.\n7. **Use Vitest workspace mode for development** -- Run `vitest --workspace=vitest.workspace.ts` in watch mode during development to get instant feedback across all packages.\n8. **Set coverage thresholds per package** -- Different packages have different test priorities. Set appropriate thresholds in each package's vitest config rather than one global number.\n9. **Type-check as a separate pipeline task** -- Run `tsc --noEmit` as a separate Turbo task (`typecheck`) instead of bundling it with tests. It catches different classes of errors.\n10. **Pin exact versions of shared dev dependencies** -- Use the same versions of vitest, typescript, and eslint across all packages via a root `pnpm-workspace.yaml` catalog or `syncpack`.\n\n## Anti-Patterns to Avoid\n\n1. **Running all tests on every change** -- Without `--filter`, Turbo runs every package's tests. Always use affected detection for PRs.\n2. **Importing from package dist instead of source** -- In a monorepo, internal packages should resolve to source (via `main: .\u002Fsrc\u002Findex.ts`), not compiled output, during development and testing.\n3. **Sharing mutable test state across packages** -- Global test state that leaks across workspace boundaries causes flaky and order-dependent tests.\n4. **Missing `dependsOn: [\"^build\"]` for test tasks** -- If test tasks don't depend on upstream builds, shared package changes won't be picked up, causing false positives.\n5. **Duplicating test configuration in every package** -- Maintain base configs in a shared config package and use `mergeConfig` to extend per-package.\n6. **Not specifying `inputs` for Turbo tasks** -- Without explicit inputs, Turbo hashes all files, causing unnecessary cache invalidation.\n7. **Using a single global vitest config** -- A root-level vitest config without workspace mode runs all tests in a single process, losing parallelism benefits.\n8. **Ignoring workspace dependency graph in E2E tests** -- E2E tests for the web app must `dependsOn: [\"build\"]` for the web package plus `[\"^build\"]` for all dependencies.\n9. **Hardcoding package paths in test scripts** -- Use workspace references (`@repo\u002Fshared`) instead of relative paths (`..\u002F..\u002Fshared\u002Fsrc`) to avoid breakage when packages move.\n10. **Not cleaning Turbo cache periodically** -- Stale cache entries accumulate over time. Add a `clean` script that removes `node_modules\u002F.cache\u002Fturbo` and run it when debugging mysterious test failures.\n\n## Running Tests\n\n- Run all tests: `pnpm turbo test`\n- Run affected tests: `pnpm turbo test --filter=...[origin\u002Fmain]`\n- Run tests for one package: `pnpm turbo test --filter=@repo\u002Fapi`\n- Run tests for a package and dependents: `pnpm turbo test --filter=@repo\u002Fshared...`\n- Watch mode across workspace: `pnpm vitest --workspace=vitest.workspace.ts`\n- View Turbo task graph: `pnpm turbo test --graph`\n- Check cache status: `pnpm turbo test --dry-run`\n- Force re-run (skip cache): `pnpm turbo test --force`\n","# Turborepo Monorepo Testing Skill\n\nYou are an expert QA engineer specializing in testing Turborepo and pnpm monorepo projects. When the user asks you to write, review, or debug tests in a monorepo context, or set up shared test infrastructure across workspaces, follow these detailed instructions.\n\n## Core Principles\n\n1. **Workspace isolation** -- Each package should have self-contained tests that can run independently. Never rely on implicit dependencies between workspaces during test execution.\n2. **Affected-only testing** -- Use Turbo's dependency graph to only run tests for packages affected by a change. Avoid running the full test suite on every commit.\n3. **Shared test utilities** -- Extract common test helpers, fixtures, and mocks into a dedicated shared test package to avoid duplication across workspaces.\n4. **Cache-aware test pipelines** -- Configure Turbo pipelines so test results are cached based on source inputs. A package whose code has not changed should never re-run its tests.\n5. **Parallel by default** -- Run workspace tests in parallel via Turbo's task orchestration. Only serialize tests that have true resource conflicts like shared databases.\n6. **Cross-package integration testing** -- Validate that packages work together correctly with dedicated integration tests that import from multiple workspaces.\n7. **Consistent configuration** -- Use shared Vitest\u002FJest configs at the root to ensure all packages follow the same test conventions, coverage thresholds, and reporter settings.\n\n## Project Structure\n\nAlways organize monorepo testing with this structure:\n\n```\nmy-monorepo\u002F\n  turbo.json\n  vitest.workspace.ts\n  pnpm-workspace.yaml\n  packages\u002F\n    shared\u002F\n      src\u002F\n        index.ts\n        utils\u002F\n      __tests__\u002F\n        utils.test.ts\n      vitest.config.ts\n      package.json\n    web\u002F\n      src\u002F\n        app\u002F\n        components\u002F\n      __tests__\u002F\n        unit\u002F\n        integration\u002F\n      e2e\u002F\n        home.spec.ts\n      vitest.config.ts\n      playwright.config.ts\n      package.json\n    api\u002F\n      src\u002F\n        routes\u002F\n        services\u002F\n      __tests__\u002F\n        unit\u002F\n        integration\u002F\n      vitest.config.ts\n      package.json\n    test-utils\u002F\n      src\u002F\n        fixtures\u002F\n          user.fixture.ts\n          product.fixture.ts\n        mocks\u002F\n          api-client.mock.ts\n          database.mock.ts\n        helpers\u002F\n          render.tsx\n          setup-server.ts\n        index.ts\n      package.json\n    config\u002F\n      vitest\u002F\n        base.config.ts\n        react.config.ts\n        node.config.ts\n      tsconfig\u002F\n        base.json\n        react.json\n        node.json\n      package.json\n```\n\n## Turbo Pipeline Configuration\n\n### turbo.json with Test Pipelines\n\n```json\n{\n  \"$schema\": \"https:\u002F\u002Fturbo.build\u002Fschema.json\",\n  \"globalDependencies\": [\"**\u002F.env.*local\"],\n  \"globalEnv\": [\"NODE_ENV\", \"CI\"],\n  \"pipeline\": {\n    \"build\": {\n      \"dependsOn\": [\"^build\"],\n      \"outputs\": [\"dist\u002F**\", \".next\u002F**\", \"!.next\u002Fcache\u002F**\"]\n    },\n    \"test\": {\n      \"dependsOn\": [\"^build\"],\n      \"outputs\": [\"coverage\u002F**\"],\n      \"inputs\": [\n        \"src\u002F**\",\n        \"__tests__\u002F**\",\n        \"vitest.config.*\",\n        \"tsconfig.json\"\n      ],\n      \"env\": [\"DATABASE_URL\", \"TEST_DATABASE_URL\"]\n    },\n    \"test:unit\": {\n      \"dependsOn\": [\"^build\"],\n      \"outputs\": [\"coverage\u002F**\"],\n      \"inputs\": [\n        \"src\u002F**\",\n        \"__tests__\u002Funit\u002F**\",\n        \"vitest.config.*\"\n      ]\n    },\n    \"test:integration\": {\n      \"dependsOn\": [\"^build\"],\n      \"outputs\": [\"coverage\u002F**\"],\n      \"inputs\": [\n        \"src\u002F**\",\n        \"__tests__\u002Fintegration\u002F**\",\n        \"vitest.config.*\"\n      ],\n      \"env\": [\"DATABASE_URL\", \"TEST_DATABASE_URL\"]\n    },\n    \"test:e2e\": {\n      \"dependsOn\": [\"^build\", \"build\"],\n      \"outputs\": [\"test-results\u002F**\", \"playwright-report\u002F**\"],\n      \"inputs\": [\n        \"e2e\u002F**\",\n        \"playwright.config.*\",\n        \"src\u002F**\"\n      ]\n    },\n    \"lint\": {\n      \"dependsOn\": [\"^build\"],\n      \"inputs\": [\n        \"src\u002F**\",\n        \"__tests__\u002F**\",\n        \"e2e\u002F**\",\n        \".eslintrc.*\",\n        \"eslint.config.*\"\n      ]\n    },\n    \"typecheck\": {\n      \"dependsOn\": [\"^build\"],\n      \"inputs\": [\n        \"src\u002F**\",\n        \"__tests__\u002F**\",\n        \"tsconfig.json\"\n      ]\n    }\n  }\n}\n```\n\n### Vitest Workspace Configuration\n\n```typescript\n\u002F\u002F vitest.workspace.ts (root)\nimport { defineWorkspace } from 'vitest\u002Fconfig';\n\nexport default defineWorkspace([\n  'packages\u002Fshared\u002Fvitest.config.ts',\n  'packages\u002Fweb\u002Fvitest.config.ts',\n  'packages\u002Fapi\u002Fvitest.config.ts',\n]);\n```\n\n### Shared Base Vitest Config\n\n```typescript\n\u002F\u002F packages\u002Fconfig\u002Fvitest\u002Fbase.config.ts\nimport { defineConfig } from 'vitest\u002Fconfig';\n\nexport default defineConfig({\n  test: {\n    globals: true,\n    clearMocks: true,\n    restoreMocks: true,\n    coverage: {\n      provider: 'v8',\n      reporter: ['text', 'json', 'html', 'lcov'],\n      exclude: [\n        'node_modules\u002F',\n        'dist\u002F',\n        '**\u002F*.d.ts',\n        '**\u002F*.config.*',\n        '**\u002Findex.ts',\n        '**\u002F__tests__\u002F**',\n        '**\u002Ftest-utils\u002F**',\n      ],\n      thresholds: {\n        branches: 80,\n        functions: 80,\n        lines: 80,\n        statements: 80,\n      },\n    },\n    reporters: process.env.CI\n      ? ['default', 'junit']\n      : ['default'],\n    outputFile: process.env.CI\n      ? { junit: '.\u002Ftest-results\u002Fjunit.xml' }\n      : undefined,\n  },\n});\n```\n\n### Package-Level Vitest Config\n\n```typescript\n\u002F\u002F packages\u002Fapi\u002Fvitest.config.ts\nimport { defineConfig, mergeConfig } from 'vitest\u002Fconfig';\nimport baseConfig from '@repo\u002Fconfig\u002Fvitest\u002Fbase.config';\n\nexport default mergeConfig(\n  baseConfig,\n  defineConfig({\n    test: {\n      environment: 'node',\n      include: ['__tests__\u002F**\u002F*.test.ts'],\n      setupFiles: ['__tests__\u002Fsetup.ts'],\n      testTimeout: 10000,\n      pool: 'forks',\n      poolOptions: {\n        forks: {\n          singleFork: false,\n        },\n      },\n    },\n  })\n);\n```\n\n```typescript\n\u002F\u002F packages\u002Fweb\u002Fvitest.config.ts\nimport { defineConfig, mergeConfig } from 'vitest\u002Fconfig';\nimport react from '@vitejs\u002Fplugin-react';\nimport baseConfig from '@repo\u002Fconfig\u002Fvitest\u002Fbase.config';\n\nexport default mergeConfig(\n  baseConfig,\n  defineConfig({\n    plugins: [react()],\n    test: {\n      environment: 'jsdom',\n      include: ['__tests__\u002F**\u002F*.test.{ts,tsx}'],\n      setupFiles: ['__tests__\u002Fsetup.ts'],\n      css: true,\n    },\n  })\n);\n```\n\n## Shared Test Utilities Package\n\n### Package Configuration\n\n```json\n{\n  \"name\": \"@repo\u002Ftest-utils\",\n  \"version\": \"0.0.0\",\n  \"private\": true,\n  \"main\": \".\u002Fsrc\u002Findex.ts\",\n  \"types\": \".\u002Fsrc\u002Findex.ts\",\n  \"exports\": {\n    \".\": \".\u002Fsrc\u002Findex.ts\",\n    \".\u002Ffixtures\": \".\u002Fsrc\u002Ffixtures\u002Findex.ts\",\n    \".\u002Fmocks\": \".\u002Fsrc\u002Fmocks\u002Findex.ts\",\n    \".\u002Fhelpers\": \".\u002Fsrc\u002Fhelpers\u002Findex.ts\"\n  },\n  \"dependencies\": {\n    \"@testing-library\u002Freact\": \"^16.0.0\",\n    \"@testing-library\u002Fjest-dom\": \"^6.0.0\",\n    \"msw\": \"^2.0.0\"\n  },\n  \"peerDependencies\": {\n    \"vitest\": \"^2.0.0\"\n  }\n}\n```\n\n### Shared Fixtures\n\n```typescript\n\u002F\u002F packages\u002Ftest-utils\u002Fsrc\u002Ffixtures\u002Fuser.fixture.ts\nimport { faker } from '@faker-js\u002Ffaker';\n\nexport interface TestUser {\n  id: string;\n  email: string;\n  name: string;\n  role: 'admin' | 'user' | 'editor';\n  createdAt: Date;\n}\n\nexport function createTestUser(overrides: Partial\u003CTestUser> = {}): TestUser {\n  return {\n    id: faker.string.uuid(),\n    email: faker.internet.email(),\n    name: faker.person.fullName(),\n    role: 'user',\n    createdAt: faker.date.recent(),\n    ...overrides,\n  };\n}\n\nexport function createTestUsers(count: number, overrides: Partial\u003CTestUser> = {}): TestUser[] {\n  return Array.from({ length: count }, () => createTestUser(overrides));\n}\n\nexport const adminUser = createTestUser({ role: 'admin', email: 'admin@test.com' });\nexport const regularUser = createTestUser({ role: 'user', email: 'user@test.com' });\n```\n\n```typescript\n\u002F\u002F packages\u002Ftest-utils\u002Fsrc\u002Ffixtures\u002Fproduct.fixture.ts\nimport { faker } from '@faker-js\u002Ffaker';\n\nexport interface TestProduct {\n  id: string;\n  name: string;\n  price: number;\n  category: string;\n  inStock: boolean;\n}\n\nexport function createTestProduct(overrides: Partial\u003CTestProduct> = {}): TestProduct {\n  return {\n    id: faker.string.uuid(),\n    name: faker.commerce.productName(),\n    price: parseFloat(faker.commerce.price({ min: 1, max: 500 })),\n    category: faker.commerce.department(),\n    inStock: true,\n    ...overrides,\n  };\n}\n```\n\n### Shared Mock Utilities\n\n```typescript\n\u002F\u002F packages\u002Ftest-utils\u002Fsrc\u002Fmocks\u002Fapi-client.mock.ts\nimport { http, HttpResponse } from 'msw';\nimport { setupServer } from 'msw\u002Fnode';\nimport { createTestUser, createTestProduct } from '..\u002Ffixtures';\n\nexport const handlers = [\n  http.get('\u002Fapi\u002Fusers', () => {\n    return HttpResponse.json({\n      users: [createTestUser(), createTestUser()],\n      total: 2,\n    });\n  }),\n\n  http.get('\u002Fapi\u002Fusers\u002F:id', ({ params }) => {\n    return HttpResponse.json(\n      createTestUser({ id: params.id as string })\n    );\n  }),\n\n  http.post('\u002Fapi\u002Fusers', async ({ request }) => {\n    const body = await request.json() as Record\u003Cstring, unknown>;\n    return HttpResponse.json(\n      createTestUser(body),\n      { status: 201 }\n    );\n  }),\n\n  http.get('\u002Fapi\u002Fproducts', () => {\n    return HttpResponse.json({\n      products: [createTestProduct(), createTestProduct()],\n      total: 2,\n    });\n  }),\n];\n\nexport const server = setupServer(...handlers);\n\nexport function setupMockServer() {\n  beforeAll(() => server.listen({ onUnhandledRequest: 'error' }));\n  afterEach(() => server.resetHandlers());\n  afterAll(() => server.close());\n}\n```\n\n### Shared React Testing Helpers\n\n```typescript\n\u002F\u002F packages\u002Ftest-utils\u002Fsrc\u002Fhelpers\u002Frender.tsx\nimport React, { ReactElement } from 'react';\nimport { render, RenderOptions } from '@testing-library\u002Freact';\nimport userEvent from '@testing-library\u002Fuser-event';\n\n\u002F\u002F Add your app-wide providers here\nfunction AllProviders({ children }: { children: React.ReactNode }) {\n  return (\n    \u003C>\n      {children}\n    \u003C\u002F>\n  );\n}\n\nexport function renderWithProviders(\n  ui: ReactElement,\n  options?: Omit\u003CRenderOptions, 'wrapper'>\n) {\n  const user = userEvent.setup();\n  return {\n    user,\n    ...render(ui, { wrapper: AllProviders, ...options }),\n  };\n}\n\nexport { render, screen, waitFor, within } from '@testing-library\u002Freact';\nexport { userEvent };\n```\n\n## Affected Package Testing\n\n### Running Tests Only for Changed Packages\n\n```bash\n# Run tests only for packages affected by changes since main\npnpm turbo test --filter=...[origin\u002Fmain]\n\n# Run tests for a specific package and its dependents\npnpm turbo test --filter=@repo\u002Fshared...\n\n# Run tests for packages affected by changes in the last commit\npnpm turbo test --filter=...[HEAD~1]\n\n# Dry run to see what would be tested\npnpm turbo test --filter=...[origin\u002Fmain] --dry-run\n```\n\n### CI Script for Affected Testing\n\n```typescript\n\u002F\u002F scripts\u002Frun-affected-tests.ts\nimport { execSync } from 'child_process';\n\nfunction getAffectedPackages(): string[] {\n  const baseBranch = process.env.BASE_BRANCH || 'origin\u002Fmain';\n\n  try {\n    const output = execSync(\n      `pnpm turbo test --filter=...[${baseBranch}] --dry-run=json`,\n      { encoding: 'utf-8' }\n    );\n\n    const result = JSON.parse(output);\n    return result.packages || [];\n  } catch {\n    console.warn('Could not determine affected packages, running all tests');\n    return ['*'];\n  }\n}\n\nfunction runAffectedTests(): void {\n  const affected = getAffectedPackages();\n\n  if (affected.length === 0) {\n    console.log('No packages affected, skipping tests');\n    process.exit(0);\n  }\n\n  console.log(`Running tests for affected packages: ${affected.join(', ')}`);\n\n  const filterArgs = affected\n    .map((pkg) => `--filter=${pkg}`)\n    .join(' ');\n\n  try {\n    execSync(`pnpm turbo test ${filterArgs}`, {\n      stdio: 'inherit',\n    });\n  } catch {\n    process.exit(1);\n  }\n}\n\nrunAffectedTests();\n```\n\n## Cross-Package Integration Testing\n\n### Integration Test for Shared + API\n\n```typescript\n\u002F\u002F packages\u002Fapi\u002F__tests__\u002Fintegration\u002Fshared-integration.test.ts\nimport { describe, it, expect, beforeAll } from 'vitest';\nimport { parseSkillMd, serializeSkillMd } from '@repo\u002Fshared';\nimport { SkillService } from '..\u002F..\u002Fsrc\u002Fservices\u002Fskill-service';\nimport { createTestDatabase, cleanupDatabase } from '@repo\u002Ftest-utils\u002Fhelpers';\n\ndescribe('Shared + API Integration', () => {\n  let db: ReturnType\u003Ctypeof createTestDatabase>;\n\n  beforeAll(async () => {\n    db = await createTestDatabase();\n  });\n\n  afterAll(async () => {\n    await cleanupDatabase(db);\n  });\n\n  it('should parse SKILL.md and store in database via service', async () => {\n    const markdown = `---\nname: \"Test Skill\"\ndescription: \"A test skill for integration testing\"\nversion: 1.0.0\nauthor: test\ntags: [testing]\ntestingTypes: [unit]\nframeworks: [vitest]\nlanguages: [typescript]\ndomains: [web]\nagents: [claude-code]\n---\n\n# Test Skill\n\nThis is a test skill body.\n`;\n\n    \u002F\u002F Uses @repo\u002Fshared parser\n    const parsed = parseSkillMd(markdown);\n    expect(parsed.frontmatter.name).toBe('Test Skill');\n\n    \u002F\u002F Uses API service to store\n    const service = new SkillService(db);\n    const stored = await service.createSkill(parsed);\n\n    expect(stored.id).toBeDefined();\n    expect(stored.name).toBe('Test Skill');\n\n    \u002F\u002F Round-trip: retrieve and serialize back\n    const retrieved = await service.getSkill(stored.id);\n    const serialized = serializeSkillMd(retrieved);\n\n    expect(serialized).toContain('name: \"Test Skill\"');\n    expect(serialized).toContain('# Test Skill');\n  });\n\n  it('should validate shared types are compatible with API endpoints', async () => {\n    const service = new SkillService(db);\n\n    const skills = await service.listSkills({\n      testingTypes: ['unit'],\n      languages: ['typescript'],\n      page: 1,\n      limit: 10,\n    });\n\n    \u002F\u002F Verify the response matches the shared SkillSummary type\n    for (const skill of skills.items) {\n      expect(skill).toHaveProperty('id');\n      expect(skill).toHaveProperty('name');\n      expect(skill).toHaveProperty('description');\n      expect(skill).toHaveProperty('version');\n      expect(Array.isArray(skill.tags)).toBe(true);\n      expect(Array.isArray(skill.testingTypes)).toBe(true);\n    }\n  });\n});\n```\n\n### Integration Test for Web + API\n\n```typescript\n\u002F\u002F packages\u002Fweb\u002F__tests__\u002Fintegration\u002Fapi-integration.test.ts\nimport { describe, it, expect, beforeAll, afterAll } from 'vitest';\nimport { createTestUser, createTestProduct } from '@repo\u002Ftest-utils\u002Ffixtures';\nimport { server } from '@repo\u002Ftest-utils\u002Fmocks';\n\ndescribe('Web + API Integration', () => {\n  beforeAll(() => server.listen());\n  afterAll(() => server.close());\n\n  it('should fetch and transform API data for UI rendering', async () => {\n    const response = await fetch('\u002Fapi\u002Fusers');\n    const data = await response.json();\n\n    expect(data.users).toHaveLength(2);\n    expect(data.users[0]).toHaveProperty('name');\n    expect(data.users[0]).toHaveProperty('email');\n  });\n\n  it('should handle API error responses gracefully', async () => {\n    server.use(\n      http.get('\u002Fapi\u002Fusers', () => {\n        return HttpResponse.json(\n          { error: 'Internal Server Error' },\n          { status: 500 }\n        );\n      })\n    );\n\n    const response = await fetch('\u002Fapi\u002Fusers');\n    expect(response.status).toBe(500);\n\n    const data = await response.json();\n    expect(data.error).toBe('Internal Server Error');\n  });\n});\n```\n\n## E2E Testing in a Monorepo\n\n### Playwright Config with Monorepo Awareness\n\n```typescript\n\u002F\u002F packages\u002Fweb\u002Fplaywright.config.ts\nimport { defineConfig, devices } from '@playwright\u002Ftest';\nimport path from 'path';\n\nexport default defineConfig({\n  testDir: '.\u002Fe2e',\n  fullyParallel: true,\n  forbidOnly: !!process.env.CI,\n  retries: process.env.CI ? 2 : 0,\n  workers: process.env.CI ? 1 : undefined,\n  reporter: [\n    ['html', { outputFolder: path.join(__dirname, 'playwright-report') }],\n    process.env.CI ? ['github'] : ['list'],\n  ],\n  use: {\n    baseURL: process.env.BASE_URL || 'http:\u002F\u002Flocalhost:3000',\n    trace: 'on-first-retry',\n    screenshot: 'only-on-failure',\n  },\n  projects: [\n    {\n      name: 'chromium',\n      use: { ...devices['Desktop Chrome'] },\n    },\n    {\n      name: 'firefox',\n      use: { ...devices['Desktop Firefox'] },\n    },\n    {\n      name: 'mobile-chrome',\n      use: { ...devices['Pixel 7'] },\n    },\n  ],\n  webServer: {\n    command: 'pnpm turbo build --filter=@repo\u002Fweb && pnpm turbo start --filter=@repo\u002Fweb',\n    url: 'http:\u002F\u002Flocalhost:3000',\n    reuseExistingServer: !process.env.CI,\n    timeout: 120000,\n  },\n});\n```\n\n## CI Configuration with Turbo Cache\n\n### GitHub Actions Workflow\n\n```yaml\n# .github\u002Fworkflows\u002Ftest.yml\nname: Test\n\non:\n  pull_request:\n    branches: [main]\n  push:\n    branches: [main]\n\nconcurrency:\n  group: ${{ github.workflow }}-${{ github.ref }}\n  cancel-in-progress: true\n\njobs:\n  test:\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        node-version: [20]\n\n    steps:\n      - uses: actions\u002Fcheckout@v4\n        with:\n          fetch-depth: 0  # Full history for affected detection\n\n      - uses: pnpm\u002Faction-setup@v4\n        with:\n          version: 9\n\n      - uses: actions\u002Fsetup-node@v4\n        with:\n          node-version: ${{ matrix.node-version }}\n          cache: 'pnpm'\n\n      - name: Install dependencies\n        run: pnpm install --frozen-lockfile\n\n      # Turbo remote cache\n      - name: Configure Turbo cache\n        uses: actions\u002Fcache@v4\n        with:\n          path: node_modules\u002F.cache\u002Fturbo\n          key: turbo-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.sha }}\n          restore-keys: |\n            turbo-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}-\n            turbo-${{ runner.os }}-\n\n      # Run only affected unit and integration tests\n      - name: Run affected tests\n        run: pnpm turbo test:unit test:integration --filter=...[origin\u002Fmain]\n\n      # Always run full lint\n      - name: Lint\n        run: pnpm turbo lint\n\n      # Type checking\n      - name: Type check\n        run: pnpm turbo typecheck\n\n      # Upload coverage from all packages\n      - name: Upload coverage\n        if: always()\n        uses: actions\u002Fupload-artifact@v4\n        with:\n          name: coverage-reports\n          path: packages\u002F*\u002Fcoverage\u002F\n\n  e2e:\n    runs-on: ubuntu-latest\n    needs: test\n    steps:\n      - uses: actions\u002Fcheckout@v4\n      - uses: pnpm\u002Faction-setup@v4\n        with:\n          version: 9\n      - uses: actions\u002Fsetup-node@v4\n        with:\n          node-version: 20\n          cache: 'pnpm'\n\n      - name: Install dependencies\n        run: pnpm install --frozen-lockfile\n\n      - name: Install Playwright browsers\n        run: pnpm --filter @repo\u002Fweb exec playwright install --with-deps\n\n      - name: Build all packages\n        run: pnpm turbo build\n\n      - name: Run E2E tests\n        run: pnpm turbo test:e2e\n\n      - name: Upload E2E report\n        if: always()\n        uses: actions\u002Fupload-artifact@v4\n        with:\n          name: playwright-report\n          path: packages\u002Fweb\u002Fplaywright-report\u002F\n```\n\n## Package Scripts Configuration\n\n### Root package.json Scripts\n\n```json\n{\n  \"scripts\": {\n    \"dev\": \"turbo dev\",\n    \"build\": \"turbo build\",\n    \"test\": \"turbo test\",\n    \"test:unit\": \"turbo test:unit\",\n    \"test:integration\": \"turbo test:integration\",\n    \"test:e2e\": \"turbo test:e2e\",\n    \"test:affected\": \"turbo test --filter=...[origin\u002Fmain]\",\n    \"test:watch\": \"vitest --workspace=vitest.workspace.ts\",\n    \"test:coverage\": \"turbo test -- --coverage\",\n    \"lint\": \"turbo lint\",\n    \"typecheck\": \"turbo typecheck\",\n    \"format\": \"prettier --write .\",\n    \"format:check\": \"prettier --check .\",\n    \"clean\": \"turbo clean && rm -rf node_modules\"\n  }\n}\n```\n\n### Individual Package Scripts\n\n```json\n{\n  \"name\": \"@repo\u002Fapi\",\n  \"scripts\": {\n    \"dev\": \"tsx watch src\u002Fserver.ts\",\n    \"build\": \"tsup src\u002Findex.ts\",\n    \"test\": \"vitest run\",\n    \"test:unit\": \"vitest run __tests__\u002Funit\",\n    \"test:integration\": \"vitest run __tests__\u002Fintegration\",\n    \"test:watch\": \"vitest\",\n    \"test:coverage\": \"vitest run --coverage\",\n    \"lint\": \"eslint src __tests__\",\n    \"typecheck\": \"tsc --noEmit\",\n    \"clean\": \"rm -rf dist coverage\"\n  }\n}\n```\n\n## Workspace Dependency Testing\n\n### Verifying Internal Dependencies Resolve Correctly\n\n```typescript\n\u002F\u002F packages\u002Fapi\u002F__tests__\u002Funit\u002Fdependencies.test.ts\nimport { describe, it, expect } from 'vitest';\n\ndescribe('Workspace Dependency Resolution', () => {\n  it('should import shared types correctly', async () => {\n    const shared = await import('@repo\u002Fshared');\n\n    expect(shared).toHaveProperty('parseSkillMd');\n    expect(shared).toHaveProperty('serializeSkillMd');\n    expect(typeof shared.parseSkillMd).toBe('function');\n  });\n\n  it('should import test-utils fixtures', async () => {\n    const { createTestUser } = await import('@repo\u002Ftest-utils\u002Ffixtures');\n\n    const user = createTestUser();\n    expect(user).toHaveProperty('id');\n    expect(user).toHaveProperty('email');\n    expect(user).toHaveProperty('name');\n  });\n\n  it('should verify shared constants are accessible', async () => {\n    const { AGENTS, CATEGORIES } = await import('@repo\u002Fshared');\n\n    expect(Array.isArray(AGENTS)).toBe(true);\n    expect(AGENTS.length).toBeGreaterThan(0);\n    expect(Array.isArray(CATEGORIES)).toBe(true);\n  });\n\n  it('should verify shared schemas validate correctly', async () => {\n    const { skillFrontmatterSchema } = await import('@repo\u002Fshared');\n\n    const validData = {\n      name: 'Test Skill',\n      description: 'A valid description that is long enough',\n      version: '1.0.0',\n      author: 'test',\n      tags: ['testing'],\n      testingTypes: ['unit'],\n      frameworks: ['vitest'],\n      languages: ['typescript'],\n      domains: ['web'],\n      agents: ['claude-code'],\n    };\n\n    const result = skillFrontmatterSchema.safeParse(validData);\n    expect(result.success).toBe(true);\n  });\n});\n```\n\n### Testing Build Output Compatibility\n\n```typescript\n\u002F\u002F scripts\u002Fverify-build-outputs.test.ts\nimport { describe, it, expect } from 'vitest';\nimport { existsSync, readFileSync } from 'fs';\nimport path from 'path';\n\ndescribe('Build Output Verification', () => {\n  const packages = ['shared', 'cli', 'sdk', 'api'];\n\n  for (const pkg of packages) {\n    const distPath = path.join(__dirname, '..', 'packages', pkg, 'dist');\n\n    it(`${pkg}: dist directory should exist after build`, () => {\n      expect(existsSync(distPath)).toBe(true);\n    });\n\n    it(`${pkg}: should have a valid entry point`, () => {\n      const pkgJsonPath = path.join(__dirname, '..', 'packages', pkg, 'package.json');\n      const pkgJson = JSON.parse(readFileSync(pkgJsonPath, 'utf-8'));\n\n      const mainEntry = pkgJson.main || pkgJson.exports?.['.'];\n      expect(mainEntry).toBeDefined();\n\n      const resolvedEntry = path.join(__dirname, '..', 'packages', pkg, mainEntry);\n      expect(existsSync(resolvedEntry)).toBe(true);\n    });\n\n    it(`${pkg}: TypeScript declarations should be present`, () => {\n      const dtsFiles = require('fast-glob').sync('**\u002F*.d.ts', { cwd: distPath });\n      expect(dtsFiles.length).toBeGreaterThan(0);\n    });\n  }\n});\n```\n\n## Test Database Management for Integration Tests\n\n```typescript\n\u002F\u002F packages\u002Ftest-utils\u002Fsrc\u002Fhelpers\u002Fsetup-database.ts\nimport { execSync } from 'child_process';\nimport { randomUUID } from 'crypto';\n\ninterface TestDatabaseConfig {\n  connectionString: string;\n  databaseName: string;\n  cleanup: () => Promise\u003Cvoid>;\n}\n\nexport async function createTestDatabase(): Promise\u003CTestDatabaseConfig> {\n  const baseName = 'test_db';\n  const databaseName = `${baseName}_${randomUUID().slice(0, 8)}`;\n  const baseUrl = process.env.TEST_DATABASE_URL || 'postgresql:\u002F\u002Flocalhost:5432';\n\n  \u002F\u002F Create isolated test database\n  execSync(`createdb ${databaseName}`, {\n    env: { ...process.env, PGHOST: 'localhost' },\n  });\n\n  const connectionString = `${baseUrl}\u002F${databaseName}`;\n\n  \u002F\u002F Run migrations\n  execSync('pnpm drizzle-kit push', {\n    env: { ...process.env, DATABASE_URL: connectionString },\n    cwd: process.cwd(),\n  });\n\n  return {\n    connectionString,\n    databaseName,\n    cleanup: async () => {\n      execSync(`dropdb --if-exists ${databaseName}`, {\n        env: { ...process.env, PGHOST: 'localhost' },\n      });\n    },\n  };\n}\n```\n\n## Parallel Test Execution Strategies\n\n```typescript\n\u002F\u002F packages\u002Fapi\u002F__tests__\u002Fsetup.ts\nimport { beforeAll, afterAll } from 'vitest';\nimport { server } from '@repo\u002Ftest-utils\u002Fmocks';\n\n\u002F\u002F Each worker gets its own mock server\nbeforeAll(() => {\n  server.listen({ onUnhandledRequest: 'warn' });\n});\n\nafterAll(() => {\n  server.close();\n});\n```\n\n```typescript\n\u002F\u002F vitest.config.ts with parallel configuration\nimport { defineConfig } from 'vitest\u002Fconfig';\n\nexport default defineConfig({\n  test: {\n    \u002F\u002F Run test files in parallel (default)\n    fileParallelism: true,\n\n    \u002F\u002F Each test file runs in its own worker thread\n    pool: 'threads',\n    poolOptions: {\n      threads: {\n        \u002F\u002F Match CPU core count for optimal parallelism\n        minThreads: 1,\n        maxThreads: process.env.CI ? 4 : undefined,\n      },\n    },\n\n    \u002F\u002F Isolate each test file to prevent state leakage\n    isolate: true,\n\n    \u002F\u002F Sequence configuration for deterministic order when needed\n    sequence: {\n      shuffle: true, \u002F\u002F Randomize to detect order dependencies\n    },\n  },\n});\n```\n\n## Coverage Aggregation Across Packages\n\n```typescript\n\u002F\u002F scripts\u002Fmerge-coverage.ts\nimport { execSync } from 'child_process';\nimport { existsSync, mkdirSync } from 'fs';\nimport path from 'path';\n\nconst rootDir = path.resolve(__dirname, '..');\nconst mergedDir = path.join(rootDir, 'coverage-merged');\n\nif (!existsSync(mergedDir)) {\n  mkdirSync(mergedDir, { recursive: true });\n}\n\nconst packages = ['shared', 'web', 'api', 'cli', 'sdk'];\n\n\u002F\u002F Collect all coverage JSON files\nconst coverageFiles = packages\n  .map((pkg) => path.join(rootDir, 'packages', pkg, 'coverage', 'coverage-final.json'))\n  .filter((f) => existsSync(f));\n\nif (coverageFiles.length === 0) {\n  console.log('No coverage files found. Run tests with coverage first.');\n  process.exit(0);\n}\n\n\u002F\u002F Merge using nyc\nconst fileArgs = coverageFiles.map((f) => `--include=\"${f}\"`).join(' ');\nexecSync(\n  `npx nyc merge ${coverageFiles.map((f) => path.dirname(f)).join(' ')} ${mergedDir}\u002Fcoverage.json`,\n  { stdio: 'inherit' }\n);\n\n\u002F\u002F Generate merged report\nexecSync(\n  `npx nyc report --temp-dir=${mergedDir} --reporter=text --reporter=html --report-dir=${mergedDir}\u002Fhtml`,\n  { stdio: 'inherit' }\n);\n\nconsole.log(`Merged coverage report generated at ${mergedDir}\u002Fhtml\u002Findex.html`);\n```\n\n## Best Practices\n\n1. **Define explicit test inputs in turbo.json** -- Always list the `inputs` array for test tasks so Turbo can compute hashes correctly. Missing inputs cause stale cache hits.\n2. **Use workspace protocol for internal dependencies** -- Use `\"@repo\u002Fshared\": \"workspace:*\"` in package.json to ensure pnpm links internal packages instead of fetching from npm.\n3. **Create a dedicated test-utils package** -- Extract shared fixtures, mocks, and helpers into `@repo\u002Ftest-utils` instead of duplicating across packages.\n4. **Run affected tests in CI, full suite on main** -- Use `--filter=...[origin\u002Fmain]` on PRs but run the full `pnpm turbo test` on main branch merges.\n5. **Cache test results in CI** -- Store and restore `node_modules\u002F.cache\u002Fturbo` between CI runs. Turbo will skip unchanged packages.\n6. **Isolate integration tests with separate databases** -- Each integration test suite should create and destroy its own test database to enable parallel execution.\n7. **Use Vitest workspace mode for development** -- Run `vitest --workspace=vitest.workspace.ts` in watch mode during development to get instant feedback across all packages.\n8. **Set coverage thresholds per package** -- Different packages have different test priorities. Set appropriate thresholds in each package's vitest config rather than one global number.\n9. **Type-check as a separate pipeline task** -- Run `tsc --noEmit` as a separate Turbo task (`typecheck`) instead of bundling it with tests. It catches different classes of errors.\n10. **Pin exact versions of shared dev dependencies** -- Use the same versions of vitest, typescript, and eslint across all packages via a root `pnpm-workspace.yaml` catalog or `syncpack`.\n\n## Anti-Patterns to Avoid\n\n1. **Running all tests on every change** -- Without `--filter`, Turbo runs every package's tests. Always use affected detection for PRs.\n2. **Importing from package dist instead of source** -- In a monorepo, internal packages should resolve to source (via `main: .\u002Fsrc\u002Findex.ts`), not compiled output, during development and testing.\n3. **Sharing mutable test state across packages** -- Global test state that leaks across workspace boundaries causes flaky and order-dependent tests.\n4. **Missing `dependsOn: [\"^build\"]` for test tasks** -- If test tasks don't depend on upstream builds, shared package changes won't be picked up, causing false positives.\n5. **Duplicating test configuration in every package** -- Maintain base configs in a shared config package and use `mergeConfig` to extend per-package.\n6. **Not specifying `inputs` for Turbo tasks** -- Without explicit inputs, Turbo hashes all files, causing unnecessary cache invalidation.\n7. **Using a single global vitest config** -- A root-level vitest config without workspace mode runs all tests in a single process, losing parallelism benefits.\n8. **Ignoring workspace dependency graph in E2E tests** -- E2E tests for the web app must `dependsOn: [\"build\"]` for the web package plus `[\"^build\"]` for all dependencies.\n9. **Hardcoding package paths in test scripts** -- Use workspace references (`@repo\u002Fshared`) instead of relative paths (`..\u002F..\u002Fshared\u002Fsrc`) to avoid breakage when packages move.\n10. **Not cleaning Turbo cache periodically** -- Stale cache entries accumulate over time. Add a `clean` script that removes `node_modules\u002F.cache\u002Fturbo` and run it when debugging mysterious test failures.\n\n## Running Tests\n\n- Run all tests: `pnpm turbo test`\n- Run affected tests: `pnpm turbo test --filter=...[origin\u002Fmain]`\n- Run tests for one package: `pnpm turbo test --filter=@repo\u002Fapi`\n- Run tests for a package and dependents: `pnpm turbo test --filter=@repo\u002Fshared...`\n- Watch mode across workspace: `pnpm vitest --workspace=vitest.workspace.ts`\n- View Turbo task graph: `pnpm turbo test --graph`\n- Check cache status: `pnpm turbo test --dry-run`\n- Force re-run (skip cache): `pnpm turbo test --force`\n",{"name":5,"tags":24,"agents":35,"author":48,"domains":49,"license":15,"version":52,"languages":53,"frameworks":56,"description":7,"testingTypes":60},[25,26,27,28,29,30,31,32,33,34],"turborepo","monorepo","pnpm","workspace","parallel-testing","affected","caching","ci-cd","turbo-pipeline","shared-utils",[36,37,38,39,40,41,42,43,44,45,46,47],"claude-code","cursor","github-copilot","windsurf","codex","aider","continue","cline","zed","bolt","gemini-cli","amp","thetestingacademy",[50,51],"web","api","1.0.0",[54,55],"typescript","javascript",[57,58,59],"vitest","playwright","jest",[61,62,63],"unit","integration","e2e","main","eac438ea9216a7cb8a570cab803eb01eeafc6793","skills\u002Fqa\u002Fturborepo-monorepo-testing","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m","https:\u002F\u002Fid-preview--d5bef06d-6c9e-4563-a3d4-a855b9d61610.lovable.app\u002F","Eu sou Antonio B. B. Ndombe \r\nEu sou um Pesquisador e desenvolvedor de sistema autonomia cognitivos, fundador de sistemas ODCs ( organismos digital conscientes)","2026-11-04 06:53:39",{"source":8,"skillName":5,"commands":73,"prompt":82,"zipAvailable":83},[74,77,80],{"tool":75,"command":76},"npx","npx skills add GrupoANDevelopment-m\u002Falberto-ai --skill \"Turborepo Monorepo Testing\"",{"tool":78,"command":79},"bunx","bunx skills add GrupoANDevelopment-m\u002Falberto-ai --skill \"Turborepo Monorepo Testing\"",{"tool":27,"command":81},"pnpm dlx skills add GrupoANDevelopment-m\u002Falberto-ai --skill \"Turborepo Monorepo Testing\"","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fskills\u002Fqa\u002Fturborepo-monorepo-testing\u002FSKILL.md",true,[],[86,94,101,108,115,122],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":90,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":19},"01M7DASC6FSCJP49JZBSK0NY1Z","nemoclaw-user-reference","Describes the NemoClaw integration layer and blueprint architecture and how they orchestrate compatible agent sandboxes. Use when looking up architecture, agent integration, plugin structure, or blueprint design. Trigger keywords - nemoclaw architecture, nemoclaw agent architecture, nemoclaw plugin blueprint structure, nemoclaw vs openshell, which cli, nemoclaw cli, openshell cli, sandbox commands, nemoclaw cli commands, nemoclaw command reference, nemoclaw network policy, sandbox egress control operator approval, nemoclaw troubleshooting, nemoclaw debug sandbox issues.","Apache-2.0","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-reference\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":90,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":19},"01M7DAS5S79VK33XFGVAM2TFWF","nemoclaw-user-overview","Explains how OpenClaw, OpenShell, and NemoClaw form the ecosystem, NemoClaw's position in the stack, what NemoClaw adds beyond the community sandbox, and when to prefer NemoClaw versus integrating OpenShell and OpenClaw directly. Use when users ask about the relationship between OpenClaw, OpenShell, and NemoClaw, or when to use NemoClaw versus OpenShell. Trigger keywords - nemoclaw ecosystem, openclaw openshell, nemoclaw vs openshell, sandboxed openclaw, how nemoclaw works, nemoclaw sandbox lifecycle blueprint, nemoclaw overview, openclaw always-on assistants, nvidia openshell, nvidia nemotron, nemoclaw release notes, nemoclaw changelog.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-overview\u002FSKILL.md",[],[],{"skillNo":102,"name":103,"nameZh":6,"description":104,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":90,"licenseFileUrl":6,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":19},"01M7DAS0PQEMET5MNGZ1ABSZVS","nemoclaw-user-monitor-sandbox","Inspects sandbox health, traces agent behavior, and diagnoses problems. Use when monitoring a running sandbox, debugging agent issues, or checking sandbox logs. Trigger keywords - monitor nemoclaw sandbox, debug nemoclaw agent issues.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-monitor-sandbox\u002FSKILL.md",[],[],{"skillNo":109,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":90,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":19},"01M7DARQYGF7E9A69VH6S3CGN9","nemoclaw-user-manage-sandboxes","Explains operational tasks after the quickstart: listing sandboxes, status and health checks, logs, diagnostics, port forwards, multiple sandboxes, credential reset, rebuilds, network presets, upgrades, and uninstall. Trigger keywords - manage nemoclaw sandboxes, nemoclaw status, nemoclaw list, nemoclaw dashboard port, nemoclaw rebuild, nemoclaw upgrade sandboxes, nemoclaw uninstall, sandbox mutability, sandbox runtime configuration, sandbox rebuild, nemoclaw backup, nemoclaw restore, workspace backup, openshell sandbox download upload, nemoclaw messaging channels, nemoclaw telegram, nemoclaw discord, nemoclaw slack, nemoclaw wechat, nemoclaw whatsapp, openshell channel messaging, nemoclaw workspace files, soul.md, user.md, identity.md, agents.md, sandbox persistence.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-manage-sandboxes\u002FSKILL.md",[],[],{"skillNo":116,"name":117,"nameZh":6,"description":118,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":90,"licenseFileUrl":6,"sourceHtmlUrl":119,"categories":120,"keywords":121,"publishedAt":19},"01M7DARH8BRTG51TRCAB7YWDJ4","nemoclaw-user-manage-policy","Adds, removes, or modifies allowed endpoints in the sandbox policy. Use when customizing network policy, changing egress rules, or configuring sandbox endpoint access. Trigger keywords - customize nemoclaw network policy, sandbox egress policy configuration, nemoclaw integration policy examples, post-install policy setup, openshell approval workflow, policy preset, nemoclaw approve network requests, sandbox egress approval tui.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-manage-policy\u002FSKILL.md",[],[],{"skillNo":123,"name":124,"nameZh":6,"description":125,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":90,"licenseFileUrl":6,"sourceHtmlUrl":126,"categories":127,"keywords":128,"publishedAt":19},"01M7DARAT62M2VR37590VCZ5NS","nemoclaw-user-get-started","Installs NemoClaw, launches a sandbox, and runs the first agent prompt. Use when onboarding, installing, or launching a NemoClaw sandbox for the first time. Trigger keywords - nemoclaw quickstart, install nemoclaw openclaw sandbox, nemohermes quickstart, hermes agent nemoclaw, run hermes openshell sandbox, nemoclaw prerequisites, nemoclaw supported platforms, nemoclaw hardware software, nemoclaw windows wsl2 setup, nemoclaw install windows docker desktop.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-get-started\u002FSKILL.md",[],[]]