# Testing ## A pipe hides the exit code of the command you are checking **What happened.** On 2026-11-01 Phase 0 ran `pnpm -s lint 2>&1 | tail -30; echo "exit=$?"`. It printed one ESLint error and then `exit=0`. The `0` belonged to `tail`, not to ESLint. **Why it bit.** Anything piped through `tail`, `grep` or `head` reports the last command's status. A gate read that way can be red and look green. This is the same lie as `pnpm test` exiting 0 having run nothing, one layer further out. **How to apply it.** When the exit code matters, redirect to a file and read `$?` before filtering: `cmd > log 2>&1; ec=$?; grep … log; echo "exit=$ec"`. You can also use `${PIPESTATUS[0]}` in bash. Never quote `exit=0` from the far end of a pipe. ## `setOffline` tests the harness, not the service worker *(imported from Ludus)* **What happened.** In Ludus, `context.setOffline(true)` and `route().abort()` both failed the navigation before the service worker was consulted. So an "offline" test passed or failed for reasons that had nothing to do with the cache. **Why it bit.** Both mechanisms act at the browser's network layer, which sits in front of service-worker dispatch. **How to apply it.** Prove offline by **closing the server**: start it, wait for `navigator.serviceWorker.controller` and for the precache, call `server.close()`, then navigate. `e2e/offline.spec.ts` does this, and also fetches from Node to prove the server really is gone. Not re-measured in Rosea. Strike the "imported" mark once someone has. ## Put the bug back before you trust the test **What happened.** Phase 0 put 13 bugs back one at a time: `clientsClaim: false`, no `navigateFallback`, manifest scope `/`, an inline script, a Google Fonts link, a `localStorage` write, a hard-coded heading, a UTC `localDay`, a disabled length cap (checked twice), a lost word boundary, a removed Domi rule, and both git hooks. Every one was caught. The results are recorded in `.agents/reviews/feature-phase0-workspace.md`. **Why it bit.** It didn't, this time. But a guard that has only ever been seen not firing has not been tested. Without the run, a review can only say "I believe". **How to apply it.** For every guard a branch adds, apply the inverse change, run the one suite that should catch it, record CAUGHT or MISSED, and restore the file with `git checkout`. Commit first, so the restore is exact.