Skip to content

Commit e07fd1d

Browse files
fix tests
1 parent e9b7154 commit e07fd1d

3 files changed

Lines changed: 11 additions & 14 deletions

File tree

codeflash/languages/javascript/test_runner.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,9 @@ def _create_codeflash_jest_config(
336336
def _get_jest_config_for_project(project_root: Path) -> Path | None:
337337
"""Get the appropriate Jest config for the project.
338338
339-
Creates a codeflash-compatible Jest config that handles:
340-
- ESM packages in node_modules that need transformation
341-
- TypeScript files with proper ts-jest configuration
342-
- bundler moduleResolution compatibility
339+
If the project uses bundler moduleResolution, creates and returns a
340+
codeflash-compatible Jest config. Otherwise, returns the project's
341+
existing Jest config.
343342
344343
Args:
345344
project_root: Root of the project.
@@ -356,12 +355,10 @@ def _get_jest_config_for_project(project_root: Path) -> Path | None:
356355
logger.info("Detected bundler moduleResolution - creating compatible config")
357356
# Create codeflash-compatible tsconfig
358357
_create_codeflash_tsconfig(project_root)
359-
360-
# Always create a codeflash Jest config to handle ESM packages properly
361-
# Many modern NPM packages are ESM-only and need transformation
362-
codeflash_jest_config = _create_codeflash_jest_config(project_root, original_jest_config, for_esm=True)
363-
if codeflash_jest_config:
364-
return codeflash_jest_config
358+
# Create codeflash Jest config that uses it
359+
codeflash_jest_config = _create_codeflash_jest_config(project_root, original_jest_config)
360+
if codeflash_jest_config:
361+
return codeflash_jest_config
365362

366363
return original_jest_config
367364

tests/test_languages/fixtures/js_cjs/calculator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
const { add, multiply, factorial } = require('./math_utils');
77
const { formatNumber, validateInput } = require('./helpers/format');
88

9-
export class Calculator {
9+
class Calculator {
1010
constructor(precision = 2) {
1111
this.precision = precision;
1212
this.history = [];

tests/test_languages/test_javascript_test_runner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -668,10 +668,10 @@ def test_create_codeflash_jest_config(self):
668668
assert result_path.exists()
669669
assert result_path.name == "jest.codeflash.config.js"
670670

671-
# Verify it contains the tsconfig reference
671+
# Verify it contains ESM package transformation patterns
672672
content = result_path.read_text()
673-
assert "tsconfig.codeflash.json" in content
674-
assert "ts-jest" in content
673+
assert "transformIgnorePatterns" in content
674+
assert "node_modules" in content
675675

676676
def test_get_jest_config_for_project_with_bundler(self):
677677
"""Test that bundler projects get codeflash Jest config."""

0 commit comments

Comments
 (0)