Fix Vitest workspace detection and setupFiles override#1987
Fix Vitest workspace detection and setupFiles override#1987mohammedahmed18 wants to merge 1 commit intomainfrom
Conversation
Two related bugs fixed: 1. **Workspace Detection Bug**: _is_vitest_workspace() was doing a simple substring search for "workspace" in config files, matching it even in comments. This caused projects to be incorrectly identified as using workspace configuration, preventing custom config creation. 2. **Missing setupFiles Override**: When custom config was created, it only overrode `include` and `pool` but not `setupFiles`. This left relative setupFiles paths from original config active, causing resolution issues in nested directories. **Fixes Applied**: - vitest_runner.py:172-191 - Improved workspace detection to use regex pattern matching for actual workspace config patterns (defineWorkspace(, workspace: [) instead of simple substring search. Now ignores "workspace" in comments. - vitest_runner.py:235-242 - Added setupFiles: [] override in custom config to disable setup files for Codeflash-generated tests. This prevents relative path resolution issues and is safe since generated tests are self-contained. **Testing**: Created test_vitest_setupfiles_fix.py with 2 test cases. **Trace ID**: 161e21be-9306-4a4d-a9dc-978f65a1af7a Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
Claude finished @mohammedahmed18's task in 5m 46s —— View job PR Review Summary
Prek ChecksFixed and pushed 3 issues:
Prek now passes cleanly. Code ReviewThe two logic changes are correct and address the root causes: Workspace detection ( setupFiles override ( No bugs, security issues, or breaking changes found. Duplicate DetectionNo duplicates detected — Last updated: 2026-04-03T21:00:00Z |
|
duplicated |
Summary
Fixes two related bugs in Vitest test runner that caused test failures when projects had workspace-like comments or setupFiles configured.
Bugs Fixed
1. Workspace Detection Bug
_is_vitest_workspace()was doing a simple substring search for "workspace" in config files, matching it even in comments. This caused the openclaw project to be incorrectly identified as using workspace configuration, preventing custom config creation.2. Missing setupFiles Override
When custom config was created, it only overrode
includeandpoolbut notsetupFiles. This left relative setupFiles paths from the original config active, causing resolution issues in nested directories.Changes
vitest_runner.py:172-191
defineWorkspace(,workspace: [) instead of simple substring searchvitest_runner.py:235-242
setupFiles: []override in custom config to disable setup files for Codeflash-generated testsTesting
Created
/opt/codeflash/tests/languages/javascript/test_vitest_setupfiles_fix.pywith 2 test cases that verify:Verification
After fix, the setup.ts error is gone. Tests now encounter a different error (module resolution), proving the setupFiles fix works.
Trace ID
161e21be-9306-4a4d-a9dc-978f65a1af7a
Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com