From eefe543eadded76d76c46ec502def8cdc3948bdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Flor=C3=AAncio?= Date: Fri, 29 May 2026 00:44:39 +0100 Subject: [PATCH] docs: note IS_DEBUG runs under vitest in debug-logs skill (#1137) --- .agents/skills/debug-logs/SKILL.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.agents/skills/debug-logs/SKILL.md b/.agents/skills/debug-logs/SKILL.md index fe012e3eb5..064d6d0a2f 100644 --- a/.agents/skills/debug-logs/SKILL.md +++ b/.agents/skills/debug-logs/SKILL.md @@ -48,6 +48,7 @@ Key properties: - **Register the namespace** in the cheat-sheet docblock at the top of `lib/debug/log.ts`. Future agents triage by reading that list — an unregistered namespace is invisible. - **One log per event**, not per render frame. The factory is no-op in prod but allocates a closure per call in dev — still cheap, but per-render-frame logs spam the console and slow devtools. - **Guard expensive arg computation** with `if (IS_DEBUG) { ... }`. The `debug()` call itself is free, but JS evaluates args first. +- **`IS_DEBUG` is true under vitest** (`NODE_ENV === "test"` ≠ `"production"`), so persistent debug branches *execute in tests*. If a debug line — or a helper it calls (e.g. a `formatXSnapshot`) — reaches into a module that a test `vi.mock`s, that mock must export every symbol the debug path touches, or the log throws `No "" export is defined on the "..." mock` and turns a green suite red. Adding a `debug()` call to a code path covered by a partial-mock test is enough to trigger this. Fix by completing the mock (add the missing export) or by keeping the debug helper's transitive deps minimal. ### ✅ Correct — flat primitives as a single object arg