fix(js): pass project Jest config for TypeScript transformation#1244
Merged
fix(js): pass project Jest config for TypeScript transformation#1244
Conversation
When running generated tests on TypeScript projects, Jest was failing with "unexpected token" errors because it wasn't configured to transform TypeScript files. The tests were being run without the project's Jest config file. This fix: - Adds `_find_jest_config()` function to locate Jest config files - Searches project root and parent directories (for monorepo support) - Passes `--config` flag to Jest in all test runner functions - Stops search at git root or monorepo root (package.json with workspaces) Tested against next.js (monorepo) where jest.config.js is at repo root but packages are in nested directories. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
|
Can add test for finding the jest config with a tmp project. |
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
_find_jest_config()function to locate Jest config in project and parent directoriesProblem
When running codeflash on TypeScript projects like next.js, generated tests were failing with:
Root Cause
The Jest test runner functions (
run_jest_behavioral_tests,run_jest_benchmarking_tests,run_jest_line_profile_tests) were not passing a--configflag to Jest, causing it to run without the project's TypeScript transformation configuration.Solution
Added
_find_jest_config()function that:Updated all three Jest runner functions to pass
--config={path}when a config is foundTest plan
🤖 Generated with Claude Code