-
Notifications
You must be signed in to change notification settings - Fork 178
Description
Problem
When scanning a TypeScript project with 15 test files (117 tests) in __tests__ subdirectories, the test coverage detector reports 0% test health and "no test files found" for every production module.
Reproduction
Project: /Users/peteromalley/Documents/personal_website
Test files are correctly classified in the test zone (verified with desloppify zone show):
src/__tests__/App.test.tsx
src/components/__tests__/Header.test.tsx
src/lib/__tests__/markdown.test.ts
... (16 test files total)
All tests pass: npx vitest run → 15 files, 117 tests passed.
But desloppify scan reports:
Test health: 0.0%
test coverage: 45 issues (untested module)
Investigation
The matching functions work correctly in isolation:
from desloppify.languages.typescript.test_coverage import map_test_to_source, resolve_import_spec
prod = {'src/components/Header.tsx'}
map_test_to_source('src/components/__tests__/Header.test.tsx', prod)
# Returns: 'src/components/Header.tsx' ✓
resolve_import_spec('../Header', 'src/components/__tests__/Header.test.tsx', prod)
# Returns: 'src/components/Header.tsx' ✓naming_based_mapping() also works:
naming_based_mapping(test_files, prod_files, 'typescript')
# Returns all 9 production files matched ✓The bug appears to be upstream — either the test files aren't being passed to the matching functions during a real scan, or the import graph construction isn't including the test files, causing the early if not test_files check to short-circuit at detector.py:52.
Expected behavior
Test coverage detector should recognize __tests__ subdirectory test files and match them to their production counterparts, reporting accurate test coverage.
Environment
- desloppify from local source at
/Users/peteromalley/Documents/desloppify - TypeScript project with vitest, React, Express SSR
- macOS Darwin 24.4.0