-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjest.setup.ts
More file actions
35 lines (29 loc) · 1.07 KB
/
jest.setup.ts
File metadata and controls
35 lines (29 loc) · 1.07 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
import '@testing-library/jest-dom';
// Augment the global type for the act environment flag
declare global {
// eslint-disable-next-line no-var
var IS_REACT_ACT_ENVIRONMENT: boolean;
}
// Explicitly set the React 18+ act environment flag
global.IS_REACT_ACT_ENVIRONMENT = true;
jest.mock('next/navigation', () => ({
useRouter: () => ({
push: jest.fn(),
replace: jest.fn(),
prefetch: jest.fn(),
}),
usePathname: () => '/',
useSearchParams: () => new URLSearchParams(),
}));
jest.mock('next-intl', () => ({
useTranslations: (namespace?: string) => (key: string) =>
namespace ? `${namespace}.${key}` : key,
}));
// Remove the global mock for next-intl
// jest.mock('next-intl', () => ({
// useTranslations: jest.fn(() => (key: string) => key.split('.').pop() || key),
// useLocale: jest.fn(() => 'en'),
// // Add other exports if needed by any component, e.g.:
// // NextIntlClientProvider: ({ children }: { children: React.ReactNode }) => <>{children}</>,
// }));
// Add other global mocks or setup here if needed