-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.js
More file actions
24 lines (22 loc) · 930 Bytes
/
Copy pathjest.setup.js
File metadata and controls
24 lines (22 loc) · 930 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
import '@testing-library/jest-dom';
// Clerk ships ESM (@clerk/backend) that jsdom/Jest doesn't transform, and no
// unit test exercises real auth. Stub the server + client entry points so
// components that transitively import them (e.g. via server actions) load.
jest.mock('@clerk/nextjs/server', () => ({
auth: jest.fn(async () => ({
userId: 'test-user-id',
getToken: jest.fn(async () => 'test-token'),
})),
currentUser: jest.fn(async () => null),
clerkMiddleware: (handler) => handler,
createRouteMatcher: () => () => false,
}));
jest.mock('@clerk/nextjs', () => ({
ClerkProvider: ({ children }) => children,
useClerk: () => ({ signOut: jest.fn() }),
useAuth: () => ({ isSignedIn: true, userId: 'test-user-id' }),
useUser: () => ({ isSignedIn: true, user: null }),
useSession: () => ({ session: { getToken: jest.fn(async () => 'test-token') } }),
SignIn: () => null,
SignUp: () => null,
}));