|
| 1 | +# TASK_067: Fix GitHub Release Pipeline - mock.module Cross-Test Pollution |
| 2 | + |
| 3 | +**Purpose**: Fix CI test failures in GitHub release pipeline caused by mock.module pollution between test files, specifically where index.test.ts mocks persist and interfere with coderabbit.test.ts execution. |
| 4 | + |
| 5 | +**Status**: in_progress |
| 6 | + |
| 7 | +**Started**: 2025-09-17 21:37 |
| 8 | + |
| 9 | +## Requirements |
| 10 | +- [ ] Analyze current mock.module usage in index.test.ts and coderabbit.test.ts |
| 11 | +- [ ] Identify the specific mock pollution causing CI failures |
| 12 | +- [ ] Fix mock isolation in index.test.ts by adding proper cleanup |
| 13 | +- [ ] Ensure mock.module effects don't persist between test files |
| 14 | +- [ ] Verify tests pass in different execution orders |
| 15 | +- [ ] Validate fix works in CI environment |
| 16 | +- [ ] Document the solution for future reference |
| 17 | + |
| 18 | +## Success Criteria |
| 19 | +- [ ] All tests pass consistently in CI pipeline |
| 20 | +- [ ] No mock pollution between test files |
| 21 | +- [ ] Tests return expected values (not "CodeRabbit review content" from wrong mock) |
| 22 | +- [ ] GitHub release pipeline completes successfully |
| 23 | +- [ ] Tests maintain proper isolation and can run in any order |
| 24 | + |
| 25 | +## Technical Approach |
| 26 | +### Root Cause Analysis |
| 27 | +- `index.test.ts` uses `mock.module('./coderabbit', ...)` returning `{ success: true, review: 'CodeRabbit review content' }` |
| 28 | +- This mock persists in CI and affects `coderabbit.test.ts` tests |
| 29 | +- Tests expect their own mocks but get the index.test.ts mock instead |
| 30 | +- Results in 1ms execution times (mocked speed) with wrong return values |
| 31 | + |
| 32 | +### Solution Options |
| 33 | +1. **Add proper cleanup in afterEach** (Primary approach): |
| 34 | + - Call `mock.restore()` after each test in index.test.ts |
| 35 | + - Ensure mock.module effects don't persist |
| 36 | + |
| 37 | +2. **Switch to dependency injection** (Alternative): |
| 38 | + - Pass mocked dependencies directly instead of using mock.module |
| 39 | + - Match the pattern used in coderabbit.test.ts |
| 40 | + |
| 41 | +## Current Focus |
| 42 | +Implementing proper mock cleanup in index.test.ts to prevent cross-test pollution while maintaining test functionality. |
| 43 | + |
| 44 | +## Next Steps |
| 45 | +1. Examine current test files to understand mock usage patterns |
| 46 | +2. Implement mock.restore() calls in appropriate locations |
| 47 | +3. Test locally with different execution orders |
| 48 | +4. Validate fix resolves CI failures |
| 49 | +5. Update release pipeline if needed |
0 commit comments