fix: resolve jest-runner from project's node_modules for Jest 30 compatibility#1497
fix: resolve jest-runner from project's node_modules for Jest 30 compatibility#1497mohammedahmed18 merged 11 commits intomainfrom
Conversation
…atibility The loop-runner was loading jest-runner from codeflash's node_modules (v29) instead of the project's (v30), causing "runtime.enterTestCode is not a function" errors. This fix: - Adds recursive search to find jest-runner in any node_modules structure - Works with npm, yarn, and pnpm (including non-hoisted deps) - Prefers higher versions when multiple are found - Removes internal looping in capturePerf when using external loop-runner - Creates fresh TestRunner per batch to avoid Jest 30 state corruption Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
| } | ||
| } | ||
|
|
||
| const totalTimeMs = Date.now() - startTime; |
There was a problem hiding this comment.
Still present: totalTimeMs (line 367) is computed but never used. hasFailure (line 330) is declared but never read - the return value batchResult.hasFailure from _runAllTestsOnce is also never consumed in runTests.
| function isValidJestRunnerPath(jestRunnerPath) { | ||
| if (!fs.existsSync(jestRunnerPath)) { | ||
| return false; | ||
| function findJestRunnerRecursive(nodeModulesPath, maxDepth = 5) { |
There was a problem hiding this comment.
Still present: createRequire is imported at line 33 but never used after the refactoring removed the internalRequire approach.
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
…codeflash into fix/jest30-pnpm-resolution
| const shouldRecurse = entry.name === 'node_modules' || | ||
| entry.name.startsWith('@') || | ||
| const shouldRecurse = entry.name === 'node_modules' || | ||
| entry.name.startsWith('@') || | ||
| entry.name === '.pnpm' || entry.name === '.yarn' || | ||
| entry.name.startsWith('jest-runner@'); | ||
| entry.name.startsWith('jest-runner@'); |
There was a problem hiding this comment.
✅ Fixed in latest commit
PR Review SummaryPrek Checks✅ All checks pass — Mypy
Code Review (Re-review)Existing comments still open:
No new critical issues found in the latest changes ( Test Coverage
Analysis: The Python changes in this PR are minimal — removing a Test suite: 2374 passed, 8 failed (all in Last updated: 2026-02-17T13:36Z |
| if result.returncode != 0: | ||
| logger.info(f"Jest benchmarking failed with return code {result.returncode}") | ||
| logger.info(f"Jest benchmarking stdout: {result.stdout}") | ||
| logger.info(f"Jest benchmarking stderr: {result.stderr}") |
There was a problem hiding this comment.
Bug: result.stderr will always be "" here because line 1046 creates a new CompletedProcess with stderr="". The original stderr was merged into stdout on line 1043. This log line is misleading — it should either be removed or log the original stderr before it's merged.
| logger.info(f"Jest benchmarking stderr: {result.stderr}") | |
| logger.info(f"Jest benchmarking stderr (merged into stdout): {result.stderr}") |
Or better yet, capture the original stderr before line 1046:
original_stderr = result.stderr
# ... line 1046 ...
logger.info(f"Jest benchmarking stderr: {original_stderr}")Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Saga4
left a comment
There was a problem hiding this comment.
Can add unit tests or fix existing on path resolution and loop index
will add unit tests for the js pacakge |
Summary
TypeError: runtime.enterTestCode is not a functionChanges
jest-runner/package.jsonanywhere in node_modules treeTest plan
🤖 Generated with Claude Code