--- description: "Testing conventions and runner guidelines using bun:test" globs: "src/**/*.test.ts" trigger: "manual" --- # Testing Guidelines When writing or maintaining unit and integration tests: 1. **Test Runner & Colocation**: - Use `bun:test` (`describe`, `test`, `expect`). - Colocate tests directly alongside implementation code as `name.test.ts` (e.g. `src/core/config/loader.test.ts`). 2. **State & Environment Hygiene**: - Any test modifying `process.env` or `process.chdir()` MUST restore them in `afterEach()`. - Never leave temporary files or mutation leaks between test cases. 3. **Execution**: - Run tests using `bun test`. - Ensure type check passes with `bun run check`.