Skip to content

Commit f89fcc3

Browse files
committed
docs: codify testing constraints and God Node invariants via /learn
1 parent dbb86c3 commit f89fcc3

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ When creating or generating unit test files:
6969

7070
4. **Always run the new tests before marking task items complete.** Execute `npx vitest run <path>` on the newly created test files to confirm they parse and pass before checking off items in `task.md`.
7171

72+
5. **CLI Tool & Script Testing:** When writing tests for CLI scripts (e.g., in `scripts/`), ensure the target script's execution blocks are wrapped in `if (process.env.NODE_ENV !== "test")`. Importing scripts that contain top-level `process.exit()` calls will crash the Vitest runner prematurely.
73+
74+
6. **JSDOM Animation Stubbing:** When writing DOM-based React tests for components that utilize GSAP (`ScrollTrigger`) or `locomotive-scroll`, you must provide extensive global stubs for `IntersectionObserver`, `window.matchMedia`, and GSAP's matchMedia hooks, as JSDOM does not support layout engines.
75+
7276
### 6.11 React Router v8 & Vite 8 Resolution Rules (Addendum)
7377

7478
- **CSP Nonce Hydration Mismatch**: In React 19, Chrome hides the `nonce` attribute on `<link>` tags for security, causing a fatal hydration mismatch if the Virtual DOM expects a value. When rendering React Router's `<Links />` component in the root layout or error boundaries, you **MUST** pass an empty string on the client (e.g., `<Links nonce="" />`) to bypass the mismatch and prevent React from crashing the client-side render tree.

gemini.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,12 @@ When writing or updating unit tests for services/repositories that return `never
381381
2. **Assertions (Success)**: NEVER use `expect(result).resolves.toEqual(...)`. Wait for the result and assert the value via `.isOk()`, `.isErr()`, or by using `_unsafeUnwrap()` *only* in tests: `expect((await service.method())._unsafeUnwrap()).toEqual(mockData)`.
382382
3. **Assertions (Failures)**: NEVER use `await expect(...).rejects.toThrow()`. The function does not throw; it returns an `err()`. You MUST assert failure using `expect((await service.method()).isErr()).toBe(true)`.
383383

384+
### 6.5.3 MemoryStorage "God Node" Invariant
385+
386+
The `tests/integration/server/memory-storage.ts` mock repository is the foundational dependency for over 343+ test files.
387+
- It **MUST** remain perfectly synchronized with the `IStorage` interface in `server/repositories/storage-interfaces.ts`.
388+
- Any refactoring to the storage interface requires an immediate mirroring update to the `MemoryStorage` class. Failure to do so will cascade into hundreds of integration test failures.
389+
384390
### 6.6 Drizzle + Zod Schema Pattern (Mandatory)
385391

386392
```typescript

0 commit comments

Comments
 (0)