-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjest.setup.js
More file actions
58 lines (53 loc) · 1.19 KB
/
jest.setup.js
File metadata and controls
58 lines (53 loc) · 1.19 KB
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
48
49
50
51
52
53
54
55
56
57
58
// Add any global Jest setup here
process.env.NODE_ENV = 'test';
// Mock Next.js router
jest.mock('next/router', () => ({
useRouter() {
return {
route: '/',
pathname: '/',
query: '',
asPath: '/',
push: jest.fn(),
pop: jest.fn(),
reload: jest.fn(),
back: jest.fn(),
prefetch: jest.fn(),
beforePopState: jest.fn(),
events: {
on: jest.fn(),
off: jest.fn(),
emit: jest.fn(),
},
};
},
}));
// Mock Next.js navigation (App Router)
jest.mock('next/navigation', () => ({
useRouter() {
return {
push: jest.fn(),
replace: jest.fn(),
back: jest.fn(),
forward: jest.fn(),
refresh: jest.fn(),
prefetch: jest.fn(),
};
},
usePathname: () => '/',
useSearchParams: () => new URLSearchParams(),
}));
// Suppress console logs during tests unless they're errors
global.console = {
...console,
log: jest.fn(),
debug: jest.fn(),
info: jest.fn(),
warn: jest.fn(),
error: console.error,
};
// Mock any problematic dependencies
jest.mock('@tensorflow/tfjs-node', () => ({}));
jest.mock('tesseract.js', () => ({}));
// Set up global test timeout
jest.setTimeout(30000);