-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.setup.ts
More file actions
47 lines (42 loc) · 1008 Bytes
/
vitest.setup.ts
File metadata and controls
47 lines (42 loc) · 1008 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import '@testing-library/jest-dom'
import { cleanup } from '@testing-library/react'
import { afterEach, vi } from 'vitest'
// Cleanup after each test
afterEach(() => {
cleanup()
})
// Mock next-intl
vi.mock('next-intl', () => ({
useTranslations: () => (key: string) => key,
useLocale: () => 'de',
}))
// Mock next/navigation
vi.mock('next/navigation', () => ({
useRouter: () => ({
push: vi.fn(),
replace: vi.fn(),
back: vi.fn(),
}),
usePathname: () => '/',
useSearchParams: () => new URLSearchParams(),
}))
// Mock @/i18n/routing
vi.mock('@/i18n/routing', () => ({
Link: vi.fn(({ children }) => children),
useRouter: () => ({
push: vi.fn(),
replace: vi.fn(),
back: vi.fn(),
}),
usePathname: () => '/',
redirect: vi.fn(),
}))
// Mock next-themes
vi.mock('next-themes', () => ({
useTheme: () => ({
theme: 'light',
setTheme: vi.fn(),
resolvedTheme: 'light',
}),
ThemeProvider: ({ children }: { children: React.ReactNode }) => children,
}))