Skip to content

Commit b2ba0fd

Browse files
misrasaurabh1claude
andcommitted
fix: add warning log when Jest fails without XML output
When Jest fails early (e.g., due to import errors) and doesn't produce XML output, the error was only logged at DEBUG level, making it hard to diagnose issues. This change adds WARNING level logging that includes Jest's stdout and stderr when: 1. Jest exits with non-zero return code 2. No XML output file is created This helps debug common issues like: - Invalid import paths in generated tests - Module resolution failures - TypeScript compilation errors Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 7cde435 commit b2ba0fd

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

codeflash/languages/javascript/test_runner.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,14 @@ def run_jest_behavioral_tests(
313313
args=result.args, returncode=result.returncode, stdout=result.stdout + "\n" + result.stderr, stderr=""
314314
)
315315
logger.debug(f"Jest result: returncode={result.returncode}")
316+
# Log Jest output at WARNING level if tests fail and no XML output will be created
317+
# This helps debug issues like import errors that cause Jest to fail early
318+
if result.returncode != 0 and not result_file_path.exists():
319+
logger.warning(
320+
f"Jest failed with returncode={result.returncode} and no XML output created.\n"
321+
f"Jest stdout: {result.stdout[:2000] if result.stdout else '(empty)'}\n"
322+
f"Jest stderr: {result.stderr[:500] if result.stderr else '(empty)'}"
323+
)
316324
except subprocess.TimeoutExpired:
317325
logger.warning(f"Jest tests timed out after {timeout}s")
318326
result = subprocess.CompletedProcess(args=jest_cmd, returncode=-1, stdout="", stderr="Test execution timed out")

0 commit comments

Comments
 (0)