GITHUBCLIENT_FIX_SUCCESS.mdโข1.98 kB
# GitHubClient Test Fix - Success Report
**Date**: July 5, 2025
**PR**: #56
**Status**: โ
FIXED
## Problem Summary
GitHubClient.test.ts was failing with two issues:
1. TypeScript compilation errors: "Argument of type 'X' is not assignable to parameter of type 'never'"
2. Runtime ESM module errors: "Cannot use import statement outside a module"
## Solution Applied
### 1. TypeScript Fix
Added type assertions to all jest.fn() calls:
```typescript
(jest.fn() as any).mockResolvedValue(mockData)
```
### 2. ESM Configuration Fix
Updated Jest to properly handle ES modules:
**jest.config.cjs changes:**
- Changed preset from `'ts-jest'` to `'ts-jest/presets/default-esm'`
- Added `globals: { 'ts-jest': { useESM: true } }`
- Updated transform to include `{ useESM: true }`
- Added `zod` to transformIgnorePatterns
**package.json changes:**
- Added `NODE_OPTIONS='--experimental-vm-modules --no-warnings'` to all test scripts
**tsconfig.json changes:**
- Added `"ts-node": { "esm": true }`
## Results
โ
**GitHubClient tests now pass**: 19/19 tests passing in 0.786s
## Key Learnings
1. The solution was found in `/MCP-Servers/Notes/jest-esm-typescript-solution.md`
2. Jest's ESM support requires specific configuration with ts-jest
3. Both `@modelcontextprotocol` AND `zod` needed to be in transformIgnorePatterns
4. The `--experimental-vm-modules` flag is still needed for Node.js ESM support in Jest
## Impact on Other Tests
Some other tests are now failing due to the ESM configuration change:
- auto-update.test.ts
- integration.test.ts
- performance.test.ts
These will need to be updated to work with the new ESM configuration.
## Next Steps
1. Merge PR #56 once CI passes
2. Update failing tests to work with ESM configuration
3. Consider documenting this ESM configuration for future reference
## References
- Solution found in: `/MCP-Servers/Notes/jest-esm-typescript-solution.md`
- PR: https://github.com/mickdarling/DollhouseMCP/pull/56
- Issue: #55