jsdom does not implement scrollTo on elements, causing any component that calls element.scrollTo() (e.g. MiniDraftGrid's scroll-to-current-cell effect) to throw in unit tests. https://claude.ai/code/session_017JCShLVs9xZ6FZmyrUFaE1
37 lines
830 B
TypeScript
37 lines
830 B
TypeScript
import '@testing-library/jest-dom';
|
|
import { cleanup } from '@testing-library/react';
|
|
import { afterEach, vi } from 'vitest';
|
|
|
|
// Cleanup after each test
|
|
afterEach(() => {
|
|
cleanup();
|
|
});
|
|
|
|
// Mock environment variables
|
|
process.env.NODE_ENV = 'test';
|
|
|
|
// jsdom does not implement scrollTo on elements
|
|
HTMLElement.prototype.scrollTo = vi.fn();
|
|
|
|
// Mock BetterAuth
|
|
vi.mock('~/lib/auth.server', () => ({
|
|
auth: {
|
|
api: {
|
|
getSession: vi.fn(() => Promise.resolve({
|
|
user: { id: 'test-user-id', email: 'test@example.com', name: 'Test User' },
|
|
session: { userId: 'test-user-id' },
|
|
})),
|
|
},
|
|
},
|
|
}));
|
|
|
|
// Mock database context
|
|
vi.mock('~/database/context', () => ({
|
|
database: vi.fn(() => ({
|
|
query: {},
|
|
insert: vi.fn(),
|
|
update: vi.fn(),
|
|
delete: vi.fn(),
|
|
select: vi.fn(),
|
|
})),
|
|
}));
|