Commit 50868ff
committed
docs(review): clarify what the no-mocking rule is actually for
The literal reading of "never mock anything" trips up AI reviewers
(and humans new to the repo) — they flag any `vi.mock` / `vi.fn` /
`vi.spyOn` they see, even when the usage isn't actually faking
behavior. Three patterns are fine and should NOT be flagged:
1. Module-load workarounds — vi.mock("~/db.server") at the top of a
unit test to stop prisma.$connect() firing at import. Cuts the
import graph, doesn't fake DB behavior.
2. Hand-written DI doubles where the real implementation has its own
dedicated infra-backed tests (CapturingMollifierBuffer, MockPayloadProcessor,
etc.). Unit test covers wiring, integration test covers the seam target.
3. vi.fn as a DI-seam probe — convenience for "was the seam called."
Equivalent to a closure-counter; not load-bearing on what's proven.
Still 🔴: spying on the code path under test then asserting the spy was
called (tautology), or replacing real infra with mocks in tests meant
to cover real behavior (e.g. mocking Redis in a Redis-queue test).1 parent e5d403e commit 50868ff
1 file changed
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
26 | 34 | | |
27 | 35 | | |
28 | 36 | | |
| |||
0 commit comments