[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6EP5XR6PXPDBDJ002WM12QT":3,"skill-same:01M6EP5XR6PXPDBDJ002WM12QT":78},{"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":31,"publishedAt":44,"linkOnly":45,"markdownContent":46,"markdownBody":47,"frontMatter":48,"refName":49,"commitSha":50,"skillDirectory":51,"forksCount":52,"repositoryHtmlUrl":53,"repositoryHomepageUrl":54,"ownerHtmlUrl":55,"ownerBlogUrl":6,"ownerDescription":56,"updatedAt":57,"install":58,"resources":71},"01M6EP5XR6PXPDBDJ002WM12QT","testing-patterns",null,"Vitest testing patterns and strategies for unit tests, agent tests, and API tests with Supabase mocking","ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Fcleanexpo\u002Ftesting-patterns\u002FSKILL.md",[18,23,26],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",{"categoryNo":27,"categoryName":28,"taxonomyType":29,"taxonomyTypeDesc":30},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[32,33,34,35,36,37,38,39,40,41,42,43],"testing","testing patterns","patterns","unit tests","supabase","api","vitest","vitest testing","strategies","tests","unit","mocking","2026-11-10 10:12:30",false,"---\nname: testing-patterns\ndescription: Vitest testing patterns and strategies for unit tests, agent tests, and API tests with Supabase mocking\n---\n\n# Testing Patterns Skill\n## Vitest Testing Strategy\n\n**When to Use**: Writing tests for new features, agents, API routes\n\n---\n\n## Framework: Vitest\n\n**Command**: `npm run test`\n**Required**: 100% pass rate\n**Location**: `tests\u002F` directory\n\n---\n\n## Unit Test Pattern\n\n```typescript\nimport { describe, it, expect, vi, beforeEach } from 'vitest';\nimport { MyService } from '@\u002Flib\u002Fservices\u002Fmy-service';\n\ndescribe('MyService', () => {\n  let service: MyService;\n\n  beforeEach(() => {\n    vi.clearAllMocks();\n    service = new MyService();\n  });\n\n  it('should process data correctly', () => {\n    const input = { value: 42 };\n    const result = service.process(input);\n\n    expect(result).toBeDefined();\n    expect(result.value).toBe(42);\n  });\n\n  it('should handle errors', () => {\n    expect(() => service.process(null)).toThrow();\n  });\n});\n```\n\n---\n\n## Agent Test Pattern\n\n```typescript\nimport { describe, it, expect, vi } from 'vitest';\nimport { MyAgent } from '@\u002Flib\u002Fagents\u002Fmy-agent';\n\n\u002F\u002F Mock Supabase\nvi.mock('@supabase\u002Fsupabase-js', () => ({\n  createClient: vi.fn(() => ({\n    from: vi.fn(() => ({\n      select: vi.fn().mockReturnThis(),\n      eq: vi.fn().mockResolvedValue({ data: [], error: null })\n    }))\n  }))\n}));\n\ndescribe('MyAgent', () => {\n  it('processes task successfully', async () => {\n    const agent = new MyAgent();\n    const task = {\n      id: 'test-1',\n      workspace_id: 'ws-123',\n      task_type: 'test',\n      payload: {},\n      priority: 5,\n      retry_count: 0,\n      max_retries: 3\n    };\n\n    const result = await agent.processTask(task);\n\n    expect(result).toBeDefined();\n  });\n});\n```\n\n---\n\n## API Test Pattern\n\n```typescript\nimport { describe, it, expect } from 'vitest';\nimport { GET } from '@\u002Fapp\u002Fapi\u002Fmy-endpoint\u002Froute';\nimport { NextRequest } from 'next\u002Fserver';\n\ndescribe('GET \u002Fapi\u002Fmy-endpoint', () => {\n  it('requires workspace_id', async () => {\n    const req = new NextRequest('http:\u002F\u002Flocalhost:3008\u002Fapi\u002Fmy-endpoint');\n\n    const response = await GET(req);\n    const data = await response.json();\n\n    expect(response.status).toBe(400);\n    expect(data.error).toContain('workspaceId required');\n  });\n});\n```\n\n---\n\n## Mocking Supabase\n\n```typescript\nconst mockSelect = vi.fn().mockReturnThis();\nconst mockEq = vi.fn().mockReturnThis();\nconst mockInsert = vi.fn().mockReturnThis();\nconst mockFrom = vi.fn(() => ({\n  select: mockSelect,\n  eq: mockEq,\n  insert: mockInsert\n}));\n\nvi.mock('@supabase\u002Fsupabase-js', () => ({\n  createClient: vi.fn(() => ({\n    from: mockFrom\n  }))\n}));\n\n\u002F\u002F Set return values\nmockEq.mockResolvedValue({ data: [{ id: '1', name: 'Test' }], error: null });\n```\n\n---\n\n## Coverage Requirements\n\n- **Unit Tests**: All services, utilities, helpers\n- **Integration Tests**: API routes, agent workflows\n- **E2E Tests**: Critical user flows (Playwright)\n\n**Target**: 100% pass rate (no failures allowed)\n\n---\n\n**Standard**: All code must have tests, all tests must pass\n","# Testing Patterns Skill\n## Vitest Testing Strategy\n\n**When to Use**: Writing tests for new features, agents, API routes\n\n---\n\n## Framework: Vitest\n\n**Command**: `npm run test`\n**Required**: 100% pass rate\n**Location**: `tests\u002F` directory\n\n---\n\n## Unit Test Pattern\n\n```typescript\nimport { describe, it, expect, vi, beforeEach } from 'vitest';\nimport { MyService } from '@\u002Flib\u002Fservices\u002Fmy-service';\n\ndescribe('MyService', () => {\n  let service: MyService;\n\n  beforeEach(() => {\n    vi.clearAllMocks();\n    service = new MyService();\n  });\n\n  it('should process data correctly', () => {\n    const input = { value: 42 };\n    const result = service.process(input);\n\n    expect(result).toBeDefined();\n    expect(result.value).toBe(42);\n  });\n\n  it('should handle errors', () => {\n    expect(() => service.process(null)).toThrow();\n  });\n});\n```\n\n---\n\n## Agent Test Pattern\n\n```typescript\nimport { describe, it, expect, vi } from 'vitest';\nimport { MyAgent } from '@\u002Flib\u002Fagents\u002Fmy-agent';\n\n\u002F\u002F Mock Supabase\nvi.mock('@supabase\u002Fsupabase-js', () => ({\n  createClient: vi.fn(() => ({\n    from: vi.fn(() => ({\n      select: vi.fn().mockReturnThis(),\n      eq: vi.fn().mockResolvedValue({ data: [], error: null })\n    }))\n  }))\n}));\n\ndescribe('MyAgent', () => {\n  it('processes task successfully', async () => {\n    const agent = new MyAgent();\n    const task = {\n      id: 'test-1',\n      workspace_id: 'ws-123',\n      task_type: 'test',\n      payload: {},\n      priority: 5,\n      retry_count: 0,\n      max_retries: 3\n    };\n\n    const result = await agent.processTask(task);\n\n    expect(result).toBeDefined();\n  });\n});\n```\n\n---\n\n## API Test Pattern\n\n```typescript\nimport { describe, it, expect } from 'vitest';\nimport { GET } from '@\u002Fapp\u002Fapi\u002Fmy-endpoint\u002Froute';\nimport { NextRequest } from 'next\u002Fserver';\n\ndescribe('GET \u002Fapi\u002Fmy-endpoint', () => {\n  it('requires workspace_id', async () => {\n    const req = new NextRequest('http:\u002F\u002Flocalhost:3008\u002Fapi\u002Fmy-endpoint');\n\n    const response = await GET(req);\n    const data = await response.json();\n\n    expect(response.status).toBe(400);\n    expect(data.error).toContain('workspaceId required');\n  });\n});\n```\n\n---\n\n## Mocking Supabase\n\n```typescript\nconst mockSelect = vi.fn().mockReturnThis();\nconst mockEq = vi.fn().mockReturnThis();\nconst mockInsert = vi.fn().mockReturnThis();\nconst mockFrom = vi.fn(() => ({\n  select: mockSelect,\n  eq: mockEq,\n  insert: mockInsert\n}));\n\nvi.mock('@supabase\u002Fsupabase-js', () => ({\n  createClient: vi.fn(() => ({\n    from: mockFrom\n  }))\n}));\n\n\u002F\u002F Set return values\nmockEq.mockResolvedValue({ data: [{ id: '1', name: 'Test' }], error: null });\n```\n\n---\n\n## Coverage Requirements\n\n- **Unit Tests**: All services, utilities, helpers\n- **Integration Tests**: API routes, agent workflows\n- **E2E Tests**: Critical user flows (Playwright)\n\n**Target**: 100% pass rate (no failures allowed)\n\n---\n\n**Standard**: All code must have tests, all tests must pass\n",{"name":5,"description":7},"main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002Faiskillstore\u002Fmarketplace\u002Fcleanexpo\u002Ftesting-patterns",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":8,"skillName":5,"commands":59,"prompt":69,"zipAvailable":70},[60,63,66],{"tool":61,"command":62},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill testing-patterns",{"tool":64,"command":65},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill testing-patterns",{"tool":67,"command":68},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill testing-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Fcleanexpo\u002Ftesting-patterns\u002FSKILL.md",true,[72],{"path":73,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":76,"sourceHtmlUrl":77},"skill-report.json","REFERENCE","参考文档",9588,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Fcleanexpo\u002Ftesting-patterns\u002Fskill-report.json",[79,89,99,108,114,121],{"skillNo":80,"name":81,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":85,"publishedAt":44},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[84],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[86,87,88],"model","model hierarchy","model hierarchy skill",{"skillNo":90,"name":91,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":95,"publishedAt":44},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[94],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[96,97,98],"MCP","zoom","zoom mcp",{"skillNo":100,"name":101,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":44},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[105,106,107,97],"sdk","zoom apps sdk","apps",{"skillNo":109,"name":110,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":111,"categories":112,"keywords":113,"publishedAt":44},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[110],{"skillNo":115,"name":116,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":117,"categories":118,"keywords":120,"publishedAt":44},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[119],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[116],{"skillNo":122,"name":123,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":124,"categories":125,"keywords":126,"publishedAt":44},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[123]]