refactor(web/test): default svelte-query mock in vitest.setup; remove from 34 files (B3)
This commit is contained in:
+12
-1
@@ -1,9 +1,20 @@
|
||||
import '@testing-library/jest-dom/vitest';
|
||||
import { beforeEach, afterEach } from 'vitest';
|
||||
import { beforeEach, afterEach, vi } from 'vitest';
|
||||
import { render } from '@testing-library/svelte';
|
||||
import ToastHost from './src/lib/components/ToastHost.svelte';
|
||||
import { clearToast } from './src/lib/stores/toast.svelte';
|
||||
|
||||
// Default svelte-query mock for the whole test suite. Most component
|
||||
// tests just need useQueryClient to return SOMETHING — they never assert
|
||||
// on the result. Tests that need to assert on invalidateQueries (named
|
||||
// mock pattern) override this with their own per-file vi.mock. The
|
||||
// override wins because per-file mocks take precedence over setup-file
|
||||
// mocks in vitest.
|
||||
vi.mock('@tanstack/svelte-query', async (orig) => {
|
||||
const actual = (await orig()) as Record<string, unknown>;
|
||||
return { ...actual, useQueryClient: () => ({ invalidateQueries: vi.fn() }) };
|
||||
});
|
||||
|
||||
// Node 25 ships a partial localStorage global that lacks getItem/setItem/clear
|
||||
// unless launched with --localstorage-file. jsdom sees Node's global and skips
|
||||
// installing its own. Replace with an in-memory Storage-compatible polyfill so
|
||||
|
||||
Reference in New Issue
Block a user