making name cosnistency in config for test-framework

This commit is contained in:
Sarthak Agarwal 2026-02-02 15:06:17 +05:30
parent 417eed4108
commit 92faba2546
5 changed files with 24 additions and 24 deletions

View file

@ -232,8 +232,8 @@ def process_pyproject_config(args: Namespace) -> Namespace:
is_js_ts_project = pyproject_config.get("language") in ("javascript", "typescript")
# Set the test framework singleton for JS/TS projects
if is_js_ts_project and pyproject_config.get("test_runner"):
set_current_test_framework(pyproject_config["test_runner"])
if is_js_ts_project and pyproject_config.get("test_framework"):
set_current_test_framework(pyproject_config["test_framework"])
if args.tests_root is None:
if is_js_ts_project:

View file

@ -260,11 +260,11 @@ def parse_package_json_config(package_json_path: Path) -> tuple[dict[str, Any],
# Check for explicit test framework override, otherwise auto-detect
# Uses "test-framework" to match Python's pyproject.toml convention
if codeflash_config.get("test-framework"):
config["test_runner"] = codeflash_config["test-framework"]
config["test_framework"] = codeflash_config["test-framework"]
else:
config["test_runner"] = detect_test_runner(project_root, package_data)
config["test_framework"] = detect_test_runner(project_root, package_data)
# Keep pytest_cmd for backwards compatibility with existing code
config["pytest_cmd"] = config["test_runner"]
config["pytest_cmd"] = config["test_framework"]
# Auto-detect formatter (with optional override from config)
if "formatterCmds" in codeflash_config:

View file

@ -29,7 +29,7 @@ class CodeflashConfig(BaseModel):
tests_root: str | None = Field(default=None, description="Root directory containing tests")
# Tooling settings (auto-detected, can be overridden)
test_runner: str | None = Field(default=None, description="Test runner: pytest, jest, vitest, mocha")
test_framework: str | None = Field(default=None, description="Test framework: pytest, jest, vitest, mocha")
formatter_cmds: list[str] = Field(default_factory=list, description="Formatter commands")
# Optional settings
@ -145,7 +145,7 @@ class CodeflashConfig(BaseModel):
if detected.module_root != detected.project_root
else ".",
tests_root=str(detected.tests_root.relative_to(detected.project_root)) if detected.tests_root else None,
test_runner=detected.test_runner,
test_framework=detected.test_runner,
formatter_cmds=detected.formatter_cmds,
ignore_paths=[
str(p.relative_to(detected.project_root)) for p in detected.ignore_paths if p != detected.project_root

View file

@ -488,7 +488,7 @@ class TestParsePackageJsonConfig:
assert result is not None
config, path = result
assert config["language"] == "javascript"
assert config["test_runner"] == "jest"
assert config["test_framework"] == "jest"
assert config["pytest_cmd"] == "jest"
assert path == package_json
@ -728,7 +728,7 @@ class TestRealWorldPackageJsonExamples:
config, _ = result
assert config["language"] == "typescript"
assert config["module_root"] == str((tmp_path / "src").resolve())
assert config["test_runner"] == "jest"
assert config["test_framework"] == "jest"
assert config["formatter_cmds"] == ["npx prettier --write $file"]
def test_vite_react_project(self, tmp_path: Path) -> None:
@ -752,7 +752,7 @@ class TestRealWorldPackageJsonExamples:
assert result is not None
config, _ = result
assert config["language"] == "typescript"
assert config["test_runner"] == "vitest"
assert config["test_framework"] == "vitest"
assert config["formatter_cmds"] == ["npx eslint --fix $file"]
def test_library_with_exports(self, tmp_path: Path) -> None:
@ -812,7 +812,7 @@ class TestRealWorldPackageJsonExamples:
assert result is not None
config, _ = result
assert config["module_root"] == str((tmp_path / "lib").resolve())
assert config["test_runner"] == "mocha"
assert config["test_framework"] == "mocha"
def test_minimal_project(self, tmp_path: Path) -> None:
"""Should handle minimal package.json."""
@ -825,7 +825,7 @@ class TestRealWorldPackageJsonExamples:
config, _ = result
assert config["language"] == "javascript"
assert config["module_root"] == str(tmp_path.resolve())
assert config["test_runner"] == "jest"
assert config["test_framework"] == "jest"
assert config["formatter_cmds"] == []
def test_existing_codeflash_config_with_overrides(self, tmp_path: Path) -> None:
@ -877,7 +877,7 @@ class TestTestFrameworkConfigOverride:
assert result is not None
config, _ = result
assert config["test_runner"] == "jest"
assert config["test_framework"] == "jest"
assert config["pytest_cmd"] == "jest"
def test_explicit_vitest_config_with_jest_in_deps(self, tmp_path: Path) -> None:
@ -897,7 +897,7 @@ class TestTestFrameworkConfigOverride:
assert result is not None
config, _ = result
assert config["test_runner"] == "vitest"
assert config["test_framework"] == "vitest"
def test_explicit_mocha_overrides_vitest_and_jest(self, tmp_path: Path) -> None:
"""Should use explicit mocha config even when vitest and jest are in devDependencies."""
@ -916,7 +916,7 @@ class TestTestFrameworkConfigOverride:
assert result is not None
config, _ = result
assert config["test_runner"] == "mocha"
assert config["test_framework"] == "mocha"
def test_auto_detection_when_no_explicit_config(self, tmp_path: Path) -> None:
"""Should auto-detect test framework when no explicit config is provided."""
@ -935,7 +935,7 @@ class TestTestFrameworkConfigOverride:
assert result is not None
config, _ = result
assert config["test_runner"] == "vitest"
assert config["test_framework"] == "vitest"
def test_empty_test_framework_falls_back_to_auto_detection(self, tmp_path: Path) -> None:
"""Should auto-detect when test-framework is empty string."""
@ -954,7 +954,7 @@ class TestTestFrameworkConfigOverride:
assert result is not None
config, _ = result
assert config["test_runner"] == "jest"
assert config["test_framework"] == "jest"
def test_custom_test_framework_value(self, tmp_path: Path) -> None:
"""Should accept custom test framework values not in the standard list."""
@ -973,10 +973,10 @@ class TestTestFrameworkConfigOverride:
assert result is not None
config, _ = result
assert config["test_runner"] == "ava"
assert config["test_framework"] == "ava"
def test_pytest_cmd_matches_test_framework_with_override(self, tmp_path: Path) -> None:
"""Should set pytest_cmd to match test_runner when using explicit config."""
"""Should set pytest_cmd to match test_framework when using explicit config."""
package_json = tmp_path / "package.json"
package_json.write_text(
json.dumps(
@ -992,6 +992,6 @@ class TestTestFrameworkConfigOverride:
assert result is not None
config, _ = result
assert config["test_runner"] == "jest"
assert config["test_framework"] == "jest"
assert config["pytest_cmd"] == "jest"
assert config["test_runner"] == config["pytest_cmd"]
assert config["test_framework"] == config["pytest_cmd"]

View file

@ -35,7 +35,7 @@ class TestCodeflashConfig:
language="javascript",
module_root="src",
tests_root="tests",
test_runner="jest",
test_framework="jest",
formatter_cmds=["npx prettier --write $file"],
ignore_paths=["dist", "node_modules"],
benchmarks_root="benchmarks",
@ -46,7 +46,7 @@ class TestCodeflashConfig:
assert config.language == "javascript"
assert config.module_root == "src"
assert config.tests_root == "tests"
assert config.test_runner == "jest"
assert config.test_framework == "jest"
assert config.formatter_cmds == ["npx prettier --write $file"]
assert config.ignore_paths == ["dist", "node_modules"]
assert config.git_remote == "upstream"
@ -128,7 +128,7 @@ class TestCodeflashConfig:
config = CodeflashConfig.from_detected_project(detected)
assert config.language == detected.language
assert config.test_runner == detected.test_runner
assert config.test_framework == detected.test_runner
def test_from_pyproject_dict(self):
"""Should create config from pyproject.toml dict."""