[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6QHY6R19MCSQ297RA2Z1RER":3,"skill-same:01M6QHY6R19MCSQ297RA2Z1RER":80},{"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":27,"publishedAt":48,"linkOnly":49,"markdownContent":50,"markdownBody":51,"frontMatter":52,"refName":60,"commitSha":61,"skillDirectory":62,"forksCount":13,"repositoryHtmlUrl":63,"repositoryHomepageUrl":6,"ownerHtmlUrl":64,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":65,"install":66,"resources":79},"01M6QHY6R19MCSQ297RA2Z1RER","debug-test",null,"Master debugging failing tests: when tests fail, how to determine if it's a real bug or test issue, and how to fix test problems without breaking production code. Use when tests fail, test debugging, fixing broken tests, or when tests don't work as expected. Triggers especially when user says \"test failed\", \"debug test\", \"fix test\", \"test not working\", \"why is this test failing\".","ImaginerLabs\u002Fskill-manager","ImaginerLabs","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F214277308?v=4","01M6QGGDPNF15RMMT1RCFDH9FN","01M6QGGDTH5BY64DQ123NR8M33",0,"MIT","https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager\u002Fblob\u002Fmain\u002Fskills\u002Fcoding\u002Fdebug-test\u002FSKILL.md",[17,22],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",{"categoryNo":23,"categoryName":24,"taxonomyType":25,"taxonomyTypeDesc":26},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47],"debug","debug test","test","expected","how to","as","triggers","tests","master","issue","bug","use","fix","broken","work","coding","why","how","code","debugging","2026-11-10 10:12:30",false,"---\nname: debug-test\ndescription: >-\n  Master debugging failing tests: when tests fail, how to determine if it's a real bug or test issue, and how to fix test problems without breaking production code. Use when tests fail, test debugging, fixing broken tests, or when tests don't work as expected. Triggers especially when user says \"test failed\", \"debug test\", \"fix test\", \"test not working\", \"why is this test failing\".\ncategory: coding\npriority: P2\ntrigger_patterns:\n  - \"test failed\"\n  - \"debug test\"\n  - \"fix test\"\n  - \"test not working\"\n  - \"why is this test failing\"\n  - \"test debugging\"\n---\n\n# Debug Test — Test Failure Analysis Framework\n\n## Overview\n\nDebug-test is a **behavioral specification skill** that encapsulates the methodology for **systematically debugging failing tests to determine if the failure is a real bug or a test problem**.\n\nThis skill embodies the expertise of developers who've spent hours chasing phantom test bugs and know the discipline of separating \"my code is broken\" from \"my test is wrong.\"\n\n## Core Philosophy\n\n### The Debugging First Principle\n\n> \"When a test fails, your first question should be: 'Is my test testing what I think it's testing?' The answer is 'not always' more often than you'd think.\"\n\n### Test Failure Types\n\n```\n┌─────────────────────────────────────────────────────────────┐\n│                    TEST FAILURE CATEGORIES                    │\n│                                                               │\n│  REAL BUG IN CODE:          TEST PROBLEM:                     │\n│  ─────────────────          ─────────────                      │\n│  • Code doesn't work       • Test checks wrong thing          │\n│  • Logic is wrong           • Test has wrong assertion        │\n│  • Edge case not handled    • Test data is wrong              │\n│  • Type error               • Test is flaky                  │\n│                                                               │\n│  BOTH:                             NEITHER:                     │\n│  • Code was right, test was vague      • Environment issue    │\n│  • Both code and test wrong           • Tooling issue         │\n└─────────────────────────────────────────────────────────────┘\n```\n\n## Decision Framework\n\n### The Test Failure Diagnosis Tree\n\n```\n                    ┌─ Does test pass locally?\n                    │   └─ NO → Continue\n                    │       └─ YES → Check CI environment\n                    │\n                    └─ Is test flaky?\n                        └─ YES → Flaky test pattern\n                        └─ NO → Continue\n                                │\n                                └─ Does the failing assertion make sense?\n                                    └─ NO → Test problem\n                                    └─ YES → Continue\n                                            │\n                                            └─ Is the code logic correct?\n                                                └─ YES → Test problem\n                                                └─ NO → Real bug\n```\n\n## Behavioral Specification\n\n### Phase 1: Initial Assessment\n\n#### 1.1 Gather Information\n\n```markdown\n## Test Failure Report\n\n| Field | Value |\n|-------|-------|\n| Test name | should_return_user_when_id_exists |\n| File | users.test.ts |\n| Line | 42 |\n| Error type | expect(received).toBe(expected) |\n| Expected | { id: \"123\", name: \"Alice\" } |\n| Received | { id: \"123\", name: \"Alice\" } |\n\nNote: Objects look same but test fails...\n```\n\n#### 1.2 First Checks\n\n```typescript\n\u002F\u002F Check 1: Are objects actually equal?\n\u002F\u002F Deep equality vs reference equality\nexpect(user).toBe(expectedUser); \u002F\u002F Reference\nexpect(user).toEqual(expectedUser); \u002F\u002F Deep (usually what you want)\n\n\u002F\u002F Check 2: Is there a type coercion issue?\n\u002F\u002F \"1\" vs 1\n\u002F\u002F true vs \"true\"\n\u002F\u002F null vs undefined\n\n\u002F\u002F Check 3: Are you comparing what you think?\nconsole.log(\"Expected:\", JSON.stringify(expected, null, 2));\nconsole.log(\"Received:\", JSON.stringify(received, null, 2));\n```\n\n### Phase 2: Isolate the Problem\n\n#### 2.1 Simplify the Test\n\n```typescript\n\u002F\u002F ORIGINAL (complex)\nit(\"should process complex order correctly\", () => {\n  const order = createComplexOrder({ ... });\n  const result = processOrder(order, options, context);\n  expect(result.status).toBe(\"shipped\");\n  expect(result.trackingNumber).toMatch(\u002F^TRACK-\u002F);\n  \u002F\u002F More assertions...\n});\n\n\u002F\u002F SIMPLIFIED (isolate)\nit(\"should process order\", () => {\n  const order = { status: \"pending\" }; \u002F\u002F Minimal\n  const result = processOrder(order);\n  expect(result.status).toBe(\"processing\"); \u002F\u002F Test one thing\n});\n```\n\n#### 2.2 Add Diagnostic Logging\n\n```typescript\nit(\"should calculate total correctly\", () => {\n  const items = [\n    { price: 10, quantity: 2 },\n    { price: 5, quantity: 3 },\n  ];\n\n  console.log(\"Input items:\", items);\n  const total = calculateTotal(items);\n  console.log(\"Calculated total:\", total);\n  console.log(\"Expected:\", 35); \u002F\u002F 10*2 + 5*3 = 35\n\n  expect(total).toBe(35);\n});\n```\n\n#### 2.3 Test in Isolation\n\n```typescript\n\u002F\u002F BEFORE: Full system test\nit(\"should work with database\", async () => {\n  const result = await fullIntegrationTest();\n  \u002F\u002F Too many variables\n});\n\n\u002F\u002F AFTER: Unit test\nit(\"should calculate total\", () => {\n  const calculator = new OrderCalculator(mockLogger);\n  const result = calculator.calculateTotal(items);\n  \u002F\u002F Isolated, clear failure point\n});\n```\n\n### Phase 3: Common Test Problems\n\n#### 3.1 Wrong Assertion Type\n\n```typescript\n\u002F\u002F ❌ PROBLEM: Checking reference, not value\nconst user1 = { name: \"Alice\" };\nconst user2 = { name: \"Alice\" };\nexpect(user1).toBe(user2); \u002F\u002F Fails! Different objects\n\n\u002F\u002F ✅ FIX: Check value\nexpect(user1).toEqual(user2); \u002F\u002F Passes! Same values\n\n\u002F\u002F ❌ PROBLEM: toBe for objects\nexpect({ a: 1 }).toBe({ a: 1 }); \u002F\u002F Fails!\n\n\u002F\u002F ✅ FIX: toEqual for objects\nexpect({ a: 1 }).toEqual({ a: 1 }); \u002F\u002F Passes!\n```\n\n#### 3.2 Async Issues\n\n```typescript\n\u002F\u002F ❌ PROBLEM: Not waiting for async\nit(\"should update user\", async () => {\n  await updateUser({ id: \"1\", name: \"Bob\" });\n  const user = getUser(\"1\");\n  expect(user.name).toBe(\"Bob\"); \u002F\u002F Might pass\u002Ffail randomly\n});\n\n\u002F\u002F ✅ FIX: Properly await\nit(\"should update user\", async () => {\n  await updateUser({ id: \"1\", name: \"Bob\" });\n  const user = await getUser(\"1\"); \u002F\u002F Await here too!\n  expect(user.name).toBe(\"Bob\");\n});\n\n\u002F\u002F ❌ PROBLEM: Forgotten async\nit(\"should return promise\", () => {\n  const promise = fetchData(); \u002F\u002F Returns promise\n  expect(promise).resolves.toEqual(data); \u002F\u002F Missing async\u002Fawait\n});\n\n\u002F\u002F ✅ FIX: Handle promise correctly\nit(\"should return promise\", async () => {\n  const promise = fetchData();\n  await expect(promise).resolves.toEqual(data);\n});\n```\n\n#### 3.3 Mock Configuration Errors\n\n```typescript\n\u002F\u002F ❌ PROBLEM: Mock not configured correctly\nconst mockRepo = {\n  findById: vi.fn(), \u002F\u002F No return value!\n};\n\u002F\u002F Test fails because findById returns undefined\n\n\u002F\u002F ✅ FIX: Configure mock properly\nconst mockRepo = {\n  findById: vi.fn().mockResolvedValue(testUser),\n};\n\n\u002F\u002F ❌ PROBLEM: Mock not reset between tests\nbeforeEach(() => {\n  \u002F\u002F Forgot to clear mocks!\n});\nit(\"calls repo\", () => {\n  service.getUser(\"1\");\n  expect(mockRepo.findById).toHaveBeenCalled(); \u002F\u002F Passes from previous test?\n});\n\n\u002F\u002F ✅ FIX: Always reset mocks\nbeforeEach(() => {\n  vi.clearAllMocks();\n});\n```\n\n#### 3.4 Test Data Issues\n\n```typescript\n\u002F\u002F ❌ PROBLEM: Test data not matching expectations\nconst user = {\n  name: \"Alice\",\n  email: null, \u002F\u002F What test expects?\n};\n\u002F\u002F Test expects email to be defined\n\n\u002F\u002F ✅ FIX: Ensure test data matches scenario\nconst user = {\n  name: \"Alice\",\n  email: \"alice@example.com\",\n};\n```\n\n### Phase 4: Real Bug vs Test Bug\n\n#### 4.1 Indicators of Real Bug\n\n```markdown\n## Real Bug Signals\n\n□ Code logic can be manually verified wrong\n□ Edge case not handled in code\n□ Type mismatch causing issues\n□ Expected behavior not implemented\n□ Integration with external system broken\n\nExample:\nCode: if (user.isActive && user.isAdmin) \u002F\u002F Should be OR\nTest: Expect admin panel to show for admin user\nFailure: isActive=false, isAdmin=true → fails\nConclusion: Real bug (wrong operator)\n```\n\n#### 4.2 Indicators of Test Bug\n\n```markdown\n## Test Bug Signals\n\n□ Test assertions don't match spec\n□ Test data doesn't match scenario\n□ Wrong assertion type (toBe vs toEqual)\n□ Missing async\u002Fawait\n□ Mock not configured correctly\n□ Test checks implementation, not behavior\n\nExample:\nCode: Returns user object correctly\nTest: expect(user).toBe({ name: \"Alice\" }) \u002F\u002F Reference check!\nFailure: Same values but different object reference\nConclusion: Test bug (wrong assertion)\n```\n\n#### 4.3 Decision Framework\n\n```\n┌─────────────────────────────────────────────────────────────┐\n│                   REAL BUG vs TEST BUG                        │\n│                                                               │\n│  1. Can you manually verify the expected behavior?            │\n│     └─ NO → Test problem or unclear spec                     │\n│     └─ YES → Continue                                        │\n│                                                               │\n│  2. Does changing the test fix the problem?                  │\n│     └─ YES, but test seems correct → Test problem            │\n│     └─ NO → Real bug in code                                │\n│                                                               │\n│  3. Does the code match requirements?                         │\n│     └─ NO → Real bug                                         │\n│     └─ YES, but test fails → Test problem                    │\n└─────────────────────────────────────────────────────────────┘\n```\n\n## Common Scenarios\n\n### Scenario 1: \"toBe vs toEqual\"\n\n```typescript\n\u002F\u002F FAILING TEST\nit(\"should create user\", () => {\n  const user = createUser({ name: \"Alice\" });\n  expect(user).toBe({ name: \"Alice\" }); \u002F\u002F Reference check!\n});\n\n\u002F\u002F WHY IT FAILS:\n\u002F\u002F toBe checks reference (are they the SAME object?)\n\u002F\u002F user is a new object created by createUser()\n\u002F\u002F { name: \"Alice\" } is a different object in memory\n\n\u002F\u002F FIX\nit(\"should create user\", () => {\n  const user = createUser({ name: \"Alice\" });\n  expect(user).toEqual({ name: \"Alice\" }); \u002F\u002F Value check!\n});\n```\n\n### Scenario 2: \"Mock not being called\"\n\n```typescript\n\u002F\u002F FAILING TEST\nit(\"should call logger\", () => {\n  const mockLogger = { info: vi.fn() };\n  const service = new Service(mockLogger);\n\n  service.doSomething();\n\n  expect(mockLogger.info).toHaveBeenCalled(); \u002F\u002F Fails!\n});\n\n\u002F\u002F DEBUG\nit(\"should call logger\", () => {\n  const mockLogger = { info: vi.fn() };\n  const service = new Service(mockLogger);\n\n  service.doSomething();\n\n  console.log(\"Calls:\", mockLogger.info.mock.calls); \u002F\u002F []\n  \u002F\u002F Info was never called...\n\n  \u002F\u002F FIX: Check if the code actually calls logger.info\n  \u002F\u002F Maybe it calls logger.debug instead?\n  \u002F\u002F Or maybe doSomething doesn't actually log?\n});\n```\n\n### Scenario 3: \"Flaky test that sometimes passes\"\n\n```typescript\n\u002F\u002F FLAKY TEST\nit(\"should return users\", async () => {\n  const users = await fetchUsers();\n  expect(users.length).toBeGreaterThan(0);\n});\n\n\u002F\u002F WHY FLAKY:\n\u002F\u002F fetchUsers() returns users from database\n\u002F\u002F Database might be empty in some test runs\n\n\u002F\u002F FIX: Ensure consistent state\nbeforeEach(async () => {\n  await seedTestDatabase(); \u002F\u002F Ensure known state\n});\n\nit(\"should return users\", async () => {\n  const users = await fetchUsers();\n  expect(users.length).toBeGreaterThan(0); \u002F\u002F Now reliable\n});\n```\n\n### Scenario 4: \"Test passes but code is wrong\"\n\n```typescript\n\u002F\u002F PASSING TEST (but code is buggy!)\nit(\"should double numbers\", () => {\n  expect(double(2)).toBe(4);\n  expect(double(3)).toBe(6);\n});\n\nfunction double(n) {\n  return n + 1; \u002F\u002F Bug! Should be n * 2\n}\n\n\u002F\u002F WHY TEST PASSES:\n\u002F\u002F double(2) = 3 ≈ 4? No wait... actually 2+1=3, not 4\n\u002F\u002F Oh wait, it would fail...\n\n\u002F\u002F The point: Sometimes bugs cancel out\n\u002F\u002F Test has implicit bug that makes it pass despite code bug\n\n\u002F\u002F FIX: Better test coverage\nit(\"should double numbers\", () => {\n  expect(double(2)).toBe(4);  \u002F\u002F 2*2=4\n  expect(double(0)).toBe(0);   \u002F\u002F 0*2=0\n  expect(double(-1)).toBe(-2); \u002F\u002F -1*2=-2\n});\n```\n\n## The Test Debugging Checklist\n\n```\nTEST DEBUGGING CHECKLIST\n========================\n\n□ 1. Isolate the failing test\n□ 2. Run only this test (not entire suite)\n□ 3. Add diagnostic logging\n□ 4. Verify expected vs actual values\n□ 5. Check assertion type (toBe vs toEqual)\n□ 6. Verify async\u002Fawait is correct\n□ 7. Check mock configuration\n□ 8. Verify test data is correct\n□ 9. Can you manually verify expected behavior?\n□ 10. Is this a real bug or a test bug?\n\nIF REAL BUG:\n□ Create minimal reproduction\n□ Fix the code\n□ Add regression test\n□ Verify test passes after fix\n\nIF TEST BUG:\n□ Fix the test\n□ Verify test fails with buggy code\n□ Verify test passes with fixed code\n□ Consider: Is there a real bug the test missed?\n```\n\n## Anti-Patterns\n\n### 1. Ignoring Flaky Tests\n\n```typescript\n\u002F\u002F ❌ BAD: \"It passes sometimes, good enough\"\nit.failing(\"should work\", () => { ... });\n\n\u002F\u002F ✅ GOOD: Fix or mark explicitly\nit(\"should work - KNOWN ISSUE: flaky on CI\", () => {\n  \u002F\u002F File issue, fix later\n  \u002F\u002F Or fix the race condition\n});\n```\n\n### 2. Changing Tests to Pass\n\n```typescript\n\u002F\u002F ❌ BAD: \"Just change the test to match whatever code does\"\nexpect(code).toBe(whateverCodeDoes); \u002F\u002F Now always passes!\n\n\u002F\u002F ✅ GOOD: Verify code is correct, then update test if needed\n\u002F\u002F Or: If requirements changed, update both\n```\n\n### 3. Not Testing the Fix\n\n```typescript\n\u002F\u002F ❌ BAD: Fix code, don't verify test\n\u002F\u002F Code was fixed\ngit commit -m \"Fix bug\"\n\u002F\u002F Test still fails because it was wrong!\n\n\u002F\u002F ✅ GOOD: Verify test fails on buggy code, passes on fixed code\n```\n\n## Key Principles\n\n### 1. Trust Tests, But Verify\n\nIf a test fails, assume the test is correct. But verify before changing code.\n\n### 2. Isolation First\n\nIsolate the failing test. Don't run the whole suite while debugging.\n\n### 3. Divide and Conquer\n\nComment out assertions one by one to find which specific check fails.\n\n### 4. Manual Verification\n\nBefore fixing, manually verify what the code SHOULD do. This prevents fixing tests incorrectly.\n\n### 5. Both Fail Together\n\nWhen you find a bug, always ask: \"Is there a test that should have caught this?\"\n\n## Relationship to Other Skills\n\n- `test-think` — Determines what tests are needed\n- `generate-mock` — Mock issues often cause test failures\n- `setup-test-data` — Wrong test data is a common cause\n- `debug-session` — General debugging methodology\n- `understand-error` — Error messages hint at the problem\n","# Debug Test — Test Failure Analysis Framework\n\n## Overview\n\nDebug-test is a **behavioral specification skill** that encapsulates the methodology for **systematically debugging failing tests to determine if the failure is a real bug or a test problem**.\n\nThis skill embodies the expertise of developers who've spent hours chasing phantom test bugs and know the discipline of separating \"my code is broken\" from \"my test is wrong.\"\n\n## Core Philosophy\n\n### The Debugging First Principle\n\n> \"When a test fails, your first question should be: 'Is my test testing what I think it's testing?' The answer is 'not always' more often than you'd think.\"\n\n### Test Failure Types\n\n```\n┌─────────────────────────────────────────────────────────────┐\n│                    TEST FAILURE CATEGORIES                    │\n│                                                               │\n│  REAL BUG IN CODE:          TEST PROBLEM:                     │\n│  ─────────────────          ─────────────                      │\n│  • Code doesn't work       • Test checks wrong thing          │\n│  • Logic is wrong           • Test has wrong assertion        │\n│  • Edge case not handled    • Test data is wrong              │\n│  • Type error               • Test is flaky                  │\n│                                                               │\n│  BOTH:                             NEITHER:                     │\n│  • Code was right, test was vague      • Environment issue    │\n│  • Both code and test wrong           • Tooling issue         │\n└─────────────────────────────────────────────────────────────┘\n```\n\n## Decision Framework\n\n### The Test Failure Diagnosis Tree\n\n```\n                    ┌─ Does test pass locally?\n                    │   └─ NO → Continue\n                    │       └─ YES → Check CI environment\n                    │\n                    └─ Is test flaky?\n                        └─ YES → Flaky test pattern\n                        └─ NO → Continue\n                                │\n                                └─ Does the failing assertion make sense?\n                                    └─ NO → Test problem\n                                    └─ YES → Continue\n                                            │\n                                            └─ Is the code logic correct?\n                                                └─ YES → Test problem\n                                                └─ NO → Real bug\n```\n\n## Behavioral Specification\n\n### Phase 1: Initial Assessment\n\n#### 1.1 Gather Information\n\n```markdown\n## Test Failure Report\n\n| Field | Value |\n|-------|-------|\n| Test name | should_return_user_when_id_exists |\n| File | users.test.ts |\n| Line | 42 |\n| Error type | expect(received).toBe(expected) |\n| Expected | { id: \"123\", name: \"Alice\" } |\n| Received | { id: \"123\", name: \"Alice\" } |\n\nNote: Objects look same but test fails...\n```\n\n#### 1.2 First Checks\n\n```typescript\n\u002F\u002F Check 1: Are objects actually equal?\n\u002F\u002F Deep equality vs reference equality\nexpect(user).toBe(expectedUser); \u002F\u002F Reference\nexpect(user).toEqual(expectedUser); \u002F\u002F Deep (usually what you want)\n\n\u002F\u002F Check 2: Is there a type coercion issue?\n\u002F\u002F \"1\" vs 1\n\u002F\u002F true vs \"true\"\n\u002F\u002F null vs undefined\n\n\u002F\u002F Check 3: Are you comparing what you think?\nconsole.log(\"Expected:\", JSON.stringify(expected, null, 2));\nconsole.log(\"Received:\", JSON.stringify(received, null, 2));\n```\n\n### Phase 2: Isolate the Problem\n\n#### 2.1 Simplify the Test\n\n```typescript\n\u002F\u002F ORIGINAL (complex)\nit(\"should process complex order correctly\", () => {\n  const order = createComplexOrder({ ... });\n  const result = processOrder(order, options, context);\n  expect(result.status).toBe(\"shipped\");\n  expect(result.trackingNumber).toMatch(\u002F^TRACK-\u002F);\n  \u002F\u002F More assertions...\n});\n\n\u002F\u002F SIMPLIFIED (isolate)\nit(\"should process order\", () => {\n  const order = { status: \"pending\" }; \u002F\u002F Minimal\n  const result = processOrder(order);\n  expect(result.status).toBe(\"processing\"); \u002F\u002F Test one thing\n});\n```\n\n#### 2.2 Add Diagnostic Logging\n\n```typescript\nit(\"should calculate total correctly\", () => {\n  const items = [\n    { price: 10, quantity: 2 },\n    { price: 5, quantity: 3 },\n  ];\n\n  console.log(\"Input items:\", items);\n  const total = calculateTotal(items);\n  console.log(\"Calculated total:\", total);\n  console.log(\"Expected:\", 35); \u002F\u002F 10*2 + 5*3 = 35\n\n  expect(total).toBe(35);\n});\n```\n\n#### 2.3 Test in Isolation\n\n```typescript\n\u002F\u002F BEFORE: Full system test\nit(\"should work with database\", async () => {\n  const result = await fullIntegrationTest();\n  \u002F\u002F Too many variables\n});\n\n\u002F\u002F AFTER: Unit test\nit(\"should calculate total\", () => {\n  const calculator = new OrderCalculator(mockLogger);\n  const result = calculator.calculateTotal(items);\n  \u002F\u002F Isolated, clear failure point\n});\n```\n\n### Phase 3: Common Test Problems\n\n#### 3.1 Wrong Assertion Type\n\n```typescript\n\u002F\u002F ❌ PROBLEM: Checking reference, not value\nconst user1 = { name: \"Alice\" };\nconst user2 = { name: \"Alice\" };\nexpect(user1).toBe(user2); \u002F\u002F Fails! Different objects\n\n\u002F\u002F ✅ FIX: Check value\nexpect(user1).toEqual(user2); \u002F\u002F Passes! Same values\n\n\u002F\u002F ❌ PROBLEM: toBe for objects\nexpect({ a: 1 }).toBe({ a: 1 }); \u002F\u002F Fails!\n\n\u002F\u002F ✅ FIX: toEqual for objects\nexpect({ a: 1 }).toEqual({ a: 1 }); \u002F\u002F Passes!\n```\n\n#### 3.2 Async Issues\n\n```typescript\n\u002F\u002F ❌ PROBLEM: Not waiting for async\nit(\"should update user\", async () => {\n  await updateUser({ id: \"1\", name: \"Bob\" });\n  const user = getUser(\"1\");\n  expect(user.name).toBe(\"Bob\"); \u002F\u002F Might pass\u002Ffail randomly\n});\n\n\u002F\u002F ✅ FIX: Properly await\nit(\"should update user\", async () => {\n  await updateUser({ id: \"1\", name: \"Bob\" });\n  const user = await getUser(\"1\"); \u002F\u002F Await here too!\n  expect(user.name).toBe(\"Bob\");\n});\n\n\u002F\u002F ❌ PROBLEM: Forgotten async\nit(\"should return promise\", () => {\n  const promise = fetchData(); \u002F\u002F Returns promise\n  expect(promise).resolves.toEqual(data); \u002F\u002F Missing async\u002Fawait\n});\n\n\u002F\u002F ✅ FIX: Handle promise correctly\nit(\"should return promise\", async () => {\n  const promise = fetchData();\n  await expect(promise).resolves.toEqual(data);\n});\n```\n\n#### 3.3 Mock Configuration Errors\n\n```typescript\n\u002F\u002F ❌ PROBLEM: Mock not configured correctly\nconst mockRepo = {\n  findById: vi.fn(), \u002F\u002F No return value!\n};\n\u002F\u002F Test fails because findById returns undefined\n\n\u002F\u002F ✅ FIX: Configure mock properly\nconst mockRepo = {\n  findById: vi.fn().mockResolvedValue(testUser),\n};\n\n\u002F\u002F ❌ PROBLEM: Mock not reset between tests\nbeforeEach(() => {\n  \u002F\u002F Forgot to clear mocks!\n});\nit(\"calls repo\", () => {\n  service.getUser(\"1\");\n  expect(mockRepo.findById).toHaveBeenCalled(); \u002F\u002F Passes from previous test?\n});\n\n\u002F\u002F ✅ FIX: Always reset mocks\nbeforeEach(() => {\n  vi.clearAllMocks();\n});\n```\n\n#### 3.4 Test Data Issues\n\n```typescript\n\u002F\u002F ❌ PROBLEM: Test data not matching expectations\nconst user = {\n  name: \"Alice\",\n  email: null, \u002F\u002F What test expects?\n};\n\u002F\u002F Test expects email to be defined\n\n\u002F\u002F ✅ FIX: Ensure test data matches scenario\nconst user = {\n  name: \"Alice\",\n  email: \"alice@example.com\",\n};\n```\n\n### Phase 4: Real Bug vs Test Bug\n\n#### 4.1 Indicators of Real Bug\n\n```markdown\n## Real Bug Signals\n\n□ Code logic can be manually verified wrong\n□ Edge case not handled in code\n□ Type mismatch causing issues\n□ Expected behavior not implemented\n□ Integration with external system broken\n\nExample:\nCode: if (user.isActive && user.isAdmin) \u002F\u002F Should be OR\nTest: Expect admin panel to show for admin user\nFailure: isActive=false, isAdmin=true → fails\nConclusion: Real bug (wrong operator)\n```\n\n#### 4.2 Indicators of Test Bug\n\n```markdown\n## Test Bug Signals\n\n□ Test assertions don't match spec\n□ Test data doesn't match scenario\n□ Wrong assertion type (toBe vs toEqual)\n□ Missing async\u002Fawait\n□ Mock not configured correctly\n□ Test checks implementation, not behavior\n\nExample:\nCode: Returns user object correctly\nTest: expect(user).toBe({ name: \"Alice\" }) \u002F\u002F Reference check!\nFailure: Same values but different object reference\nConclusion: Test bug (wrong assertion)\n```\n\n#### 4.3 Decision Framework\n\n```\n┌─────────────────────────────────────────────────────────────┐\n│                   REAL BUG vs TEST BUG                        │\n│                                                               │\n│  1. Can you manually verify the expected behavior?            │\n│     └─ NO → Test problem or unclear spec                     │\n│     └─ YES → Continue                                        │\n│                                                               │\n│  2. Does changing the test fix the problem?                  │\n│     └─ YES, but test seems correct → Test problem            │\n│     └─ NO → Real bug in code                                │\n│                                                               │\n│  3. Does the code match requirements?                         │\n│     └─ NO → Real bug                                         │\n│     └─ YES, but test fails → Test problem                    │\n└─────────────────────────────────────────────────────────────┘\n```\n\n## Common Scenarios\n\n### Scenario 1: \"toBe vs toEqual\"\n\n```typescript\n\u002F\u002F FAILING TEST\nit(\"should create user\", () => {\n  const user = createUser({ name: \"Alice\" });\n  expect(user).toBe({ name: \"Alice\" }); \u002F\u002F Reference check!\n});\n\n\u002F\u002F WHY IT FAILS:\n\u002F\u002F toBe checks reference (are they the SAME object?)\n\u002F\u002F user is a new object created by createUser()\n\u002F\u002F { name: \"Alice\" } is a different object in memory\n\n\u002F\u002F FIX\nit(\"should create user\", () => {\n  const user = createUser({ name: \"Alice\" });\n  expect(user).toEqual({ name: \"Alice\" }); \u002F\u002F Value check!\n});\n```\n\n### Scenario 2: \"Mock not being called\"\n\n```typescript\n\u002F\u002F FAILING TEST\nit(\"should call logger\", () => {\n  const mockLogger = { info: vi.fn() };\n  const service = new Service(mockLogger);\n\n  service.doSomething();\n\n  expect(mockLogger.info).toHaveBeenCalled(); \u002F\u002F Fails!\n});\n\n\u002F\u002F DEBUG\nit(\"should call logger\", () => {\n  const mockLogger = { info: vi.fn() };\n  const service = new Service(mockLogger);\n\n  service.doSomething();\n\n  console.log(\"Calls:\", mockLogger.info.mock.calls); \u002F\u002F []\n  \u002F\u002F Info was never called...\n\n  \u002F\u002F FIX: Check if the code actually calls logger.info\n  \u002F\u002F Maybe it calls logger.debug instead?\n  \u002F\u002F Or maybe doSomething doesn't actually log?\n});\n```\n\n### Scenario 3: \"Flaky test that sometimes passes\"\n\n```typescript\n\u002F\u002F FLAKY TEST\nit(\"should return users\", async () => {\n  const users = await fetchUsers();\n  expect(users.length).toBeGreaterThan(0);\n});\n\n\u002F\u002F WHY FLAKY:\n\u002F\u002F fetchUsers() returns users from database\n\u002F\u002F Database might be empty in some test runs\n\n\u002F\u002F FIX: Ensure consistent state\nbeforeEach(async () => {\n  await seedTestDatabase(); \u002F\u002F Ensure known state\n});\n\nit(\"should return users\", async () => {\n  const users = await fetchUsers();\n  expect(users.length).toBeGreaterThan(0); \u002F\u002F Now reliable\n});\n```\n\n### Scenario 4: \"Test passes but code is wrong\"\n\n```typescript\n\u002F\u002F PASSING TEST (but code is buggy!)\nit(\"should double numbers\", () => {\n  expect(double(2)).toBe(4);\n  expect(double(3)).toBe(6);\n});\n\nfunction double(n) {\n  return n + 1; \u002F\u002F Bug! Should be n * 2\n}\n\n\u002F\u002F WHY TEST PASSES:\n\u002F\u002F double(2) = 3 ≈ 4? No wait... actually 2+1=3, not 4\n\u002F\u002F Oh wait, it would fail...\n\n\u002F\u002F The point: Sometimes bugs cancel out\n\u002F\u002F Test has implicit bug that makes it pass despite code bug\n\n\u002F\u002F FIX: Better test coverage\nit(\"should double numbers\", () => {\n  expect(double(2)).toBe(4);  \u002F\u002F 2*2=4\n  expect(double(0)).toBe(0);   \u002F\u002F 0*2=0\n  expect(double(-1)).toBe(-2); \u002F\u002F -1*2=-2\n});\n```\n\n## The Test Debugging Checklist\n\n```\nTEST DEBUGGING CHECKLIST\n========================\n\n□ 1. Isolate the failing test\n□ 2. Run only this test (not entire suite)\n□ 3. Add diagnostic logging\n□ 4. Verify expected vs actual values\n□ 5. Check assertion type (toBe vs toEqual)\n□ 6. Verify async\u002Fawait is correct\n□ 7. Check mock configuration\n□ 8. Verify test data is correct\n□ 9. Can you manually verify expected behavior?\n□ 10. Is this a real bug or a test bug?\n\nIF REAL BUG:\n□ Create minimal reproduction\n□ Fix the code\n□ Add regression test\n□ Verify test passes after fix\n\nIF TEST BUG:\n□ Fix the test\n□ Verify test fails with buggy code\n□ Verify test passes with fixed code\n□ Consider: Is there a real bug the test missed?\n```\n\n## Anti-Patterns\n\n### 1. Ignoring Flaky Tests\n\n```typescript\n\u002F\u002F ❌ BAD: \"It passes sometimes, good enough\"\nit.failing(\"should work\", () => { ... });\n\n\u002F\u002F ✅ GOOD: Fix or mark explicitly\nit(\"should work - KNOWN ISSUE: flaky on CI\", () => {\n  \u002F\u002F File issue, fix later\n  \u002F\u002F Or fix the race condition\n});\n```\n\n### 2. Changing Tests to Pass\n\n```typescript\n\u002F\u002F ❌ BAD: \"Just change the test to match whatever code does\"\nexpect(code).toBe(whateverCodeDoes); \u002F\u002F Now always passes!\n\n\u002F\u002F ✅ GOOD: Verify code is correct, then update test if needed\n\u002F\u002F Or: If requirements changed, update both\n```\n\n### 3. Not Testing the Fix\n\n```typescript\n\u002F\u002F ❌ BAD: Fix code, don't verify test\n\u002F\u002F Code was fixed\ngit commit -m \"Fix bug\"\n\u002F\u002F Test still fails because it was wrong!\n\n\u002F\u002F ✅ GOOD: Verify test fails on buggy code, passes on fixed code\n```\n\n## Key Principles\n\n### 1. Trust Tests, But Verify\n\nIf a test fails, assume the test is correct. But verify before changing code.\n\n### 2. Isolation First\n\nIsolate the failing test. Don't run the whole suite while debugging.\n\n### 3. Divide and Conquer\n\nComment out assertions one by one to find which specific check fails.\n\n### 4. Manual Verification\n\nBefore fixing, manually verify what the code SHOULD do. This prevents fixing tests incorrectly.\n\n### 5. Both Fail Together\n\nWhen you find a bug, always ask: \"Is there a test that should have caught this?\"\n\n## Relationship to Other Skills\n\n- `test-think` — Determines what tests are needed\n- `generate-mock` — Mock issues often cause test failures\n- `setup-test-data` — Wrong test data is a common cause\n- `debug-session` — General debugging methodology\n- `understand-error` — Error messages hint at the problem\n",{"name":5,"category":43,"priority":53,"description":7,"trigger_patterns":54},"P2",[55,29,56,57,58,59],"test failed","fix test","test not working","why is this test failing","test debugging","main","b9a52d8e27455bdad953d64928696d028223ea1b","skills\u002Fcoding\u002Fdebug-test","https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager","https:\u002F\u002Fgithub.com\u002FImaginerLabs","2026-04-18 16:27:13",{"source":8,"skillName":5,"commands":67,"prompt":77,"zipAvailable":78},[68,71,74],{"tool":69,"command":70},"npx","npx skills add ImaginerLabs\u002Fskill-manager --skill debug-test",{"tool":72,"command":73},"bunx","bunx skills add ImaginerLabs\u002Fskill-manager --skill debug-test",{"tool":75,"command":76},"pnpm","pnpm dlx skills add ImaginerLabs\u002Fskill-manager --skill debug-test","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager\u002Fblob\u002Fmain\u002Fskills\u002Fcoding\u002Fdebug-test\u002FSKILL.md",true,[],[81,112,133,161,191,216],{"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":93,"publishedAt":48},"01M6QJCB2SD5KHC41ZDQC0GA1T","meeting-minutes","Generate concise, actionable meeting minutes for internal meetings. Includes metadata, attendees, agenda, decisions, action items (owner + due date), and follow-up steps.","https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager\u002Fblob\u002Fmain\u002Fskills\u002Fwriting\u002Fmeeting-minutes\u002FSKILL.md",[87,90],{"categoryNo":88,"categoryName":89,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000023","Skill与智能体开发",{"categoryNo":91,"categoryName":92,"taxonomyType":25,"taxonomyTypeDesc":26},"01JBSEEDCAT000000000000034","行政与办公人员",[94,95,96,97,98,99,100,101,102,103,83,60,104,105,106,107,108,109,110,111],"meeting minutes","meeting","minutes","writing","github","copilot","generate","decisions","meetings","up","agenda","actionable","concise","follow-up","tree","true","action","for",{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":118,"publishedAt":48},"01M6QJC71RRGTGNNFEHJG6S20G","documentation-writer","Diátaxis Documentation Expert. An expert technical writer specializing in creating high-quality software documentation, guided by the principles and structure of the Diátaxis technical documentation authoring framework.","https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager\u002Fblob\u002Fmain\u002Fskills\u002Fwriting\u002Fdocumentation-writer\u002FSKILL.md",[],[119,120,121,97,98,99,122,123,124,125,126,127,60,128,129,130,131,108,109,132],"documentation","documentation writer","writer","https","quality","technical","technical writer","expert","documentation expert","structure","authoring","software","principles","high",{"skillNo":134,"name":135,"nameZh":6,"description":136,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":137,"categories":138,"keywords":146,"publishedAt":48},"01M6QJC0V3C7C4R9768J1AJYWY","doc-coauthoring","Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks.","https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager\u002Fblob\u002Fmain\u002Fskills\u002Fwriting\u002Fdoc-coauthoring\u002FSKILL.md",[139,142,143],{"categoryNo":140,"categoryName":141,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":88,"categoryName":89,"taxonomyType":20,"taxonomyTypeDesc":21},{"categoryNo":144,"categoryName":145,"taxonomyType":25,"taxonomyTypeDesc":26},"01JBSEEDCAT000000000000036","内容创作者",[147,148,97,149,150,119,151,152,153,154,155,156,60,157,158,129,159,160,108,111],"doc coauthoring","doc","workflow","official","tasks","decision","write","context","proposals","guide","refine","iteration","trigger","co",{"skillNo":162,"name":163,"nameZh":6,"description":164,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":165,"categories":166,"keywords":173,"publishedAt":48},"01M6QJBJ0YPVEWGEXZH3PJRRTT","code-review-workflow","Executes comprehensive 4-phase code review: basic review, quality check, bundle analysis, and test coverage. Should be used when the user mentions comprehensive code review, checking code quality, or reviewing staged changes with multi-phase analysis. This is the comprehensive review workflow, distinct from focused skills like frontend-code-review, staged-code-review, or code-change-test-designer.","https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager\u002Fblob\u002Fmain\u002Fskills\u002Ftesting\u002Fcode-review-workflow\u002FSKILL.md",[167,170,171,172],{"categoryNo":168,"categoryName":169,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000007","代码审查",{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},{"categoryNo":88,"categoryName":89,"taxonomyType":20,"taxonomyTypeDesc":21},{"categoryNo":23,"categoryName":24,"taxonomyType":25,"taxonomyTypeDesc":26},[174,175,149,46,176,177,178,30,179,180,181,182,183,184,185,186,187,188,189,190],"code review","review","code review workflow","testing","frontend","change","code quality","code-review","analysis","check","coverage","quality check","basic","multi","comprehensive code review","with","phase",{"skillNo":192,"name":193,"nameZh":6,"description":194,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":195,"categories":196,"keywords":206,"publishedAt":48},"01M6QJB7XNHV3VEEQF4W7FMWF6","code-change-test-designer","Analyzes code changes and designs comprehensive test cases. Reads diffs, summarizes capability changes, and designs test cases covering main flows and edge cases. Should be used when the user mentions test coverage, designing tests for code changes, or analyzing diff\u002Fcommit for testing purposes. Distinguished from code-review-workflow which provides comprehensive review, this skill focuses on test case design for code changes.","https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager\u002Fblob\u002Fmain\u002Fskills\u002Ftesting\u002Fcode-change-test-designer\u002FSKILL.md",[197,198,201,202,203],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},{"categoryNo":199,"categoryName":200,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000015","视觉设计",{"categoryNo":88,"categoryName":89,"taxonomyType":20,"taxonomyTypeDesc":21},{"categoryNo":23,"categoryName":24,"taxonomyType":25,"taxonomyTypeDesc":26},{"categoryNo":204,"categoryName":205,"taxonomyType":25,"taxonomyTypeDesc":26},"01JBSEEDCAT000000000000032","设计师",[30,179,46,207,208,177,209,210,149,211,181,212,184,213,60,35,214,215,111,190],"designer","code change test designer","design","diffs","commit","edge","diff","flows","which",{"skillNo":217,"name":218,"nameZh":6,"description":219,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":220,"categories":221,"keywords":223,"publishedAt":48},"01M6QJB195WD7DCJWDMKWKB29S","skill-creator","Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.","https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager\u002Fblob\u002Fmain\u002Fskills\u002Fmeta-skills\u002Fskill-creator\u002FSKILL.md",[222],{"categoryNo":88,"categoryName":89,"taxonomyType":20,"taxonomyTypeDesc":21},[224,225,226,227,150,228,229,230,231,232,182,233,234,235,60,236,237,108,111,218],"skill creator","creator","performance","run evals","variance analysis","create","run","benchmark","Meta","improve","edit","evals","optimize","existing skill"]