Fix Vitest coverage collection by explicitly enabling coverage in config and CLI#1989
Fix Vitest coverage collection by explicitly enabling coverage in config and CLI#1989mohammedahmed18 wants to merge 2 commits intomainfrom
Conversation
…fig and CLI ## Issue Vitest coverage was not being collected (0% coverage) despite: - Coverage provider (@vitest/coverage-v8) being installed - All coverage flags being passed (--coverage, --coverage.reporter=json, etc.) - Coverage directory never created Affected 15 out of 20 optimization runs. Trace IDs: 07be59c3-e53c-4350-b874-9d1fee5238d1 and 14 others ## Root Cause Vitest 4's mergeConfig() doesn't properly enable coverage when project configs have complex coverage settings. The project config had: - coverage.provider: "v8" - coverage.reporter: ["text", "lcov"] - coverage.include: ["./src/**/*.ts"] Without explicit `enabled: true` in the config override, Vitest would not collect coverage even with --coverage flag on command line. ## Fix 1. Added `coverage.enabled: true` to generated config override (both mergeConfig and standalone cases) 2. Re-added `--coverage.enabled=true` command-line flag (was previously removed as "redundant") 3. Added broad `coverage.include` pattern to override restrictive project patterns Setting enabled: true in BOTH config and CLI ensures coverage is reliably collected regardless of how project configs are structured. ## Testing - Added test_vitest_coverage_enabled.py with 2 test cases - All existing vitest tests pass (46 tests) - uv run prek passes with no linting/type errors Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
Claude finished @mohammedahmed18's task in 2m 8s —— View job PR Review Summary
Prek ChecksAuto-fixed 2 Code ReviewBug:
Testing convention violations in Per
The Bundled unrelated changes This PR bundles 3 fixes with no separation:
The last two are meaningful standalone fixes that deserve separate description/tracking. Not a blocking issue, but worth noting for traceability.
Lines 272/294: The Duplicate DetectionNo duplicates detected. All changes are confined to Last updated: 2026-04-03T22:34 UTC |
Co-authored-by: mohammedahmed18 <undefined@users.noreply.github.com>
|
deuplicated |
Issue
Vitest coverage was not being collected (0% coverage) despite proper configuration. 15 out of 20 optimization runs showed this issue.
Trace IDs:
07be59c3-e53c-4350-b874-9d1fee5238d1and 14 othersSymptoms:
@vitest/coverage-v8installed--coverage,--coverage.reporter=json,--coverage.reportsDirectoryRoot Cause
Vitest 4's
mergeConfig()doesn't properly enable coverage when project configs have complex coverage settings. The project config had:Without explicit
enabled: truein the config override, Vitest would not collect coverage even with--coverageflag on command line.Fix
File:
codeflash/languages/javascript/vitest_runner.pycoverage.enabled: trueto generatedcodeflash.vitest.config.mjs--coverage.enabled=trueflag (was removed as "redundant")coverage.includepattern to override restrictive project patternsSetting
enabled: truein BOTH config and CLI ensures coverage is reliably collected regardless of project configuration structure.Testing
tests/languages/javascript/test_vitest_coverage_enabled.pywith 2 test casesuv run prekpasses with no linting/type errorsImpact
Fixes coverage collection for 15/20 failed optimization runs in openclaw project.