[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M783HZC6C24Y71XYBSS75BAD":3,"skill-same:01M783HZC6C24Y71XYBSS75BAD":45},{"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":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":13,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M783HZC6C24Y71XYBSS75BAD","bun-test-mocking",null,"Use for mock functions in Bun tests, spyOn, mock.module, implementations, and test doubles.","aibizmod\u002Faibizmod-service-web","aibizmod","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F295315630?v=4","01M7836CB8EQY701YQ7N88M591","01M7836CBVPZGNSJ8BRP2BT398",0,"MIT","https:\u002F\u002Fgithub.com\u002Faibizmod\u002Faibizmod-service-web\u002Fblob\u002Fmain\u002F.opencode\u002Fskill\u002Fclaude-skills\u002Fplugins\u002Fbun\u002Fskills\u002Fbun-test-mocking\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: bun-test-mocking\ndescription: Use for mock functions in Bun tests, spyOn, mock.module, implementations, and test doubles.\nmetadata:\n  version: \"1.0.0\"\nlicense: MIT\n---\n\n# Bun Test Mocking\n\nBun provides Jest-compatible mocking with `mock()`, `spyOn()`, and module mocking.\n\n## Mock Functions\n\n```typescript\nimport { test, expect, mock } from \"bun:test\";\n\n\u002F\u002F Create mock function\nconst fn = mock(() => \"original\");\n\ntest(\"mock function\", () => {\n  fn(\"arg1\", \"arg2\");\n\n  expect(fn).toHaveBeenCalled();\n  expect(fn).toHaveBeenCalledTimes(1);\n  expect(fn).toHaveBeenCalledWith(\"arg1\", \"arg2\");\n});\n```\n\n### jest.fn() Compatibility\n\n```typescript\nimport { test, expect, jest } from \"bun:test\";\n\nconst fn = jest.fn(() => \"value\");\n\ntest(\"jest.fn works\", () => {\n  const result = fn();\n  expect(result).toBe(\"value\");\n  expect(fn).toHaveBeenCalled();\n});\n```\n\n## Mock Return Values\n\n```typescript\nconst fn = mock();\n\n\u002F\u002F Return value once\nfn.mockReturnValueOnce(\"first\");\nfn.mockReturnValueOnce(\"second\");\n\n\u002F\u002F Permanent return value\nfn.mockReturnValue(\"default\");\n\n\u002F\u002F Promise returns\nfn.mockResolvedValue(\"resolved\");\nfn.mockResolvedValueOnce(\"once\");\nfn.mockRejectedValue(new Error(\"fail\"));\nfn.mockRejectedValueOnce(new Error(\"once\"));\n```\n\n## Mock Implementations\n\n```typescript\nconst fn = mock();\n\n\u002F\u002F Set implementation\nfn.mockImplementation((x) => x * 2);\n\n\u002F\u002F One-time implementation\nfn.mockImplementationOnce((x) => x * 10);\n\n\u002F\u002F Chain implementations\nfn\n  .mockImplementationOnce(() => \"first\")\n  .mockImplementationOnce(() => \"second\")\n  .mockImplementation(() => \"default\");\n```\n\n## Spy on Methods\n\n```typescript\nimport { test, expect, spyOn } from \"bun:test\";\n\nconst obj = {\n  method: () => \"original\",\n};\n\ntest(\"spy on method\", () => {\n  const spy = spyOn(obj, \"method\");\n\n  obj.method();\n\n  expect(spy).toHaveBeenCalled();\n  expect(obj.method()).toBe(\"original\"); \u002F\u002F Still works\n\n  \u002F\u002F Override implementation\n  spy.mockImplementation(() => \"mocked\");\n  expect(obj.method()).toBe(\"mocked\");\n\n  \u002F\u002F Restore\n  spy.mockRestore();\n  expect(obj.method()).toBe(\"original\");\n});\n```\n\n## Mock Modules\n\n```typescript\nimport { test, expect, mock } from \"bun:test\";\n\n\u002F\u002F Mock entire module\nmock.module(\".\u002Futils\", () => ({\n  add: mock(() => 999),\n  subtract: mock(() => 0),\n}));\n\n\u002F\u002F Now imports use mocked version\nimport { add } from \".\u002Futils\";\n\ntest(\"mocked module\", () => {\n  expect(add(1, 2)).toBe(999);\n});\n```\n\n### Mock Node Modules\n\n```typescript\nmock.module(\"axios\", () => ({\n  default: {\n    get: mock(() => Promise.resolve({ data: \"mocked\" })),\n    post: mock(() => Promise.resolve({ data: \"created\" })),\n  },\n}));\n```\n\n### Mock with Factory\n\n```typescript\nmock.module(\".\u002Fconfig\", () => {\n  return {\n    API_URL: \"http:\u002F\u002Ftest.local\",\n    DEBUG: true,\n  };\n});\n```\n\n## Mock Assertions\n\n```typescript\nconst fn = mock();\n\nfn(\"a\", \"b\");\nfn(\"c\", \"d\");\n\n\u002F\u002F Call count\nexpect(fn).toHaveBeenCalled();\nexpect(fn).toHaveBeenCalledTimes(2);\n\n\u002F\u002F Call arguments\nexpect(fn).toHaveBeenCalledWith(\"a\", \"b\");\nexpect(fn).toHaveBeenLastCalledWith(\"c\", \"d\");\nexpect(fn).toHaveBeenNthCalledWith(1, \"a\", \"b\");\n\n\u002F\u002F Return values\nfn.mockReturnValue(\"result\");\nfn();\nexpect(fn).toHaveReturned();\nexpect(fn).toHaveReturnedWith(\"result\");\nexpect(fn).toHaveReturnedTimes(1);\n```\n\n## Mock Properties\n\n```typescript\nconst fn = mock(() => \"value\");\n\nfn(\"arg1\");\nfn(\"arg2\");\n\n\u002F\u002F Access call info\nfn.mock.calls;        \u002F\u002F [[\"arg1\"], [\"arg2\"]]\nfn.mock.results;      \u002F\u002F [{ type: \"return\", value: \"value\" }, ...]\nfn.mock.lastCall;     \u002F\u002F [\"arg2\"]\n\n\u002F\u002F Clear history\nfn.mockClear();       \u002F\u002F Clear calls, keep implementation\nfn.mockReset();       \u002F\u002F Clear calls + implementation\nfn.mockRestore();     \u002F\u002F Restore original (for spies)\n```\n\n## Common Patterns\n\n### Mock Fetch\n\n```typescript\nimport { test, expect, spyOn } from \"bun:test\";\n\ntest(\"mock fetch\", async () => {\n  const spy = spyOn(global, \"fetch\").mockResolvedValue(\n    new Response(JSON.stringify({ data: \"mocked\" }))\n  );\n\n  const response = await fetch(\"\u002Fapi\u002Fdata\");\n  const json = await response.json();\n\n  expect(json.data).toBe(\"mocked\");\n  expect(spy).toHaveBeenCalledWith(\"\u002Fapi\u002Fdata\");\n\n  spy.mockRestore();\n});\n```\n\n### Mock Console\n\n```typescript\ntest(\"mock console\", () => {\n  const spy = spyOn(console, \"log\");\n\n  console.log(\"test message\");\n\n  expect(spy).toHaveBeenCalledWith(\"test message\");\n  spy.mockRestore();\n});\n```\n\n### Mock Class Methods\n\n```typescript\nclass UserService {\n  async getUser(id: string) {\n    \u002F\u002F Real implementation\n  }\n}\n\ntest(\"mock class method\", () => {\n  const service = new UserService();\n  const spy = spyOn(service, \"getUser\").mockResolvedValue({\n    id: \"1\",\n    name: \"Test User\",\n  });\n\n  const user = await service.getUser(\"1\");\n\n  expect(user.name).toBe(\"Test User\");\n  expect(spy).toHaveBeenCalledWith(\"1\");\n});\n```\n\n## Common Errors\n\n| Error | Cause | Fix |\n|-------|-------|-----|\n| `Cannot spy on undefined` | Property doesn't exist | Check property name |\n| `Not a function` | Trying to mock non-function | Use correct mock approach |\n| `Already mocked` | Double mocking | Use mockRestore first |\n| `Module not found` | Wrong module path | Check path in mock.module |\n\n## When to Load References\n\nLoad `references\u002Fmock-api.md` when:\n- Complete mock\u002Fspy API reference\n- Advanced mocking patterns\n\nLoad `references\u002Fmodule-mocking.md` when:\n- Complex module mocking\n- Hoisting behavior details\n","# Bun Test Mocking\n\nBun provides Jest-compatible mocking with `mock()`, `spyOn()`, and module mocking.\n\n## Mock Functions\n\n```typescript\nimport { test, expect, mock } from \"bun:test\";\n\n\u002F\u002F Create mock function\nconst fn = mock(() => \"original\");\n\ntest(\"mock function\", () => {\n  fn(\"arg1\", \"arg2\");\n\n  expect(fn).toHaveBeenCalled();\n  expect(fn).toHaveBeenCalledTimes(1);\n  expect(fn).toHaveBeenCalledWith(\"arg1\", \"arg2\");\n});\n```\n\n### jest.fn() Compatibility\n\n```typescript\nimport { test, expect, jest } from \"bun:test\";\n\nconst fn = jest.fn(() => \"value\");\n\ntest(\"jest.fn works\", () => {\n  const result = fn();\n  expect(result).toBe(\"value\");\n  expect(fn).toHaveBeenCalled();\n});\n```\n\n## Mock Return Values\n\n```typescript\nconst fn = mock();\n\n\u002F\u002F Return value once\nfn.mockReturnValueOnce(\"first\");\nfn.mockReturnValueOnce(\"second\");\n\n\u002F\u002F Permanent return value\nfn.mockReturnValue(\"default\");\n\n\u002F\u002F Promise returns\nfn.mockResolvedValue(\"resolved\");\nfn.mockResolvedValueOnce(\"once\");\nfn.mockRejectedValue(new Error(\"fail\"));\nfn.mockRejectedValueOnce(new Error(\"once\"));\n```\n\n## Mock Implementations\n\n```typescript\nconst fn = mock();\n\n\u002F\u002F Set implementation\nfn.mockImplementation((x) => x * 2);\n\n\u002F\u002F One-time implementation\nfn.mockImplementationOnce((x) => x * 10);\n\n\u002F\u002F Chain implementations\nfn\n  .mockImplementationOnce(() => \"first\")\n  .mockImplementationOnce(() => \"second\")\n  .mockImplementation(() => \"default\");\n```\n\n## Spy on Methods\n\n```typescript\nimport { test, expect, spyOn } from \"bun:test\";\n\nconst obj = {\n  method: () => \"original\",\n};\n\ntest(\"spy on method\", () => {\n  const spy = spyOn(obj, \"method\");\n\n  obj.method();\n\n  expect(spy).toHaveBeenCalled();\n  expect(obj.method()).toBe(\"original\"); \u002F\u002F Still works\n\n  \u002F\u002F Override implementation\n  spy.mockImplementation(() => \"mocked\");\n  expect(obj.method()).toBe(\"mocked\");\n\n  \u002F\u002F Restore\n  spy.mockRestore();\n  expect(obj.method()).toBe(\"original\");\n});\n```\n\n## Mock Modules\n\n```typescript\nimport { test, expect, mock } from \"bun:test\";\n\n\u002F\u002F Mock entire module\nmock.module(\".\u002Futils\", () => ({\n  add: mock(() => 999),\n  subtract: mock(() => 0),\n}));\n\n\u002F\u002F Now imports use mocked version\nimport { add } from \".\u002Futils\";\n\ntest(\"mocked module\", () => {\n  expect(add(1, 2)).toBe(999);\n});\n```\n\n### Mock Node Modules\n\n```typescript\nmock.module(\"axios\", () => ({\n  default: {\n    get: mock(() => Promise.resolve({ data: \"mocked\" })),\n    post: mock(() => Promise.resolve({ data: \"created\" })),\n  },\n}));\n```\n\n### Mock with Factory\n\n```typescript\nmock.module(\".\u002Fconfig\", () => {\n  return {\n    API_URL: \"http:\u002F\u002Ftest.local\",\n    DEBUG: true,\n  };\n});\n```\n\n## Mock Assertions\n\n```typescript\nconst fn = mock();\n\nfn(\"a\", \"b\");\nfn(\"c\", \"d\");\n\n\u002F\u002F Call count\nexpect(fn).toHaveBeenCalled();\nexpect(fn).toHaveBeenCalledTimes(2);\n\n\u002F\u002F Call arguments\nexpect(fn).toHaveBeenCalledWith(\"a\", \"b\");\nexpect(fn).toHaveBeenLastCalledWith(\"c\", \"d\");\nexpect(fn).toHaveBeenNthCalledWith(1, \"a\", \"b\");\n\n\u002F\u002F Return values\nfn.mockReturnValue(\"result\");\nfn();\nexpect(fn).toHaveReturned();\nexpect(fn).toHaveReturnedWith(\"result\");\nexpect(fn).toHaveReturnedTimes(1);\n```\n\n## Mock Properties\n\n```typescript\nconst fn = mock(() => \"value\");\n\nfn(\"arg1\");\nfn(\"arg2\");\n\n\u002F\u002F Access call info\nfn.mock.calls;        \u002F\u002F [[\"arg1\"], [\"arg2\"]]\nfn.mock.results;      \u002F\u002F [{ type: \"return\", value: \"value\" }, ...]\nfn.mock.lastCall;     \u002F\u002F [\"arg2\"]\n\n\u002F\u002F Clear history\nfn.mockClear();       \u002F\u002F Clear calls, keep implementation\nfn.mockReset();       \u002F\u002F Clear calls + implementation\nfn.mockRestore();     \u002F\u002F Restore original (for spies)\n```\n\n## Common Patterns\n\n### Mock Fetch\n\n```typescript\nimport { test, expect, spyOn } from \"bun:test\";\n\ntest(\"mock fetch\", async () => {\n  const spy = spyOn(global, \"fetch\").mockResolvedValue(\n    new Response(JSON.stringify({ data: \"mocked\" }))\n  );\n\n  const response = await fetch(\"\u002Fapi\u002Fdata\");\n  const json = await response.json();\n\n  expect(json.data).toBe(\"mocked\");\n  expect(spy).toHaveBeenCalledWith(\"\u002Fapi\u002Fdata\");\n\n  spy.mockRestore();\n});\n```\n\n### Mock Console\n\n```typescript\ntest(\"mock console\", () => {\n  const spy = spyOn(console, \"log\");\n\n  console.log(\"test message\");\n\n  expect(spy).toHaveBeenCalledWith(\"test message\");\n  spy.mockRestore();\n});\n```\n\n### Mock Class Methods\n\n```typescript\nclass UserService {\n  async getUser(id: string) {\n    \u002F\u002F Real implementation\n  }\n}\n\ntest(\"mock class method\", () => {\n  const service = new UserService();\n  const spy = spyOn(service, \"getUser\").mockResolvedValue({\n    id: \"1\",\n    name: \"Test User\",\n  });\n\n  const user = await service.getUser(\"1\");\n\n  expect(user.name).toBe(\"Test User\");\n  expect(spy).toHaveBeenCalledWith(\"1\");\n});\n```\n\n## Common Errors\n\n| Error | Cause | Fix |\n|-------|-------|-----|\n| `Cannot spy on undefined` | Property doesn't exist | Check property name |\n| `Not a function` | Trying to mock non-function | Use correct mock approach |\n| `Already mocked` | Double mocking | Use mockRestore first |\n| `Module not found` | Wrong module path | Check path in mock.module |\n\n## When to Load References\n\nLoad `references\u002Fmock-api.md` when:\n- Complete mock\u002Fspy API reference\n- Advanced mocking patterns\n\nLoad `references\u002Fmodule-mocking.md` when:\n- Complex module mocking\n- Hoisting behavior details\n",{"name":5,"license":14,"metadata":23,"description":7},{"version":24},"1.0.0","main","9f54582c8b485462d402d7e70feaef34801746b9",".opencode\u002Fskill\u002Fclaude-skills\u002Fplugins\u002Fbun\u002Fskills\u002Fbun-test-mocking","https:\u002F\u002Fgithub.com\u002Faibizmod\u002Faibizmod-service-web","https:\u002F\u002Fgithub.com\u002Faibizmod","2026-09-24 00:48:11",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add aibizmod\u002Faibizmod-service-web --skill bun-test-mocking",{"tool":37,"command":38},"bunx","bunx skills add aibizmod\u002Faibizmod-service-web --skill bun-test-mocking",{"tool":40,"command":41},"pnpm","pnpm dlx skills add aibizmod\u002Faibizmod-service-web --skill bun-test-mocking","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Faibizmod\u002Faibizmod-service-web\u002Fblob\u002Fmain\u002F.opencode\u002Fskill\u002Fclaude-skills\u002Fplugins\u002Fbun\u002Fskills\u002Fbun-test-mocking\u002FSKILL.md",true,[],[46,53,60,67,74,81],{"skillNo":47,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":50,"categories":51,"keywords":52,"publishedAt":18},"01M7846EAPZWCQ8C6G3AAMMR57","{TODO=lowercase-hyphen-case-name}","[TODO: Write comprehensive description in third-person. Start with \"This skill provides...\" or \"This skill should be used when...\"]\n\n[TODO: Add \"Use when\" scenarios - specific situations where Claude should use this skill]\n\n[TODO: Add keywords - technologies, use cases, error messages that should trigger this skill]","https:\u002F\u002Fgithub.com\u002Faibizmod\u002Faibizmod-service-web\u002Fblob\u002Fmain\u002F.opencode\u002Fskill\u002Fclaude-skills\u002Ftemplates\u002Fskill-skeleton\u002Fskills\u002Fskill-name\u002FSKILL.md",[],[],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":18},"01M7846A0WGDKJTDPD5QMHQVFV","zustand-state-management","Zustand state management for React with TypeScript. Use for global state, Redux\u002FContext API migration, localStorage persistence, slices pattern, devtools, Next.js SSR, or encountering hydration errors, TypeScript inference issues, persist middleware problems, infinite render loops.","https:\u002F\u002Fgithub.com\u002Faibizmod\u002Faibizmod-service-web\u002Fblob\u002Fmain\u002F.opencode\u002Fskill\u002Fclaude-skills\u002Fplugins\u002Fzustand-state-management\u002Fskills\u002Fzustand-state-management\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":18},"01M78463GGSP9B3JSF146B2MG0","zod","TypeScript-first schema validation and type inference. Use for validating API requests\u002Fresponses, form data, env vars, configs, defining type-safe schemas with runtime validation, transforming data, generating JSON Schema for OpenAPI\u002FAI, or encountering missing validation errors, type inference issues, validation error handling problems. Zero dependencies (2kb gzipped).","https:\u002F\u002Fgithub.com\u002Faibizmod\u002Faibizmod-service-web\u002Fblob\u002Fmain\u002F.opencode\u002Fskill\u002Fclaude-skills\u002Fplugins\u002Fzod\u002Fskills\u002Fzod\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":18},"01M7845ZX17SVNNY7EDGPJHSBT","xss-prevention","XSS attack prevention with input sanitization, output encoding, Content Security Policy. Use for user-generated content, rich text editors, web application security, or encountering stored XSS, reflected XSS, DOM manipulation, script injection errors.","https:\u002F\u002Fgithub.com\u002Faibizmod\u002Faibizmod-service-web\u002Fblob\u002Fmain\u002F.opencode\u002Fskill\u002Fclaude-skills\u002Fplugins\u002Fxss-prevention\u002Fskills\u002Fxss-prevention\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":18},"01M7845ST1H37YHSXWWQ9N0V0S","wordpress-plugin-core","WordPress plugin development with hooks, security, REST API, custom post types. Use for plugin creation, $wpdb queries, Settings API, or encountering SQL injection, XSS, CSRF, nonce errors.","https:\u002F\u002Fgithub.com\u002Faibizmod\u002Faibizmod-service-web\u002Fblob\u002Fmain\u002F.opencode\u002Fskill\u002Fclaude-skills\u002Fplugins\u002Fwordpress-plugin-core\u002Fskills\u002Fwordpress-plugin-core\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":18},"01M7845PTWD5HWSTGP35Q8TFNY","woocommerce-dev-cycle","Run tests, linting, and quality checks for WooCommerce development. Use when running tests, fixing code style, or following the development workflow in WooCommerce projects.","https:\u002F\u002Fgithub.com\u002Faibizmod\u002Faibizmod-service-web\u002Fblob\u002Fmain\u002F.opencode\u002Fskill\u002Fclaude-skills\u002Fplugins\u002Fwoocommerce-dev-cycle\u002Fskills\u002Fwoocommerce-dev-cycle\u002FSKILL.md",[],[]]