Skip to content

Commit a602687

Browse files
docs: add decision for cache server stub
Co-authored-by: me <me@kentcdodds.com>
1 parent cab6087 commit a602687

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Mock Cache Server in Tests
2+
3+
Date: 2026-02-01
4+
5+
Status: accepted
6+
7+
## Context
8+
9+
Our Vitest suite runs in a Vite-powered environment that attempts to bundle
10+
imports for jsdom tests. The app cache implementation imports `node:sqlite`,
11+
which Vite cannot bundle for client-like environments. This caused CI failures
12+
when Vitest upgraded and began resolving the cache module for jsdom suites.
13+
Additionally, the cache module requires `CACHE_DATABASE_PATH`, which is not
14+
needed for unit tests and creates friction for running tests locally.
15+
16+
## Decision
17+
18+
We will provide a test-only cache server stub and instruct Vite/Vitest to
19+
resolve `cache.server.ts` to this stub when running Vitest. The stub provides
20+
in-memory cache behavior and a minimal `cachified` implementation sufficient
21+
for the tests. Production and development builds continue to use the real
22+
SQLite-backed cache implementation.
23+
24+
## Consequences
25+
26+
- **Stable CI tests**: Vitest no longer tries to bundle `node:sqlite`, and the
27+
cache module no longer requires `CACHE_DATABASE_PATH` in unit tests.
28+
- **Scoped behavior**: Cache behavior in unit tests is simplified to in-memory
29+
semantics, so SQLite-specific behavior is not exercised in those tests.
30+
- **No runtime impact**: Only Vitest uses the stub; production and development
31+
environments remain unchanged.

0 commit comments

Comments
 (0)