[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M719SK11T05QYVPTWWYMYY5B":3,"skill-same:01M719SK11T05QYVPTWWYMYY5B":64},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":37,"linkOnly":38,"markdownContent":39,"markdownBody":40,"frontMatter":41,"refName":42,"commitSha":43,"skillDirectory":44,"forksCount":45,"repositoryHtmlUrl":46,"repositoryHomepageUrl":47,"ownerHtmlUrl":48,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":49,"install":50,"resources":63},"01M719SK11T05QYVPTWWYMYY5B","vitest",null,"Set up Vitest testing in any project — detects project type (Cloudflare Workers, React, Node), generates vitest.config.ts, test setup, utilities, and sample tests. Also covers mocking patterns, coverage config, workspace setup, and Jest migration. Trigger with 'set up vitest', 'add tests', 'configure vitest', 'migrate from jest', 'vitest config', 'add unit tests', or 'testing setup'.","dahaliztupe-sketch\u002FKalmeron-Two","dahaliztupe-sketch","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F271085317?v=4","01M719765Q83P08JCQ1SWNQR0N","01M719766HQBGF44W90MPJKTD2",1,"MIT","https:\u002F\u002Fgithub.com\u002Fdahaliztupe-sketch\u002FKalmeron-Two\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fvitest\u002FSKILL.md",[],[5,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],"migrate","patterns","test setup","Utilities","cloudflare workers","config","node","sample","react","jest","configure","cloudflare","up","testing","workspace setup","project","unit","SET","coverage","2026-11-10 10:12:30",false,"---\nname: vitest\ndescription: \"Set up Vitest testing in any project — detects project type (Cloudflare Workers, React, Node), generates vitest.config.ts, test setup, utilities, and sample tests. Also covers mocking patterns, coverage config, workspace setup, and Jest migration. Trigger with 'set up vitest', 'add tests', 'configure vitest', 'migrate from jest', 'vitest config', 'add unit tests', or 'testing setup'.\"\nlicense: MIT\n---\n\n# Vitest Setup\n\nDetect the project type, generate the right Vitest configuration, and produce working test infrastructure. Not a reference card — this skill creates files.\n\n## Workflow\n\n1. **Detect** — scan the project to determine type and existing setup\n2. **Configure** — generate vitest.config.ts tailored to the environment\n3. **Scaffold** — create test setup, utilities, and a sample test\n4. **Wire up** — add package.json scripts and TypeScript config\n\n## Step 1: Detect Project Type\n\nRead these files to determine the project:\n\n```\npackage.json          → dependencies, scripts, type field\ntsconfig.json         → paths, compiler options\nwrangler.toml         → Cloudflare Workers project\nvite.config.ts        → existing Vite setup (extend, don't replace)\nvitest.config.ts      → already configured? just fill gaps\njest.config.*         → migration candidate\nsrc\u002F                  → source structure\n```\n\nClassify as one of:\n\n| Type | Signals | Environment |\n|------|---------|-------------|\n| **Cloudflare Workers** | wrangler.toml, @cloudflare\u002Fworkers-types, cloudflare vite plugin | `node` with Workers-specific setup |\n| **React (Vite)** | @vitejs\u002Fplugin-react, react-dom | `jsdom` or `happy-dom` |\n| **React (SSR\u002FTanStack Start)** | @tanstack\u002Fstart, vinxi | Split: `node` for server, `jsdom` for client |\n| **Node\u002FHono API** | hono, express, no react-dom | `node` |\n| **Library** | exports field, no framework deps | `node` |\n\nIf a `vite.config.ts` already exists, extend it rather than creating a separate vitest.config.ts — Vitest reads Vite config natively.\n\n## Step 2: Install Dependencies\n\nGenerate the install command based on detected type:\n\n```bash\n# Base (always)\npnpm add -D vitest\n\n# React projects — add jsdom and Testing Library\npnpm add -D @vitest\u002Fcoverage-v8 jsdom @testing-library\u002Freact @testing-library\u002Fjest-dom @testing-library\u002Fuser-event\n\n# Workers projects — add Cloudflare test utilities\npnpm add -D @vitest\u002Fcoverage-v8 @cloudflare\u002Fvitest-pool-workers\n\n# Node\u002FHono projects\npnpm add -D @vitest\u002Fcoverage-v8\n\n# If migrating from Jest, also remove:\npnpm remove jest ts-jest @types\u002Fjest jest-environment-jsdom babel-jest\n```\n\nUse the project's package manager (check for pnpm-lock.yaml, yarn.lock, bun.lockb, or package-lock.json).\n\n## Step 3: Generate vitest.config.ts\n\n### Cloudflare Workers\n\n```typescript\nimport { defineWorkersConfig } from \"@cloudflare\u002Fvitest-pool-workers\u002Fconfig\";\n\nexport default defineWorkersConfig({\n  test: {\n    globals: true,\n    poolOptions: {\n      workers: {\n        wrangler: { configPath: \".\u002Fwrangler.toml\" },\n      },\n    },\n  },\n});\n```\n\nIf the project uses the Cloudflare Vite plugin (`@cloudflare\u002Fvite-plugin`), integrate into the existing vite.config.ts instead:\n\n```typescript\n\u002F\u002F\u002F \u003Creference types=\"vitest\u002Fconfig\" \u002F>\nimport { defineConfig } from \"vite\";\nimport { cloudflare } from \"@cloudflare\u002Fvite-plugin\";\n\nexport default defineConfig({\n  plugins: [cloudflare()],\n  test: {\n    globals: true,\n  },\n});\n```\n\n### React (Vite)\n\n```typescript\n\u002F\u002F\u002F \u003Creference types=\"vitest\u002Fconfig\" \u002F>\nimport { defineConfig } from \"vite\";\nimport react from \"@vitejs\u002Fplugin-react\";\n\nexport default defineConfig({\n  plugins: [react()],\n  test: {\n    globals: true,\n    environment: \"jsdom\",\n    setupFiles: [\".\u002Fsrc\u002Ftest\u002Fsetup.ts\"],\n    css: true,\n  },\n});\n```\n\nIf a vite.config.ts already exists, add the `test` block to it rather than creating a new file.\n\n### Node \u002F Hono API\n\n```typescript\nimport { defineConfig } from \"vitest\u002Fconfig\";\n\nexport default defineConfig({\n  test: {\n    globals: true,\n    environment: \"node\",\n  },\n});\n```\n\n### With Coverage (add to any config)\n\n```typescript\n  test: {\n    \u002F\u002F ... existing config\n    coverage: {\n      provider: \"v8\",\n      reporter: [\"text\", \"html\", \"lcov\"],\n      exclude: [\n        \"node_modules\u002F\",\n        \"**\u002F*.config.*\",\n        \"**\u002F*.d.ts\",\n        \"**\u002Ftest\u002F**\",\n      ],\n    },\n  },\n```\n\n## Step 4: Generate Test Setup File\n\nCreate `src\u002Ftest\u002Fsetup.ts` (React projects only):\n\n```typescript\nimport \"@testing-library\u002Fjest-dom\u002Fvitest\";\n```\n\nThat single import adds all the custom matchers (toBeInTheDocument, toHaveTextContent, etc.) and registers the Vitest `expect.extend` automatically.\n\n## Step 5: Add TypeScript Config\n\nAdd to `tsconfig.json` compilerOptions:\n\n```json\n{\n  \"compilerOptions\": {\n    \"types\": [\"vitest\u002Fglobals\"]\n  }\n}\n```\n\nFor projects with multiple tsconfig files (e.g. tsconfig.app.json + tsconfig.node.json), add to the one that covers test files — usually the root tsconfig.json or create a tsconfig.test.json that extends it.\n\n## Step 6: Add Package.json Scripts\n\n```json\n{\n  \"scripts\": {\n    \"test\": \"vitest\",\n    \"test:run\": \"vitest run\",\n    \"test:coverage\": \"vitest run --coverage\",\n    \"test:ui\": \"vitest --ui\"\n  }\n}\n```\n\nDon't overwrite existing scripts — merge with what's there.\n\n## Step 7: Generate Sample Test\n\nWrite one test file that demonstrates the right patterns for this specific project. Place it next to real source code, not in a separate `__tests__` directory.\n\n### For a Hono API route (e.g. `src\u002Froutes\u002Fhealth.ts`):\n\n```typescript\nimport { describe, it, expect } from \"vitest\";\nimport { app } from \"..\u002Findex\";\n\ndescribe(\"GET \u002Fhealth\", () => {\n  it(\"returns 200 with status ok\", async () => {\n    const res = await app.request(\"\u002Fhealth\");\n    expect(res.status).toBe(200);\n\n    const body = await res.json();\n    expect(body).toEqual({ status: \"ok\" });\n  });\n});\n```\n\n### For a React component (e.g. `src\u002Fcomponents\u002FButton.tsx`):\n\n```typescript\nimport { describe, it, expect } from \"vitest\";\nimport { render, screen } from \"@testing-library\u002Freact\";\nimport userEvent from \"@testing-library\u002Fuser-event\";\nimport { Button } from \".\u002FButton\";\n\ndescribe(\"Button\", () => {\n  it(\"renders with label\", () => {\n    render(\u003CButton>Click me\u003C\u002FButton>);\n    expect(screen.getByRole(\"button\", { name: \u002Fclick me\u002Fi })).toBeInTheDocument();\n  });\n\n  it(\"calls onClick when clicked\", async () => {\n    const user = userEvent.setup();\n    const handleClick = vi.fn();\n    render(\u003CButton onClick={handleClick}>Click me\u003C\u002FButton>);\n\n    await user.click(screen.getByRole(\"button\"));\n    expect(handleClick).toHaveBeenCalledOnce();\n  });\n});\n```\n\n### For a utility function (e.g. `src\u002Futils\u002Fformat.ts`):\n\n```typescript\nimport { describe, it, expect } from \"vitest\";\nimport { formatCurrency } from \".\u002Fformat\";\n\ndescribe(\"formatCurrency\", () => {\n  it(\"formats whole numbers\", () => {\n    expect(formatCurrency(1000)).toBe(\"$1,000.00\");\n  });\n\n  it(\"formats decimals\", () => {\n    expect(formatCurrency(49.9)).toBe(\"$49.90\");\n  });\n\n  it(\"handles zero\", () => {\n    expect(formatCurrency(0)).toBe(\"$0.00\");\n  });\n});\n```\n\nPick a real file from the project to test. Don't invent a fake module — the sample test should run immediately after setup.\n\n## Step 8: Verify\n\nRun the tests to confirm everything works:\n\n```bash\npnpm test:run\n```\n\nIf it fails, diagnose and fix. Common issues:\n\n| Error | Fix |\n|-------|-----|\n| `Cannot find module 'vitest'` | Check install completed, check `node_modules\u002F.vitest` exists |\n| `ReferenceError: describe is not defined` | Add `globals: true` to config, or add `types: [\"vitest\u002Fglobals\"]` to tsconfig |\n| `document is not defined` | Wrong environment — set `environment: \"jsdom\"` for React tests |\n| `Cannot use import.meta` | Ensure vitest.config uses `.ts` extension and project has `\"type\": \"module\"` or Vite handles transforms |\n| Workers bindings undefined | Use `@cloudflare\u002Fvitest-pool-workers` instead of plain vitest, check wrangler.toml path |\n\n---\n\n## Mocking Reference\n\nThese patterns are for writing tests after setup is complete. Include them in the sample test or a `src\u002Ftest\u002Fexamples.test.ts` if the user asks for mocking examples.\n\n### Module mocking (vi.mock)\n\n```typescript\nimport { vi, describe, it, expect } from \"vitest\";\nimport { getUser } from \".\u002Fapi\";\n\nvi.mock(\".\u002Fapi\", () => ({\n  getUser: vi.fn(),\n}));\n\nit(\"mocks a module function\", async () => {\n  vi.mocked(getUser).mockResolvedValue({ id: 1, name: \"Test\" });\n  const user = await getUser(1);\n  expect(user.name).toBe(\"Test\");\n  expect(getUser).toHaveBeenCalledWith(1);\n});\n```\n\n### Spy on methods (vi.spyOn)\n\n```typescript\nit(\"spies on console.warn\", () => {\n  const spy = vi.spyOn(console, \"warn\").mockImplementation(() => {});\n  doSomethingThatWarns();\n  expect(spy).toHaveBeenCalledOnce();\n  spy.mockRestore();\n});\n```\n\n### Fake timers\n\n```typescript\nimport { vi, beforeEach, afterEach, it, expect } from \"vitest\";\n\nbeforeEach(() => {\n  vi.useFakeTimers();\n  vi.setSystemTime(new Date(\"2026-01-15T10:00:00Z\"));\n});\n\nafterEach(() => {\n  vi.useRealTimers();\n});\n\nit(\"uses controlled time\", () => {\n  expect(new Date().toISOString()).toBe(\"2026-01-15T10:00:00.000Z\");\n});\n```\n\n### Global stubs\n\n```typescript\nit(\"stubs fetch\", async () => {\n  const mockFetch = vi.fn().mockResolvedValue({\n    ok: true,\n    json: () => Promise.resolve({ data: \"test\" }),\n  });\n  vi.stubGlobal(\"fetch\", mockFetch);\n\n  const res = await fetch(\"\u002Fapi\u002Fdata\");\n  expect(mockFetch).toHaveBeenCalledWith(\"\u002Fapi\u002Fdata\");\n\n  vi.unstubAllGlobals();\n});\n```\n\n### Snapshot testing\n\n```typescript\nit(\"matches snapshot\", () => {\n  const result = generateConfig({ debug: true });\n  expect(result).toMatchSnapshot();\n});\n\nit(\"matches inline snapshot\", () => {\n  expect({ status: \"ok\", count: 3 }).toMatchInlineSnapshot(`\n    {\n      \"count\": 3,\n      \"status\": \"ok\",\n    }\n  `);\n});\n```\n\n### Parameterized tests\n\n```typescript\ndescribe.each([\n  { input: \"hello\", expected: \"HELLO\" },\n  { input: \"world\", expected: \"WORLD\" },\n  { input: \"\", expected: \"\" },\n])(\"toUpperCase($input)\", ({ input, expected }) => {\n  it(`returns ${expected}`, () => {\n    expect(input.toUpperCase()).toBe(expected);\n  });\n});\n```\n\n---\n\n## Jest Migration\n\nWhen the detected project has Jest (`jest.config.*`, `@types\u002Fjest`, `ts-jest` in dependencies):\n\n1. **Generate the vitest.config.ts** using the steps above\n2. **Update imports** in existing test files:\n\n```typescript\n\u002F\u002F Before\nimport { jest } from \"@jest\u002Fglobals\";\njest.mock(\".\u002Fapi\");\njest.fn();\njest.spyOn(obj, \"method\");\n\n\u002F\u002F After\nimport { vi } from \"vitest\";\nvi.mock(\".\u002Fapi\");\nvi.fn();\nvi.spyOn(obj, \"method\");\n```\n\n3. **Remove Jest packages:**\n```bash\npnpm remove jest ts-jest @types\u002Fjest jest-environment-jsdom babel-jest @jest\u002Fglobals\n```\n\n4. **Update tsconfig** — replace `\"types\": [\"jest\"]` with `\"types\": [\"vitest\u002Fglobals\"]`\n\n5. **Run tests** and fix any remaining issues\n\nKey replacements:\n\n| Jest | Vitest |\n|------|--------|\n| `jest.fn()` | `vi.fn()` |\n| `jest.mock()` | `vi.mock()` |\n| `jest.spyOn()` | `vi.spyOn()` |\n| `jest.useFakeTimers()` | `vi.useFakeTimers()` |\n| `jest.clearAllMocks()` | `vi.clearAllMocks()` |\n| `jest.requireActual()` | `vi.importActual()` |\n| `@jest\u002Fglobals` | `vitest` |\n| `jest.config.js` | `vitest.config.ts` |\n\n---\n\n## Workspace Setup (Monorepos)\n\nFor monorepo projects with multiple packages:\n\n```typescript\n\u002F\u002F vitest.workspace.ts\nimport { defineWorkspace } from \"vitest\u002Fconfig\";\n\nexport default defineWorkspace([\n  \"packages\u002F*\u002Fvitest.config.ts\",\n]);\n```\n\nEach package gets its own config. The workspace file just points to them.\n\n---\n\n## What This Skill Produces\n\nAfter running, the project should have:\n- `vitest.config.ts` (or test block added to existing vite.config.ts)\n- `src\u002Ftest\u002Fsetup.ts` (React projects)\n- Updated `tsconfig.json` with vitest\u002Fglobals type\n- Updated `package.json` with test scripts\n- At least one passing sample test against real source code\n- Dependencies installed\n\nThe tests should pass on first run. If they don't, fix them before finishing.\n","# Vitest Setup\n\nDetect the project type, generate the right Vitest configuration, and produce working test infrastructure. Not a reference card — this skill creates files.\n\n## Workflow\n\n1. **Detect** — scan the project to determine type and existing setup\n2. **Configure** — generate vitest.config.ts tailored to the environment\n3. **Scaffold** — create test setup, utilities, and a sample test\n4. **Wire up** — add package.json scripts and TypeScript config\n\n## Step 1: Detect Project Type\n\nRead these files to determine the project:\n\n```\npackage.json          → dependencies, scripts, type field\ntsconfig.json         → paths, compiler options\nwrangler.toml         → Cloudflare Workers project\nvite.config.ts        → existing Vite setup (extend, don't replace)\nvitest.config.ts      → already configured? just fill gaps\njest.config.*         → migration candidate\nsrc\u002F                  → source structure\n```\n\nClassify as one of:\n\n| Type | Signals | Environment |\n|------|---------|-------------|\n| **Cloudflare Workers** | wrangler.toml, @cloudflare\u002Fworkers-types, cloudflare vite plugin | `node` with Workers-specific setup |\n| **React (Vite)** | @vitejs\u002Fplugin-react, react-dom | `jsdom` or `happy-dom` |\n| **React (SSR\u002FTanStack Start)** | @tanstack\u002Fstart, vinxi | Split: `node` for server, `jsdom` for client |\n| **Node\u002FHono API** | hono, express, no react-dom | `node` |\n| **Library** | exports field, no framework deps | `node` |\n\nIf a `vite.config.ts` already exists, extend it rather than creating a separate vitest.config.ts — Vitest reads Vite config natively.\n\n## Step 2: Install Dependencies\n\nGenerate the install command based on detected type:\n\n```bash\n# Base (always)\npnpm add -D vitest\n\n# React projects — add jsdom and Testing Library\npnpm add -D @vitest\u002Fcoverage-v8 jsdom @testing-library\u002Freact @testing-library\u002Fjest-dom @testing-library\u002Fuser-event\n\n# Workers projects — add Cloudflare test utilities\npnpm add -D @vitest\u002Fcoverage-v8 @cloudflare\u002Fvitest-pool-workers\n\n# Node\u002FHono projects\npnpm add -D @vitest\u002Fcoverage-v8\n\n# If migrating from Jest, also remove:\npnpm remove jest ts-jest @types\u002Fjest jest-environment-jsdom babel-jest\n```\n\nUse the project's package manager (check for pnpm-lock.yaml, yarn.lock, bun.lockb, or package-lock.json).\n\n## Step 3: Generate vitest.config.ts\n\n### Cloudflare Workers\n\n```typescript\nimport { defineWorkersConfig } from \"@cloudflare\u002Fvitest-pool-workers\u002Fconfig\";\n\nexport default defineWorkersConfig({\n  test: {\n    globals: true,\n    poolOptions: {\n      workers: {\n        wrangler: { configPath: \".\u002Fwrangler.toml\" },\n      },\n    },\n  },\n});\n```\n\nIf the project uses the Cloudflare Vite plugin (`@cloudflare\u002Fvite-plugin`), integrate into the existing vite.config.ts instead:\n\n```typescript\n\u002F\u002F\u002F \u003Creference types=\"vitest\u002Fconfig\" \u002F>\nimport { defineConfig } from \"vite\";\nimport { cloudflare } from \"@cloudflare\u002Fvite-plugin\";\n\nexport default defineConfig({\n  plugins: [cloudflare()],\n  test: {\n    globals: true,\n  },\n});\n```\n\n### React (Vite)\n\n```typescript\n\u002F\u002F\u002F \u003Creference types=\"vitest\u002Fconfig\" \u002F>\nimport { defineConfig } from \"vite\";\nimport react from \"@vitejs\u002Fplugin-react\";\n\nexport default defineConfig({\n  plugins: [react()],\n  test: {\n    globals: true,\n    environment: \"jsdom\",\n    setupFiles: [\".\u002Fsrc\u002Ftest\u002Fsetup.ts\"],\n    css: true,\n  },\n});\n```\n\nIf a vite.config.ts already exists, add the `test` block to it rather than creating a new file.\n\n### Node \u002F Hono API\n\n```typescript\nimport { defineConfig } from \"vitest\u002Fconfig\";\n\nexport default defineConfig({\n  test: {\n    globals: true,\n    environment: \"node\",\n  },\n});\n```\n\n### With Coverage (add to any config)\n\n```typescript\n  test: {\n    \u002F\u002F ... existing config\n    coverage: {\n      provider: \"v8\",\n      reporter: [\"text\", \"html\", \"lcov\"],\n      exclude: [\n        \"node_modules\u002F\",\n        \"**\u002F*.config.*\",\n        \"**\u002F*.d.ts\",\n        \"**\u002Ftest\u002F**\",\n      ],\n    },\n  },\n```\n\n## Step 4: Generate Test Setup File\n\nCreate `src\u002Ftest\u002Fsetup.ts` (React projects only):\n\n```typescript\nimport \"@testing-library\u002Fjest-dom\u002Fvitest\";\n```\n\nThat single import adds all the custom matchers (toBeInTheDocument, toHaveTextContent, etc.) and registers the Vitest `expect.extend` automatically.\n\n## Step 5: Add TypeScript Config\n\nAdd to `tsconfig.json` compilerOptions:\n\n```json\n{\n  \"compilerOptions\": {\n    \"types\": [\"vitest\u002Fglobals\"]\n  }\n}\n```\n\nFor projects with multiple tsconfig files (e.g. tsconfig.app.json + tsconfig.node.json), add to the one that covers test files — usually the root tsconfig.json or create a tsconfig.test.json that extends it.\n\n## Step 6: Add Package.json Scripts\n\n```json\n{\n  \"scripts\": {\n    \"test\": \"vitest\",\n    \"test:run\": \"vitest run\",\n    \"test:coverage\": \"vitest run --coverage\",\n    \"test:ui\": \"vitest --ui\"\n  }\n}\n```\n\nDon't overwrite existing scripts — merge with what's there.\n\n## Step 7: Generate Sample Test\n\nWrite one test file that demonstrates the right patterns for this specific project. Place it next to real source code, not in a separate `__tests__` directory.\n\n### For a Hono API route (e.g. `src\u002Froutes\u002Fhealth.ts`):\n\n```typescript\nimport { describe, it, expect } from \"vitest\";\nimport { app } from \"..\u002Findex\";\n\ndescribe(\"GET \u002Fhealth\", () => {\n  it(\"returns 200 with status ok\", async () => {\n    const res = await app.request(\"\u002Fhealth\");\n    expect(res.status).toBe(200);\n\n    const body = await res.json();\n    expect(body).toEqual({ status: \"ok\" });\n  });\n});\n```\n\n### For a React component (e.g. `src\u002Fcomponents\u002FButton.tsx`):\n\n```typescript\nimport { describe, it, expect } from \"vitest\";\nimport { render, screen } from \"@testing-library\u002Freact\";\nimport userEvent from \"@testing-library\u002Fuser-event\";\nimport { Button } from \".\u002FButton\";\n\ndescribe(\"Button\", () => {\n  it(\"renders with label\", () => {\n    render(\u003CButton>Click me\u003C\u002FButton>);\n    expect(screen.getByRole(\"button\", { name: \u002Fclick me\u002Fi })).toBeInTheDocument();\n  });\n\n  it(\"calls onClick when clicked\", async () => {\n    const user = userEvent.setup();\n    const handleClick = vi.fn();\n    render(\u003CButton onClick={handleClick}>Click me\u003C\u002FButton>);\n\n    await user.click(screen.getByRole(\"button\"));\n    expect(handleClick).toHaveBeenCalledOnce();\n  });\n});\n```\n\n### For a utility function (e.g. `src\u002Futils\u002Fformat.ts`):\n\n```typescript\nimport { describe, it, expect } from \"vitest\";\nimport { formatCurrency } from \".\u002Fformat\";\n\ndescribe(\"formatCurrency\", () => {\n  it(\"formats whole numbers\", () => {\n    expect(formatCurrency(1000)).toBe(\"$1,000.00\");\n  });\n\n  it(\"formats decimals\", () => {\n    expect(formatCurrency(49.9)).toBe(\"$49.90\");\n  });\n\n  it(\"handles zero\", () => {\n    expect(formatCurrency(0)).toBe(\"$0.00\");\n  });\n});\n```\n\nPick a real file from the project to test. Don't invent a fake module — the sample test should run immediately after setup.\n\n## Step 8: Verify\n\nRun the tests to confirm everything works:\n\n```bash\npnpm test:run\n```\n\nIf it fails, diagnose and fix. Common issues:\n\n| Error | Fix |\n|-------|-----|\n| `Cannot find module 'vitest'` | Check install completed, check `node_modules\u002F.vitest` exists |\n| `ReferenceError: describe is not defined` | Add `globals: true` to config, or add `types: [\"vitest\u002Fglobals\"]` to tsconfig |\n| `document is not defined` | Wrong environment — set `environment: \"jsdom\"` for React tests |\n| `Cannot use import.meta` | Ensure vitest.config uses `.ts` extension and project has `\"type\": \"module\"` or Vite handles transforms |\n| Workers bindings undefined | Use `@cloudflare\u002Fvitest-pool-workers` instead of plain vitest, check wrangler.toml path |\n\n---\n\n## Mocking Reference\n\nThese patterns are for writing tests after setup is complete. Include them in the sample test or a `src\u002Ftest\u002Fexamples.test.ts` if the user asks for mocking examples.\n\n### Module mocking (vi.mock)\n\n```typescript\nimport { vi, describe, it, expect } from \"vitest\";\nimport { getUser } from \".\u002Fapi\";\n\nvi.mock(\".\u002Fapi\", () => ({\n  getUser: vi.fn(),\n}));\n\nit(\"mocks a module function\", async () => {\n  vi.mocked(getUser).mockResolvedValue({ id: 1, name: \"Test\" });\n  const user = await getUser(1);\n  expect(user.name).toBe(\"Test\");\n  expect(getUser).toHaveBeenCalledWith(1);\n});\n```\n\n### Spy on methods (vi.spyOn)\n\n```typescript\nit(\"spies on console.warn\", () => {\n  const spy = vi.spyOn(console, \"warn\").mockImplementation(() => {});\n  doSomethingThatWarns();\n  expect(spy).toHaveBeenCalledOnce();\n  spy.mockRestore();\n});\n```\n\n### Fake timers\n\n```typescript\nimport { vi, beforeEach, afterEach, it, expect } from \"vitest\";\n\nbeforeEach(() => {\n  vi.useFakeTimers();\n  vi.setSystemTime(new Date(\"2026-01-15T10:00:00Z\"));\n});\n\nafterEach(() => {\n  vi.useRealTimers();\n});\n\nit(\"uses controlled time\", () => {\n  expect(new Date().toISOString()).toBe(\"2026-01-15T10:00:00.000Z\");\n});\n```\n\n### Global stubs\n\n```typescript\nit(\"stubs fetch\", async () => {\n  const mockFetch = vi.fn().mockResolvedValue({\n    ok: true,\n    json: () => Promise.resolve({ data: \"test\" }),\n  });\n  vi.stubGlobal(\"fetch\", mockFetch);\n\n  const res = await fetch(\"\u002Fapi\u002Fdata\");\n  expect(mockFetch).toHaveBeenCalledWith(\"\u002Fapi\u002Fdata\");\n\n  vi.unstubAllGlobals();\n});\n```\n\n### Snapshot testing\n\n```typescript\nit(\"matches snapshot\", () => {\n  const result = generateConfig({ debug: true });\n  expect(result).toMatchSnapshot();\n});\n\nit(\"matches inline snapshot\", () => {\n  expect({ status: \"ok\", count: 3 }).toMatchInlineSnapshot(`\n    {\n      \"count\": 3,\n      \"status\": \"ok\",\n    }\n  `);\n});\n```\n\n### Parameterized tests\n\n```typescript\ndescribe.each([\n  { input: \"hello\", expected: \"HELLO\" },\n  { input: \"world\", expected: \"WORLD\" },\n  { input: \"\", expected: \"\" },\n])(\"toUpperCase($input)\", ({ input, expected }) => {\n  it(`returns ${expected}`, () => {\n    expect(input.toUpperCase()).toBe(expected);\n  });\n});\n```\n\n---\n\n## Jest Migration\n\nWhen the detected project has Jest (`jest.config.*`, `@types\u002Fjest`, `ts-jest` in dependencies):\n\n1. **Generate the vitest.config.ts** using the steps above\n2. **Update imports** in existing test files:\n\n```typescript\n\u002F\u002F Before\nimport { jest } from \"@jest\u002Fglobals\";\njest.mock(\".\u002Fapi\");\njest.fn();\njest.spyOn(obj, \"method\");\n\n\u002F\u002F After\nimport { vi } from \"vitest\";\nvi.mock(\".\u002Fapi\");\nvi.fn();\nvi.spyOn(obj, \"method\");\n```\n\n3. **Remove Jest packages:**\n```bash\npnpm remove jest ts-jest @types\u002Fjest jest-environment-jsdom babel-jest @jest\u002Fglobals\n```\n\n4. **Update tsconfig** — replace `\"types\": [\"jest\"]` with `\"types\": [\"vitest\u002Fglobals\"]`\n\n5. **Run tests** and fix any remaining issues\n\nKey replacements:\n\n| Jest | Vitest |\n|------|--------|\n| `jest.fn()` | `vi.fn()` |\n| `jest.mock()` | `vi.mock()` |\n| `jest.spyOn()` | `vi.spyOn()` |\n| `jest.useFakeTimers()` | `vi.useFakeTimers()` |\n| `jest.clearAllMocks()` | `vi.clearAllMocks()` |\n| `jest.requireActual()` | `vi.importActual()` |\n| `@jest\u002Fglobals` | `vitest` |\n| `jest.config.js` | `vitest.config.ts` |\n\n---\n\n## Workspace Setup (Monorepos)\n\nFor monorepo projects with multiple packages:\n\n```typescript\n\u002F\u002F vitest.workspace.ts\nimport { defineWorkspace } from \"vitest\u002Fconfig\";\n\nexport default defineWorkspace([\n  \"packages\u002F*\u002Fvitest.config.ts\",\n]);\n```\n\nEach package gets its own config. The workspace file just points to them.\n\n---\n\n## What This Skill Produces\n\nAfter running, the project should have:\n- `vitest.config.ts` (or test block added to existing vite.config.ts)\n- `src\u002Ftest\u002Fsetup.ts` (React projects)\n- Updated `tsconfig.json` with vitest\u002Fglobals type\n- Updated `package.json` with test scripts\n- At least one passing sample test against real source code\n- Dependencies installed\n\nThe tests should pass on first run. If they don't, fix them before finishing.\n",{"name":5,"license":14,"description":7},"main","13d9afadbb6a87d6209fe4bd6ca2bbe4553119ac",".agents\u002Fskills\u002Fvitest",0,"https:\u002F\u002Fgithub.com\u002Fdahaliztupe-sketch\u002FKalmeron-Two","https:\u002F\u002Fkalmeron-two.vercel.app","https:\u002F\u002Fgithub.com\u002Fdahaliztupe-sketch","2026-10-05 12:24:53",{"source":8,"skillName":5,"commands":51,"prompt":61,"zipAvailable":62},[52,55,58],{"tool":53,"command":54},"npx","npx skills add dahaliztupe-sketch\u002FKalmeron-Two --skill vitest",{"tool":56,"command":57},"bunx","bunx skills add dahaliztupe-sketch\u002FKalmeron-Two --skill vitest",{"tool":59,"command":60},"pnpm","pnpm dlx skills add dahaliztupe-sketch\u002FKalmeron-Two --skill vitest","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fdahaliztupe-sketch\u002FKalmeron-Two\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fvitest\u002FSKILL.md",true,[],[65,75,82,94,109,126],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":69,"licenseFileUrl":70,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":74},"01M73HK3SBGDHWYP2ZTMJHSJ33","skill-creator","To create new CLI skills following Anthropic's official best practices with zero manual configuration. This skill automates brainstorming, template application, validation, and installation processes while maintaining progressive disclosure patterns and writing style standards.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fdahaliztupe-sketch\u002FKalmeron-Two\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fskill-creator\u002Fskill-creator\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fdahaliztupe-sketch\u002FKalmeron-Two\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fskill-creator\u002Fskill-creator\u002FSKILL.md",[],[],"2026-11-11 15:11:14",{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":69,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":74},"01M73HA3PK4C7YS0D3VD9FQ8QA","business-investment-advisor","Business investment analysis and capital allocation advisor. Use when evaluating whether to invest in equipment, real estate, a new business, hiring, technology, or any capital expenditure. Also use for ROI calculations, IRR, NPV, payback period, build vs buy decisions, lease vs buy analysis, vendor evaluation, or deciding where to allocate limited budget for maximum return.","https:\u002F\u002Fgithub.com\u002Fdahaliztupe-sketch\u002FKalmeron-Two\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Ffinance-skills\u002Fbusiness-investment-advisor\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":69,"licenseFileUrl":86,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":37},"01M719SWYD9RGS97HJ69PXWY62","add-new-agent","خطوات تفصيليّة لإضافة وكيل ذكاء اصطناعي جديد إلى منصّة Kalmeron من الفكرة إلى الإنتاج","https:\u002F\u002Fgithub.com\u002Fdahaliztupe-sketch\u002FKalmeron-Two\u002Fblob\u002Fmain\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fdahaliztupe-sketch\u002FKalmeron-Two\u002Fblob\u002Fmain\u002FSKILL.md",[],[90,91,92,93],"add","add new agent","new","new agent",{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":69,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":37},"01M719SSKNBA7T5NS7V6DP0PX4","writing-skills","Use when creating new skills, editing existing skills, or verifying skills work before deployment","https:\u002F\u002Fgithub.com\u002Fdahaliztupe-sketch\u002FKalmeron-Two\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fwriting-skills\u002FSKILL.md",[],[101,102,92,103,104,105,106,107,108],"writing skills","writing","when","work","editing","deployment","use","Existing",{"skillNo":110,"name":111,"nameZh":6,"description":112,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":69,"licenseFileUrl":6,"sourceHtmlUrl":113,"categories":114,"keywords":115,"publishedAt":37},"01M719SRFDNKA3044QD3FYZ05R","writing-plans","Use when you have a spec or requirements for a multi-step task, before touching code","https:\u002F\u002Fgithub.com\u002Fdahaliztupe-sketch\u002FKalmeron-Two\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fwriting-plans\u002FSKILL.md",[],[116,102,117,118,119,120,121,122,123,107,103,124,125],"writing plans","plans","task","code","multi","spec","multi-step task","for","you","requirements",{"skillNo":127,"name":128,"nameZh":6,"description":129,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":69,"licenseFileUrl":6,"sourceHtmlUrl":130,"categories":131,"keywords":132,"publishedAt":37},"01M719SPN5FM1JYJSR9DGJQPZ0","web-design-guidelines","Review UI code for Web Interface Guidelines compliance. Use when asked to \"review my UI\", \"check accessibility\", \"audit design\", \"review UX\", or \"check my site against best practices\".","https:\u002F\u002Fgithub.com\u002Fdahaliztupe-sketch\u002FKalmeron-Two\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fweb-design-guidelines\u002FSKILL.md",[],[133,134,135,136,137,138,123,139,140,141,119,142,143,144,145,146,103,107,147,148],"design","guidelines","web","web design guidelines","web design","vercel","accessibility","best practices","file","review","check","compliance","audit","ux","web interface guidelines","interface"]