fix: resolve test module path for JS when tests are outside tests_project_rootdir#1871
fix: resolve test module path for JS when tests are outside tests_project_rootdir#1871aseembits93 wants to merge 1 commit intomainfrom
Conversation
…ject_rootdir For JavaScript projects, generated tests are placed near the source file (e.g., code_to_optimize/js/.../tests/codeflash-generated/) rather than under tests_project_rootdir. This caused module_name_from_file_path to crash with ValueError. Fall back to project_root_path when the test path isn't under tests_project_rootdir. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @aseembits93's task in 3m 35s —— View job PR Review SummaryTodo
Prek Checks✅ Mypy was not run via prek (interactive prompt issue in CI environment), but the new test function has proper Code ReviewThe fix is correct and handles the root cause: for JS/TS, No bugs found. A few observations: Duplicate fallback pattern — The same try/except pattern is now in two places:
Both fallbacks are identical in structure. Extracting a small helper (e.g., Other callers not affected —
Duplicate DetectionNo duplicates detected. The two changed call sites are intentionally parallel (test generation vs. test repair), not candidates for a shared abstraction in this codebase style. Test Coverage
Bot PR CleanupClosed PR #1870 ( Last updated: 2026-03-18 |
Summary
tests_project_rootdir), causingmodule_name_from_file_pathto crash withValueErrorproject_root_pathinverifier.pyandfunction_optimizer.pywhen test path isn't undertests_project_rootdirTest plan
test_module_name_from_file_path_not_under_rootpassescodeflash --file code_to_optimize/js/code_to_optimize_js/calculator.js --module-root code_to_optimize --subagentruns to completion🤖 Generated with Claude Code