You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: strip file extensions from JS/TS import paths in generated tests
LLMs often add .js extensions to TypeScript import paths (e.g.,
`import { func } from '../module.js'`), but TypeScript's module resolution
doesn't require explicit extensions. This causes "Cannot find module" errors
when Jest tries to resolve these imports.
This change adds `strip_js_extensions()` to remove .js/.ts/.tsx/.jsx/.mjs/.mts
extensions from relative import paths in generated tests. The function handles:
- ES module imports: import { x } from '../path/file.js'
- CommonJS requires: require('../path/file.js')
- Jest mocks: jest.mock('../path/file.js'), jest.doMock(), etc.
External package imports (lodash, react, etc.) and alias imports (@/components)
are preserved.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
0 commit comments