Initial vitest setup

This commit is contained in:
2025-05-26 20:02:53 +02:00
parent 3c6e767954
commit e5569fc4a5
7 changed files with 1050 additions and 100 deletions

30
app/src/test/setup.ts Normal file
View File

@@ -0,0 +1,30 @@
import '@testing-library/jest-dom';
import { vi } from 'vitest';
// Mock window.API_BASE_URL
Object.defineProperty(window, 'API_BASE_URL', {
value: 'http://localhost:8080/api/v1',
writable: true,
});
// Mock matchMedia - required for Mantine components
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: vi.fn().mockImplementation((query: string) => ({
matches: false,
media: query,
onchange: null,
addListener: vi.fn(), // deprecated
removeListener: vi.fn(), // deprecated
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
dispatchEvent: vi.fn(),
})),
});
// Mock ResizeObserver - sometimes needed for Mantine components
global.ResizeObserver = vi.fn().mockImplementation(() => ({
observe: vi.fn(),
unobserve: vi.fn(),
disconnect: vi.fn(),
}));