TEST_FAILURE_ANALYSIS.md•5.04 kB
# Test Failure Analysis Report
## Summary
- **Total Failing Tests**: 5 test suites with specific failures
- **Test Status**: 9 failed, 2 passed, 11 total
- **Root Causes Identified**: Configuration mismatches, missing files, TypeScript interface mismatches, and module resolution errors
## Detailed Analysis of Failing Tests
### 1. GitHub Release Workflow Test (`github-release.test.js`)
**Status**: FAILING
**Location**: `tests/github-release.test.js:28`
**Root Cause**:
- The release workflow uses `gh` CLI tool instead of GitHub Actions
- Test expects `uses: actions/create-release` or `uses: softprops/action-gh-release`
- Actual workflow uses: `gh release create` command
**Test Expectation**:
```javascript
expect(workflow).toMatch(/uses: actions\/create-release|uses: softprops\/action-gh-release/);
```
**Actual Implementation**:
```yaml
- name: Create Release
run: |
gh release create ${{ github.ref_name }} \
--title "Release ${{ github.ref_name }}" \
--notes "$(cat CHANGELOG.md | head -50)" \
--verify-tag
```
**Fix Required**: Either update the test to accept `gh release create` or change workflow to use GitHub Actions.
### 2. Jest ESM Configuration Test (`jest-esm.test.js`)
**Status**: FAILING
**Location**: `tests/jest-esm.test.js:38`
**Root Cause**:
- Test expects `transform: {}` (empty transform)
- Actual config has `transform` with ts-jest configurations
**Test Expectation**:
```javascript
expect(config).toContain('transform: {}');
```
**Actual Implementation**:
```javascript
transform: {
'^.+\\.(ts|tsx)$': ['ts-jest', { useESM: true }],
'^.+\\.js$': ['ts-jest', { useESM: true }]
}
```
**Fix Required**: Update test to accept the ts-jest transform configuration for ESM.
### 3. Docker Build Tests (`docker-build.test.js`)
**Status**: 3 FAILURES
#### 3a. Missing .dockerignore file
**Location**: `tests/docker-build.test.js:46`
- **Root Cause**: `.dockerignore` file does not exist
- **Fix Required**: Create `.dockerignore` file
#### 3b. Missing ENV NODE_ENV
**Location**: `tests/docker-build.test.js:92`
- **Root Cause**: Dockerfile doesn't set `ENV NODE_ENV`
- **Fix Required**: Add `ENV NODE_ENV=production` to Dockerfile
#### 3c. HEALTHCHECK format mismatch
**Location**: `tests/docker-build.test.js:201`
- **Root Cause**: Test regex expects different format
- **Current**: `HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \\`
- **Test Expects**: Pattern `/HEALTHCHECK\s+--interval=.*CMD/`
- **Fix Required**: Update test regex to match multiline HEALTHCHECK
### 4. Unit Tests - Module Resolution Failures
**Status**: FAILING TO RUN
**Files**:
- `tests/unit/youtube-transcript.service.test.ts`
- `tests/unit/mcp-server.test.js`
- `tests/unit/youtube-transcript.service.test.js`
**Root Cause**: Tests try to mock non-existent module paths
- Attempting to mock `'../../src/utils/logger'`
- Attempting to mock `'../../src/utils/cache'`
- Attempting to mock `'../../src/services/youtube-transcript.service'`
**Actual File Structure**:
- Logger exists at: `src/utils/logger.ts`
- Cache exists at: `src/utils/cache.ts`
- Service exists at: `src/services/youtube-transcript.service.ts`
**Fix Required**: The tests are compiled JavaScript files trying to import TypeScript source files. Need to update import paths or mock strategy.
### 5. Integration Test - TypeScript Interface Mismatch
**Status**: FAILING TO COMPILE
**File**: `tests/integration/end-to-end.test.ts`
**Locations**: Lines 30, 59, 83, 126, 153, 184, 208
**Root Cause**: Mock data missing required `offset` property
- YouTube Transcript API `TranscriptResponse` interface requires:
```typescript
interface TranscriptResponse {
text: string;
duration: number;
offset: number; // REQUIRED
lang?: string;
}
```
- Test mocks only provide:
```javascript
{ text: 'string', start: number, duration: number }
```
**Fix Required**: Update all mock transcript objects to include `offset` property.
## Fix Priority Order
1. **HIGH**: Fix TypeScript interface mismatch in integration tests (blocking compilation)
2. **HIGH**: Fix module resolution in unit tests (blocking test execution)
3. **MEDIUM**: Create .dockerignore file
4. **MEDIUM**: Update Dockerfile with ENV NODE_ENV
5. **LOW**: Update test expectations for GitHub Release workflow
6. **LOW**: Update Jest ESM test expectations
7. **LOW**: Fix HEALTHCHECK regex pattern
## Categorization by Fix Type
### Configuration Fixes
- Create `.dockerignore`
- Add `ENV NODE_ENV` to Dockerfile
### Test Expectation Updates
- GitHub Release workflow test (accept gh CLI)
- Jest ESM config test (accept ts-jest transform)
- Docker HEALTHCHECK test (fix regex)
### Code Fixes
- Add `offset` property to all mock transcript objects
- Fix module import paths in unit tests
### Module Resolution Strategy
- Tests are compiled to JavaScript but trying to import TypeScript files
- Either:
- Import from compiled `/dist` directory
- Use path mapping in Jest config
- Mock at a different level