How We Finally Solved Test Discovery
How We Finally Solved Test Discovery Yesterday I wrote about why test file discovery is still unsolved. Three approaches (stem matching, content grepping, hybrid), each failing differently. The hyb...

Source: DEV Community
How We Finally Solved Test Discovery Yesterday I wrote about why test file discovery is still unsolved. Three approaches (stem matching, content grepping, hybrid), each failing differently. The hybrid worked best but had a broken ranking function - flat scoring that gave src/ the same weight as src/pages/checkout/. Today it's solved. The Problem With Flat Scoring The March 30 post ended with this bug: +30 points for any shared parent directory. One shared path component got the same bonus as three. With 3 synthetic inputs, other factors dominated. With 29 real file paths, unrelated test files ranked above relevant ones. The fix wasn't tweaking the constant. It was replacing the scoring model entirely. Five Tiers, Not Points Instead of adding up weighted scores, we rank by structural relationship. Higher tiers always win over lower ones, regardless of path depth or name similarity. Tier 1 - Colocated tests. Same directory, same stem with a test suffix. Button.tsx and Button.test.tsx sid