ReviewOS

also looking at this

stacks/bun-query-builder

test: run every test file in the package, not just the test directory

#1188
Merged glennmichael123 wants to merge test/ci-runs-every-test-file into main
2 files +95 -1
8 days ago

20 tests CI has never run

The test script handed bun an explicit path:

bun test --max-concurrency=1 packages/bun-query-builder/test

So src/__tests__/type-narrowing.test.ts — 20 tests, 50 assertions — was never executed by CI. It passes, and had passed all along for anyone running bare bun test from the repo root, which discovers the whole tree. CI's narrower path did not, and nothing said so: the run reported 216 files and a green tick, and 216 looks no different from 217 unless you already suspect the number.

Proved by mutation, not arithmetic

Broke one assertion in that file and ran both paths:

pathresult
packages/bun-query-builder (new)1 fail, 23 tests across 217 files
packages/bun-query-builder/test (old)0 fail, 22 tests across 216 files

CI, as configured, could not have failed on a regression in that file. (Mutation reverted.)

Why widen the path instead of moving the file

The file is in the right place. tsconfig.json includes every source file under a package's src — which is why its types are checked by the typecheck job — and, inverted, excludes everything under a package's test, so the directory holding every other test is not typechecked at all.

The two halves cover opposite sides of the package, which is how a file came to sit in the gap. Moving it into test/ would trade the missing runtime half for a missing type half.

The guard

suite-coverage.test.ts pins the invariant rather than the fix: a test file added anywhere under the package must be somewhere the test script will find it.

  • It reads the path out of package.json rather than hardcoding it — narrowing that path is the regression, and a second copy would be narrowed along with it.
  • Against the unfixed script it fails and names the orphan; against the fixed one it passes.
  • A second case asserts the walk really sees that file, so a broken walk cannot report zero orphans forever.

Verification

Canonical bun run test: 2510 pass, 0 fail, 217 files (215 before, +1 orphan, +1 guard). bun run lint 0 errors, none in the new file. tsc clean.

Independent of #1187 — different files, mergeable in either order. Same theme: a test that silently does not run.

🤖 Generated with Claude Code

2 changed files on the files tab, with 0 review threads.

Sign in to comment on this pull request.