File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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.
You can’t perform that action at this time.
0 commit comments