GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — baseFM-opensource/vitest.setup.tsx at main · EskyLab/baseFM-opensource

Expand file tree

/

vitest.setup.tsx

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
141 lines (130 loc) · 2.91 KB
/

vitest.setup.tsx

Copy path

File metadata and controls

141 lines (130 loc) · 2.91 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/**
* Vitest Setup File
*
* This file runs before all tests.
* Configure global mocks and test utilities here.
*/
import '@testing-library/jest-dom';
import { vi } from 'vitest';
// =============================================================================
// GLOBAL MOCKS
// =============================================================================
/**
* Mock Next.js router
* Required for components using useRouter
*/
vi.mock('next/navigation', () => ({
useRouter: () => ({
push: vi.fn(),
replace: vi.fn(),
back: vi.fn(),
forward: vi.fn(),
refresh: vi.fn(),
prefetch: vi.fn(),
}),
usePathname: () => '/',
useSearchParams: () => new URLSearchParams(),
}));
/**
* Mock Next.js Image component
* Renders as a regular img for testing
*/
vi.mock('next/image', () => ({
default: (props: any) => <img {...props} />,
}));
/**
* Mock wagmi hooks
* Override these in individual tests as needed
*/
vi.mock('wagmi', () => ({
useAccount: () => ({
address: undefined,
isConnected: false,
isConnecting: false,
isDisconnected: true,
}),
useBalance: () => ({
data: undefined,
isLoading: false,
isError: false,
}),
useWriteContract: () => ({
writeContract: vi.fn(),
data: undefined,
isPending: false,
error: null,
}),
useWaitForTransactionReceipt: () => ({
isLoading: false,
isSuccess: false,
}),
useReadContract: () => ({
data: undefined,
isLoading: false,
isError: false,
}),
}));
/**
* Mock ResizeObserver
* Required for components using ResizeObserver
*/
global.ResizeObserver = vi.fn().mockImplementation(() => ({
observe: vi.fn(),
unobserve: vi.fn(),
disconnect: vi.fn(),
}));
/**
* Mock IntersectionObserver
* Required for lazy loading and infinite scroll
*/
global.IntersectionObserver = vi.fn().mockImplementation(() => ({
observe: vi.fn(),
unobserve: vi.fn(),
disconnect: vi.fn(),
}));
/**
* Mock fetch globally
* Override in individual tests as needed
*/
global.fetch = vi.fn(() =>
Promise.resolve({
ok: true,
json: () => Promise.resolve({}),
})
) as unknown as typeof fetch;
/**
* Mock navigator.share
* For social sharing tests
*/
Object.defineProperty(navigator, 'share', {
value: vi.fn().mockResolvedValue(undefined),
writable: true,
});
/**
* Mock navigator.clipboard
* For copy-to-clipboard tests
*/
Object.defineProperty(navigator, 'clipboard', {
value: {
writeText: vi.fn().mockResolvedValue(undefined),
readText: vi.fn().mockResolvedValue(''),
},
writable: true,
});
/**
* Mock window.matchMedia
* For responsive design tests
*/
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: vi.fn().mockImplementation((query: string) => ({
matches: false,
media: query,
onchange: null,
addListener: vi.fn(),
removeListener: vi.fn(),
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
dispatchEvent: vi.fn(),
})),
});
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.