Files
livedash-node/tests/setup.ts
Kaj Kowalski aa0e9d5ebc test: fix test environment issues and update TODO with architecture plan
- Fix window.matchMedia mock for DOM environment compatibility
- Simplify accessibility tests to focus on core functionality
- Update auth test mocking to avoid initialization errors
- Move visual tests to examples directory
- Add comprehensive architecture refactoring plan to TODO
- Document platform management needs and microservices strategy
2025-06-28 07:16:22 +02:00

43 lines
1.1 KiB
TypeScript

// Vitest test setup
import { vi } from "vitest";
import "@testing-library/jest-dom";
// Mock console methods to reduce noise in tests
global.console = {
...console,
log: vi.fn(),
warn: vi.fn(),
error: vi.fn(),
};
// Set test environment variables
process.env.NEXTAUTH_SECRET = "test-secret";
process.env.NEXTAUTH_URL = "http://localhost:3000";
// Use test database for all database operations during tests
if (process.env.DATABASE_URL_TEST) {
process.env.DATABASE_URL = process.env.DATABASE_URL_TEST;
}
// Mock node-fetch for transcript fetcher tests
vi.mock("node-fetch", () => ({
default: vi.fn(),
}));
// Mock window.matchMedia for theme provider (only in DOM environment)
if (typeof window !== "undefined") {
Object.defineProperty(window, "matchMedia", {
writable: true,
value: vi.fn().mockImplementation(query => ({
matches: false,
media: query,
onchange: null,
addListener: vi.fn(), // deprecated
removeListener: vi.fn(), // deprecated
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
dispatchEvent: vi.fn(),
})),
});
}