**Every test in this repo MUST pass `bun test` in one process, in one go - no isolation flags, no retries, no special ordering.** That is the gate. A test that needs `--only`, its own process, or a specific run order to pass is **BROKEN**. Fix the test; do not pamper it.
- "wait long enough for X to happen" - "enough" is a guess; CI machines are slower or faster than your laptop and the test WILL fail on someone else's box
When code under test emits an event, fires a callback, or resolves a promise:
1.**Register the listener / construct the awaitable BEFORE you trigger the action.** Reverse order = lost event = flake.
2.**Race against an explicit timeout.** On timeout, **fail with a useful message** (`"waited 5s for event 'X', never fired"`). NEVER silently retry, NEVER fall through.
3. The timeout is a **circuit breaker**, not a synchronization primitive. If the assertion logic depends on the timeout firing first, the test is wrong.
## NO ISOLATION CRUTCHES
Tests must work under arbitrary parallel ordering in a single `bun test` run, **no matter how many mocks are involved.**
- Running a test in its own process to "fix" a state leak. `script/run-ci-tests.ts` already auto-isolates files that use `mock.module()` - DO NOT add to that list to cover up a real cross-test bug
- Reordering `describe` / `it` blocks to mask cross-test contamination
- Relying on test A running before test B
Cross-test contamination = **state leak**. Find the leak. Reset in `beforeEach`, add the reset to `test-setup.ts` if it is shared, or mock at the module boundary (`mock.module`) instead of mutating globals other tests will read.
The wording changes next sprint, the test fails, and the next engineer edits the assertion to match the new text without understanding what the test was guarding. **The test guarded nothing.**