-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.js
More file actions
35 lines (32 loc) · 822 Bytes
/
jest.setup.js
File metadata and controls
35 lines (32 loc) · 822 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
// Learn more: https://jestjs.io/docs/configuration#setupfilesafterenv-array
// This file is used to set up any global test environment configuration
// For example, you might add global mocks or polyfills here
// Mock Next.js router
jest.mock('next/router', () => ({
useRouter: () => ({
push: jest.fn(),
replace: jest.fn(),
prefetch: jest.fn(),
back: jest.fn(),
pathname: '/',
query: {},
asPath: '/',
locale: 'en',
events: {
on: jest.fn(),
off: jest.fn(),
emit: jest.fn(),
},
}),
}));
// Mock Next.js navigation functions
jest.mock('next/navigation', () => ({
useRouter: () => ({
push: jest.fn(),
replace: jest.fn(),
back: jest.fn(),
}),
usePathname: () => '/',
useSearchParams: () => new URLSearchParams(),
notFound: jest.fn(),
}));