codeflash-internal/django
mohammed ahmed d10868e05e
Fix: Strip .js extensions from all test outputs in JS/TS testgen (#2551)
## Problem
Generated tests imported TypeScript files with `.js` extensions, causing
"Cannot find module" errors. The AI service was only stripping
extensions from `generated_test_source` but NOT from
`instrumented_behavior_tests` and `instrumented_perf_tests` (which the
CLI actually uses).

## Root Cause
**File:** `core/languages/js_ts/testgen.py:608`

Only `generated_test_source` received `strip_js_extensions()` call. The
CLI uses `instrumented_behavior_tests` from the response, which still
had incorrect `.js` extensions on TypeScript imports.

## Impact
- Affected **15 out of 20 test runs (~75% failure rate)**
- **Severity: HIGH** - systematic bug blocking all TypeScript projects
- **Error:** `Cannot find module '../../google.js'` when source is
`google.ts`

## Fix
Apply `strip_js_extensions()` to all three test output variants:
- `generated_test_source` (already done)
- `instrumented_behavior_tests`  **NEW**
- `instrumented_perf_tests`  **NEW**

## Testing
 All 32 existing JavaScript testgen tests pass
 Added regression test for extension stripping  
 Verified with `--rerun` on trace
`03899729-131e-4ff6-8149-c132bd888089`
 No "Cannot find module *.js" errors after fix

## References
**Trace IDs exhibiting this bug:**
- `03899729-131e-4ff6-8149-c132bd888089`
- `19446b34-cd22-4a38-b304-22c16ba86747`
- (and 13 others - see `/workspace/logs`)

**Related:** AI Service Reference doc section 10.1 issue #2

---------

Co-authored-by: mohammed ahmed <mohammedahmed18@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
2026-04-04 16:30:41 +05:30
..
aiservice Fix: Strip .js extensions from all test outputs in JS/TS testgen (#2551) 2026-04-04 16:30:41 +05:30
.dockerignore local setup (#1898) 2025-11-17 12:35:09 -08:00