-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjest.setup.js
40 lines (33 loc) · 954 Bytes
/
jest.setup.js
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
import '@testing-library/jest-dom'
// Polyfill for TextEncoder/TextDecoder
const { TextEncoder, TextDecoder } = require('util')
global.TextEncoder = TextEncoder
global.TextDecoder = TextDecoder
global.setImmediate = (callback) => setTimeout(callback, 0);
// Mock @privy-io/react-auth
jest.mock('@privy-io/react-auth', () => ({
usePrivy: () => ({
ready: true,
authenticated: false,
user: null,
login: jest.fn(),
logout: jest.fn(),
getAccessToken: jest.fn(),
}),
}))
// Mock @radix-ui/react-slot
jest.mock('@radix-ui/react-slot', () => ({
Slot: ({ children, ...props }) => <div {...props}>{children}</div>,
}))
// Mock @/lib/cn
jest.mock('@/lib/cn', () => ({
cn: (...args) => args.filter(Boolean).join(' '),
}))
// Mock @/components/ui/loader
jest.mock('@/components/ui/loader', () => ({
Loader: () => <div data-testid="loader" />,
}))
// Reset all mocks after each test
afterEach(() => {
jest.clearAllMocks()
})