fix: Jest XML path resolution and runner support for monorepos#1315
Merged
mohammedahmed18 merged 6 commits intomainfrom Feb 3, 2026
Merged
fix: Jest XML path resolution and runner support for monorepos#1315mohammedahmed18 merged 6 commits intomainfrom
mohammedahmed18 merged 6 commits intomainfrom
Conversation
When running in monorepos, test files may be cleaned up before results are parsed. This fix: 1. Uses .resolve() to properly handle relative paths with .. components 2. Infers test type from filename pattern when files don't exist 3. Removes requirement for test files to exist when parsing results Tested on Budibase monorepo - behavioral tests now parse correctly. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added resolveJestRunner() function that walks up the directory tree to find jest-runner in workspace root node_modules. This fixes the "jest-runner requires jest-runner to be installed" error when running in monorepo packages. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Saga4
reviewed
Feb 3, 2026
| * Walks up the directory tree looking for node_modules/jest-runner. | ||
| */ | ||
| function resolveJestRunner() { | ||
| // Try standard resolution first (works in simple projects) |
Contributor
There was a problem hiding this comment.
Can use _find_js_project_root or _find_project_root function too to figure out the project root.
Saga4
requested changes
Feb 3, 2026
Contributor
Saga4
left a comment
There was a problem hiding this comment.
We can add unit tests for figuring out root path.
…lution Instead of duplicating monorepo detection logic in JavaScript, leverage the existing Python _find_node_project_root and add _find_monorepo_root functions. Pass the detected monorepo root via CODEFLASH_MONOREPO_ROOT environment variable to the loop-runner. This approach: - Reuses existing Python project detection logic - Provides a reliable monorepo root hint to JavaScript - Maintains fallback directory traversal for edge cases Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
a815e54 to
7f954d1
Compare
jest-runner v30+ uses webpack bundling and doesn't export runTest separately. This commit adds version detection and implements external looping for v30+ while maintaining loop-runner support for v29.x. Changes: - Added _get_jest_runner_version() to detect installed jest-runner version - Modified run_jest_benchmarking_tests() to check version and choose strategy - For v29: Use loop-runner (in-process batching) - For v30+: Use external looping (run Jest multiple times) - External looping respects min_loops, max_loops, and target_duration_ms Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This reverts commit cad865c.
Saga4
approved these changes
Feb 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes two critical issues preventing CodeFlash from working in monorepo environments like Budibase when running from the workspace root.
Changes
..components in monoreposProblem 1: Test Path Resolution
When running CodeFlash from a monorepo root (e.g.,
~/budibase), Jest XML reports contain relative paths like:These paths couldn't be resolved because:
base_diris/home/user/budibase/tests../../tests/...needs proper resolution to find the actual fileExample Failure
Problem 2: Jest Runner Resolution
When running in a monorepo package (e.g.,
packages/backend-core), jest-runner is installed at the workspace root:The loop-runner would fail with:
Solution
1. Improved Path Resolution
2. Monorepo-Aware Jest Runner Resolution
3. Flexible Test Type Inference
Testing
Before (Failure)
After (Success)
Test Results on Budibase Monorepo
validEmailpackages/backend-core/src/utils/stringUtils.tspunctuateListpackages/shared-core/src/helpers/lists.tsisDevWorkspaceIDpackages/backend-core/src/docIds/conversions.tsImpact
✅ Fixes
✅ Maintains Backward Compatibility
require.resolve()tried first for simple projects✅ Tested On
Files Changed
codeflash/verification/parse_test_output.py- Path resolution with.resolve()and flexible test type inferencepackages/codeflash/runtime/loop-runner.js- Monorepo-aware jest-runner resolution🤖 Generated with Claude Code