60e115309c
queryClient.ts constructed the TanStack client at module eval but was not in the sideEffects allowlist, so Rollup treated the module as pure — safe only while a value-importer keeps it alive (D-3). - replace the eager `queryClient` singleton with a memoized getQueryClient() factory; construction is deferred to first call - the module is now genuinely side-effect-free, so no sideEffects exception is needed and construction can never be legally tree-shaken away - route all consumers through getQueryClient() (QueryProvider as first caller; stores via class fields/observers; tests via a local alias; the fontCatalogStore spec mock now overrides getQueryClient)
34 lines
840 B
TypeScript
34 lines
840 B
TypeScript
import { getQueryClient } from '$shared/api/queryClient';
|
|
import * as matchers from '@testing-library/jest-dom/matchers';
|
|
import { cleanup } from '@testing-library/svelte';
|
|
import {
|
|
afterEach,
|
|
expect,
|
|
vi,
|
|
} from 'vitest';
|
|
|
|
// Import Tailwind CSS styles for component tests
|
|
import '$app/styles/app.css';
|
|
|
|
expect.extend(matchers);
|
|
|
|
afterEach(() => {
|
|
cleanup();
|
|
getQueryClient().clear();
|
|
});
|
|
|
|
// Mock window.matchMedia for components that use it
|
|
Object.defineProperty(window, 'matchMedia', {
|
|
writable: true,
|
|
value: vi.fn().mockImplementation((query: string) => ({
|
|
matches: false,
|
|
media: query,
|
|
onchange: null,
|
|
addListener: vi.fn(),
|
|
removeListener: vi.fn(),
|
|
addEventListener: vi.fn(),
|
|
removeEventListener: vi.fn(),
|
|
dispatchEvent: vi.fn(),
|
|
})),
|
|
});
|