test(repo): prefer test.each over for/forEach loops in tests#303
Conversation
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughThis PR replaces manual in-test loops with parameterized Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Convert hand-rolled parameterization loops in test bodies (and around test definitions) to test.each so each case becomes its own reported test with pinpointed failure attribution. Document the convention in .claude/rules/testing.md, including Bun's readonly-array spread gotcha and the runtime-data exception.
04baa3f to
e89546e
Compare
Summary
.claude/rules/testing.md: tests should usetest.each(orit.each/describe.each) instead offor/forEachloops inside a single test, so each case becomes its own reported test with pinpointed failure attribution.test.each. Test count grows from 1450 → 1528 (eachtest.eachrow becomes a separately reported case); zero new failures.test.eachreadonly-array gotcha: spreadas const/readonlyarrays to a mutable copy (test.each([...MODES])) so Bun's literal-inferring overload preserves the union in the callback type.Files refactored
cli-program.test.tsforloops → cross-producttest.each(AGENT_DIR_CASES)+test.each([...EXTRA_REL_PATHS])bootstrap.test.tstest.each(REGISTRY_PM_PAIRS)skill/install.test.tstest.each(VERSION_FILE_CASES)lib/listage.test.tsfor (active = 0; <20; ...)property tests → cross-producttest.each(SCROLL_CASES)lib/users.test.tstest.eachintegration/onboard.test.tsfor (mode) { test.each(frameworks) }→ flattenedtest.each(ONBOARD_CASES)with explicitFrameworkCaseinterfaceintegration/switch-apps.test.tsfor (mode of MODES)→test.each([...MODES])Loops left alone (per the documented exceptions)
http.requestscollected during the test,filesmap captured from a callback).pkcerejection-sampling distribution).Test plan
bun run typecheck— passesbun run lint— 0 warnings, 0 errorsbun run format:check— cleanbun run teston the 7 touched files — 217/217 passbun run test— 1406 pass, 122 fail; the 122 failures are preexisting onmainand unrelated to this diff (verified viagit stashbaseline)bun run test:e2e:op— not run locally; CI will exercise