Compare commits

..

2 commits

Author SHA1 Message Date
1804544203 Merge pull request 'Fix sports.test.tsx timeout: mock SportIcon to eliminate async image-error state updates' (#77) from fix/sports-test-timeout into main
All checks were successful
🚀 Deploy / 🧪 Test (push) Successful in 2m25s
🚀 Deploy / ʦ🔍 Typecheck & Lint (push) Successful in 1m20s
🚀 Deploy / 🐳 Build (push) Successful in 1m12s
🚀 Deploy / 🚀 Deploy (push) Successful in 12s
Reviewed-on: #77
2026-06-06 17:34:15 +00:00
Chris Parsons
3c3b162aab Fix sports.test.tsx timeout: mock SportIcon to eliminate async image-error state updates
All checks were successful
🚀 Deploy / 🧪 Test (pull_request) Successful in 2m28s
🚀 Deploy / ʦ🔍 Typecheck & Lint (pull_request) Successful in 1m20s
🚀 Deploy / 🐳 Build (pull_request) Has been skipped
🚀 Deploy / 🚀 Deploy (pull_request) Has been skipped
SportIcon renders <img> elements whose onError handler calls setFailed(true),
scheduling state updates asynchronously outside React act() in jsdom. With
multiple icons on the Sports page this caused the synchronous render test to
hit the 5000ms Vitest timeout intermittently.

Mock SportIcon in the test using resolveSportIconUrl() so the mock stays in
sync with the real URL resolution logic if it ever changes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-06 10:27:41 -07:00

View file

@ -6,6 +6,16 @@ vi.mock("~/models/sport", () => ({
findPublicSportsWithCurrentSeasons: vi.fn(),
}));
vi.mock("~/components/SportIcon", async () => {
const { resolveSportIconUrl } = await import("~/lib/sport-icon-url");
return {
SportIcon: ({ sportName, iconUrl }: { sportName: string; iconUrl?: string | null }) => {
const src = resolveSportIconUrl(iconUrl);
return src ? <img src={src} alt={sportName} /> : null;
},
};
});
import Sports, { loader } from "../sports";
import { findPublicSportsWithCurrentSeasons } from "~/models/sport";
import type { PublicSportWithCurrentSeasons } from "~/models/sport";