From 8a3717cea71e892a9c820cd2ccf92dfff97ed767 Mon Sep 17 00:00:00 2001 From: Jake Jarvis Date: Fri, 6 Mar 2026 13:51:55 -0500 Subject: [PATCH] Remove tmdbImageUrl mocks to fix cross-file mock poisoning in CI bun's mock.module persists across test files in the same process, causing image.test.ts to receive the stub instead of the real tmdbImageUrl. Since tmdbImageUrl has no heavy runtime dependencies, service tests work fine with the real implementation. Co-Authored-By: Claude Opus 4.6 --- lib/services/credits.test.ts | 6 +----- lib/services/discovery.test.ts | 6 +----- lib/services/person.test.ts | 6 +----- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/lib/services/credits.test.ts b/lib/services/credits.test.ts index f18df33..11a14c9 100644 --- a/lib/services/credits.test.ts +++ b/lib/services/credits.test.ts @@ -2,10 +2,6 @@ import { beforeEach, describe, expect, mock, test } from "bun:test"; import { persons, titleCast } from "@/lib/db/schema"; import { clearAllTables, insertTitle, testDb } from "@/lib/test-utils"; -mock.module("@/lib/tmdb/image", () => ({ - tmdbImageUrl: (path: string | null) => path, -})); - mock.module("./image-cache", () => ({ imageCacheEnabled: () => false, cacheProfilePhotos: async () => {}, @@ -65,7 +61,7 @@ describe("getCastForTitle", () => { expect(cast).toHaveLength(2); expect(cast[0].name).toBe("Actor One"); expect(cast[0].character).toBe("Hero"); - expect(cast[0].profilePath).toBe("/path1.jpg"); + expect(cast[0].profilePath).toBe("/api/images/profiles/path1.jpg"); expect(cast[1].name).toBe("Actor Two"); }); diff --git a/lib/services/discovery.test.ts b/lib/services/discovery.test.ts index 3449637..8f5a917 100644 --- a/lib/services/discovery.test.ts +++ b/lib/services/discovery.test.ts @@ -1,4 +1,4 @@ -import { beforeEach, describe, expect, mock, test } from "bun:test"; +import { beforeEach, describe, expect, test } from "bun:test"; import { clearAllTables, insertAvailabilityOffer, @@ -12,10 +12,6 @@ import { insertUser, } from "@/lib/test-utils"; -mock.module("@/lib/tmdb/image", () => ({ - tmdbImageUrl: (path: string | null) => path, -})); - import { getContinueWatchingFeed, getNewAvailableFeed, diff --git a/lib/services/person.test.ts b/lib/services/person.test.ts index 08fa358..c078bd0 100644 --- a/lib/services/person.test.ts +++ b/lib/services/person.test.ts @@ -1,11 +1,7 @@ -import { beforeEach, describe, expect, mock, test } from "bun:test"; +import { beforeEach, describe, expect, test } from "bun:test"; import { persons, titleCast } from "@/lib/db/schema"; import { clearAllTables, insertTitle, testDb } from "@/lib/test-utils"; -mock.module("@/lib/tmdb/image", () => ({ - tmdbImageUrl: (path: string | null) => path, -})); - import { getLocalFilmography } from "./person"; beforeEach(() => {