mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-26 17:26:23 +02:00
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import '@testing-library/jest-dom';
|
|
import { cleanup } from '@testing-library/react';
|
|
import { afterEach, vi } from 'vitest';
|
|
import React from 'react';
|
|
|
|
// Cleanup after each test
|
|
afterEach(() => {
|
|
cleanup();
|
|
});
|
|
|
|
// Mock ResizeObserver (required for Radix UI components)
|
|
global.ResizeObserver = class ResizeObserver {
|
|
observe() { }
|
|
unobserve() { }
|
|
disconnect() { }
|
|
};
|
|
|
|
// Mock PointerEvent APIs for Radix UI Select
|
|
HTMLElement.prototype.hasPointerCapture = vi.fn(() => false);
|
|
HTMLElement.prototype.setPointerCapture = vi.fn();
|
|
HTMLElement.prototype.releasePointerCapture = vi.fn();
|
|
HTMLElement.prototype.scrollIntoView = vi.fn();
|
|
|
|
// Mock Next.js router
|
|
vi.mock('next/navigation', () => ({
|
|
useRouter: () => ({
|
|
push: vi.fn(),
|
|
replace: vi.fn(),
|
|
prefetch: vi.fn(),
|
|
back: vi.fn(),
|
|
pathname: '/',
|
|
query: {},
|
|
}),
|
|
usePathname: () => '/',
|
|
useSearchParams: () => new URLSearchParams(),
|
|
}));
|
|
|
|
// Mock Next.js Image component
|
|
vi.mock('next/image', () => ({
|
|
default: (props: any) => {
|
|
return React.createElement('img', props);
|
|
},
|
|
}));
|