diff --git a/client/src/components/Map/MapView.test.tsx b/client/src/components/Map/MapView.test.tsx index b4496cef8..aa4200bb9 100644 --- a/client/src/components/Map/MapView.test.tsx +++ b/client/src/components/Map/MapView.test.tsx @@ -211,7 +211,15 @@ vi.mock('../../services/photoService', () => ({ const shell = vi.hoisted(() => ({ phone: undefined as boolean | undefined })) vi.mock('../../mobile/useIsPhone', async (importOriginal) => { const actual = await importOriginal() - return { ...actual, useIsPhone: () => shell.phone ?? actual.useIsPhone() } + // The real hook runs every time, so a test that changes the answer never changes the + // number of hooks a mounted map has (React throws on that). + return { + ...actual, + useIsPhone: () => { + const real = actual.useIsPhone() + return shell.phone ?? real + }, + } }) vi.mock('./gcj02Crs', () => ({