@@ -487,8 +487,7 @@ def __init__(
487487 rel_path = os .path .relpath (str (source_file_abs ), str (tests_root_abs ))
488488 self .original_module_path = rel_path
489489 logger .debug (
490- f"!lsp|JS module path: source={ source_file_abs } , "
491- f"tests_root={ tests_root_abs } , rel_path={ rel_path } "
490+ f"!lsp|JS module path: source={ source_file_abs } , tests_root={ tests_root_abs } , rel_path={ rel_path } "
492491 )
493492 except ValueError :
494493 # Fallback if paths are on different drives (Windows)
@@ -600,6 +599,24 @@ def generate_and_instrument_tests(
600599 for test_index in range (n_tests )
601600 ]
602601
602+ # For JavaScript/TypeScript, copy all runtime files to tests directory
603+ if language in ("javascript" , "typescript" ):
604+ import shutil
605+
606+ from codeflash .languages .javascript .runtime import get_all_runtime_files
607+
608+ # Copy all runtime files (helper, serializer, comparator, etc.)
609+ for runtime_file_source in get_all_runtime_files ():
610+ runtime_file_dest = self .test_cfg .tests_root / runtime_file_source .name
611+
612+ # Copy file if it doesn't exist or is outdated
613+ if (
614+ not runtime_file_dest .exists ()
615+ or runtime_file_source .stat ().st_mtime > runtime_file_dest .stat ().st_mtime
616+ ):
617+ shutil .copy2 (runtime_file_source , runtime_file_dest )
618+ logger .debug (f"Copied { runtime_file_source .name } to { runtime_file_dest } " )
619+
603620 test_results = self .generate_tests (
604621 testgen_context = code_context .testgen_context ,
605622 helper_functions = code_context .helper_functions ,
@@ -854,7 +871,9 @@ def handle_successful_candidate(
854871 else :
855872 with progress_bar ("Running line-by-line profiling" ):
856873 line_profile_test_results = self .line_profiler_step (
857- code_context = code_context , original_helper_code = original_helper_code , candidate_index = candidate_index
874+ code_context = code_context ,
875+ original_helper_code = original_helper_code ,
876+ candidate_index = candidate_index ,
858877 )
859878
860879 eval_ctx .record_line_profiler_result (candidate .optimization_id , line_profile_test_results ["str_out" ])
@@ -2231,6 +2250,7 @@ def establish_original_code_baseline(
22312250 for result in behavioral_results
22322251 if (result .test_type == TestType .GENERATED_REGRESSION and not result .did_pass )
22332252 ]
2253+
22342254 if total_timing == 0 :
22352255 logger .warning ("The overall summed benchmark runtime of the original function is 0, couldn't run tests." )
22362256 console .rule ()
@@ -2414,7 +2434,9 @@ def run_optimized_candidate(
24142434 logger .error (f"Candidate SQLite database not found: { candidate_sqlite } " )
24152435 logger .debug ("No diffs found, skipping repair" )
24162436 # Use Python-style comparison on TestResults as fallback
2417- match , diffs = compare_test_results (baseline_results .behavior_test_results , candidate_behavior_results )
2437+ match , diffs = compare_test_results (
2438+ baseline_results .behavior_test_results , candidate_behavior_results
2439+ )
24182440 else :
24192441 # Python: Compare using Python comparator
24202442 match , diffs = compare_test_results (baseline_results .behavior_test_results , candidate_behavior_results )
0 commit comments