codeflash/tests/languages
mohammed ahmed bf15f44f44 Fix Vitest coverage collection by overriding coverage.reporter
## Problem
When Codeflash runs Vitest tests, coverage files are not collected even
though tests run successfully. This affects 14 out of ~20 optimization
runs, resulting in 0% coverage reported.

Root cause: The generated `codeflash.vitest.config.mjs` only overrides
`include`, `pool`, and `setupFiles`, but does NOT override coverage
settings. When the project's vitest.config.ts has custom coverage
settings (e.g., `reporter: ["text", "lcov"]`), Vitest's `mergeConfig()`
doesn't properly handle the nested coverage object merge with command-line
flags like `--coverage.reporter=json`, resulting in coverage files not
being written to the expected location.

## Solution
Explicitly override `coverage.reporter` to `['json']` in the generated
codeflash.vitest.config.mjs file. This ensures consistent behavior
regardless of Vitest version or project configuration.

## Testing
Added comprehensive unit tests in test_vitest_coverage_config.py that:
1. Verify coverage overrides are present in generated config
2. Test with and without existing project coverage settings
3. Confirm generated config includes expected coverage.reporter

All tests pass ✓

## References
- Trace IDs affected: 11f707d6, 69b271f5, and 12 others
- Related to iteration 2 investigation in fix_history.log

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-04-03 21:39:45 +00:00
..
javascript Fix Vitest coverage collection by overriding coverage.reporter 2026-04-03 21:39:45 +00:00
test_coverage_exclusion_message.py Fix AttributeError: use file_path not source_file_path 2026-04-02 18:51:38 +00:00