test(Font): make queryClient mock factory self-contained

The vi.mock factory referenced the top-level QueryClient import. Once
BaseQueryStore landed in the $shared/lib barrel, importing that barrel
for createFilter eagerly pulled @tanstack/query-core into the init
cycle, so the hoisted factory hit the import before initialization
(Cannot access '__vi_import_2__' before initialization). Import
QueryClient inside the factory to keep it independent of module order.
This commit is contained in:
Ilia Mashkov
2026-05-31 17:51:34 +03:00
parent a651d3d16f
commit 6888f67f14
@@ -2,7 +2,6 @@ import {
generateMixedCategoryFonts, generateMixedCategoryFonts,
generateMockFonts, generateMockFonts,
} from '$entities/Font/testing'; } from '$entities/Font/testing';
import { QueryClient } from '@tanstack/query-core';
import { flushSync } from 'svelte'; import { flushSync } from 'svelte';
import { import {
afterEach, afterEach,
@@ -20,6 +19,13 @@ import type { UnifiedFont } from '../../types';
import { FontCatalogStore } from './fontCatalogStore.svelte'; import { FontCatalogStore } from './fontCatalogStore.svelte';
vi.mock('$shared/api/queryClient', async importOriginal => { vi.mock('$shared/api/queryClient', async importOriginal => {
/**
* Import QueryClient inside the factory rather than referencing the top-level binding.
* A hoisted vi.mock factory that touches a module-level import can hit that import
* before it is initialized (ReferenceError) when the import sits in a circular/eager
* barrel chain — which it now does via $shared/lib → BaseQueryStore → query-core.
*/
const { QueryClient } = await import('@tanstack/query-core');
const actual = await importOriginal<typeof import('$shared/api/queryClient')>(); const actual = await importOriginal<typeof import('$shared/api/queryClient')>();
return { return {
...actual, ...actual,