-
-
Notifications
You must be signed in to change notification settings - Fork 268
Expand file tree
/
Copy pathvitest.setup.tsx
More file actions
28 lines (23 loc) · 802 Bytes
/
vitest.setup.tsx
File metadata and controls
28 lines (23 loc) · 802 Bytes
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
import '@testing-library/jest-dom';
import { vi, beforeAll } from 'vitest';
const MockedNextImage = ({ src, alt }: { src: string; alt: string }) => <img src={src} alt={alt} />;
/* MOCKS */
vi.mock('next/image', () => ({ default: MockedNextImage }));
vi.mock('next/navigation', () => ({
useRouter: () => ({ push: vi.fn(), prefetch: vi.fn(), back: vi.fn(), replace: vi.fn() }),
usePathname: () => '/',
useSearchParams: () => new URLSearchParams(),
}));
vi.importMock('@/lib/utils/thirdParty/gtag');
beforeAll(async () => {
const IntersectionObserverMock = vi.fn(() => ({
disconnect: vi.fn(),
observe: vi.fn(),
takeRecords: vi.fn(),
unobserve: vi.fn(),
}));
vi.stubGlobal('IntersectionObserver', IntersectionObserverMock);
});
beforeEach(() => {
vi.clearAllMocks();
});