mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-07-14 18:15:56 -04:00
Switch `mock.module("../src/image-cache", ...)` stubs in thumbhash, person-detail, colors, and credits tests to `spyOn(globalThis, "fetch")` instead. This avoids the cross-file persistence problem with `mock.module` and tests the real code paths more faithfully.
Update `image-cache.ts` to call `globalThis.fetch` so the spy intercepts it, add `mock.restore()` to the global `afterEach` in `preload.ts`, and set `IMAGE_CACHE_ENABLED=false` in affected tests to avoid disk writes during test runs.
16 lines
291 B
TypeScript
16 lines
291 B
TypeScript
import { afterEach, mock } from "bun:test";
|
|
import { applyMigrations, testDb } from "@sofa/db/test-utils";
|
|
|
|
process.env.LOG_LEVEL ??= "error";
|
|
|
|
mock.module("@sofa/db/client", () => ({
|
|
db: testDb,
|
|
closeDatabase: () => {},
|
|
}));
|
|
|
|
applyMigrations();
|
|
|
|
afterEach(() => {
|
|
mock.restore();
|
|
});
|