Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions codeflash/languages/javascript/edit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,14 @@ def inject_test_globals(
"import { jest, describe, it, expect, beforeEach, afterEach, beforeAll, test } from '@jest/globals'\n"
)

stripped_import = global_import.strip()
for test in generated_tests.generated_tests:
# Skip injection if the source already has the import (LLM may have included it)
if global_import.strip() not in test.generated_original_test_source:
if stripped_import not in test.generated_original_test_source:
test.generated_original_test_source = global_import + test.generated_original_test_source
if global_import.strip() not in test.instrumented_behavior_test_source:
if stripped_import not in test.instrumented_behavior_test_source:
test.instrumented_behavior_test_source = global_import + test.instrumented_behavior_test_source
if global_import.strip() not in test.instrumented_perf_test_source:
if stripped_import not in test.instrumented_perf_test_source:
test.instrumented_perf_test_source = global_import + test.instrumented_perf_test_source
return generated_tests

Expand Down
Loading