77 * entry never runs, in CI or locally, and nothing reports it. `scripts/check-migrations-safety.test.ts`
88 * sat unreferenced and green for exactly that reason. `scripts/vitest.config.ts` now collects
99 * the directory by glob, so drift can only come from a file the glob does not match (a test in a
10- * subdirectory, a different suffix) or from the ` test` script no longer chaining `test:scripts` .
11- * This guard checks both by asking Vitest which files it would run.
10+ * subdirectory, a different suffix) or from the test commands no longer running that config .
11+ * This guard checks the command contract and asks Vitest which files it would run.
1212 *
1313 * `run-audits.ts` derives its own list from the `check:*` namespace precisely so a new audit is
1414 * picked up by default, so this guard registers itself simply by being named `check:*` — it cannot
@@ -20,6 +20,8 @@ import { localBin } from './local-bin'
2020
2121const ROOT = path . resolve ( import . meta. dir , '..' )
2222const SUB_SCRIPT_PATTERN = / b u n r u n ( [ \w : - ] + ) / g
23+ const SCRIPTS_TEST_CONFIG = 'scripts/vitest.config.ts'
24+ const SCRIPTS_TEST_COMMAND = `vitest run --config ${ SCRIPTS_TEST_CONFIG } `
2325
2426const manifest = await Bun . file ( path . join ( ROOT , 'package.json' ) ) . json ( )
2527const commands = manifest . scripts as Record < string , string >
@@ -42,8 +44,14 @@ if (!reachableScripts('test').has('test:scripts')) {
4244 process . exit ( 1 )
4345}
4446
47+ // Keep collection tied to the actual runner; filters or another config can silently skip tests.
48+ if ( commands [ 'test:scripts' ] ?. trim ( ) !== SCRIPTS_TEST_COMMAND ) {
49+ console . error ( `test:scripts must run the complete scripts Vitest config: ${ SCRIPTS_TEST_COMMAND } ` )
50+ process . exit ( 1 )
51+ }
52+
4553const listed = Bun . spawnSync (
46- [ localBin ( 'vitest' ) , 'list' , '--json' , '--filesOnly' , '--config' , 'scripts/vitest.config.ts' ] ,
54+ [ localBin ( 'vitest' ) , 'list' , '--json' , '--filesOnly' , '--config' , SCRIPTS_TEST_CONFIG ] ,
4755 {
4856 cwd : ROOT ,
4957 }
0 commit comments