-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.setup.ts
More file actions
37 lines (31 loc) · 1.17 KB
/
Copy pathvitest.setup.ts
File metadata and controls
37 lines (31 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/// <reference types="vitest/globals" />
import '@testing-library/jest-dom';
import { vi } from 'vitest';
import { setupMocks } from './__tests__/setup/mocks';
// Setup mocks before all tests
setupMocks();
// Mock IntersectionObserver which is not available in jsdom
if (typeof window !== 'undefined') {
window.IntersectionObserver = class MockIntersectionObserver implements IntersectionObserver {
readonly root: Element | null = null;
readonly rootMargin: string = '0px';
readonly thresholds: ReadonlyArray<number> = [0];
constructor() {}
observe(): void {}
unobserve(): void {}
disconnect(): void {}
takeRecords(): IntersectionObserverEntry[] {
return [];
}
};
}
// Suppress console errors/warnings in test output
beforeAll(() => {
console.error = vi.fn();
console.warn = vi.fn();
});
// Setup environment variables for testing
process.env.TEST_DATABASE_URL = 'postgresql://postgres:postgres@localhost:5432/kosuke_test';
process.env.POSTGRES_URL = 'postgresql://postgres:postgres@localhost:5432/kosuke_test';
process.env.NEXT_PUBLIC_APP_URL = 'http://localhost:3000';
process.env.BETTER_AUTH_SECRET = 'test-secret-key-for-testing-only';