forked from creativeplatform/crtv3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.setup.ts
More file actions
27 lines (23 loc) · 760 Bytes
/
vitest.setup.ts
File metadata and controls
27 lines (23 loc) · 760 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
25
26
27
import '@testing-library/jest-dom'
import { vi } from 'vitest';
import * as matchers from 'jest-extended';
// Setup jest-extended for additional matchers (e.g., toHaveBeenCalledBefore, ...etc)
expect.extend(matchers);
// Mock Next.js components/functions
vi.mock('next/server', () => ({
NextResponse: {
json: <T>(data: any, init?: ResponseInit) =>
new Response(JSON.stringify(data), {
...init,
headers: { 'content-type': 'application/json' },
}),
},
NextRequest: class MockNextRequest extends Request {
nextUrl: URL;
constructor(input: RequestInfo | URL, init?: RequestInit) {
super(input, init);
this.nextUrl = new URL(input.toString());
}
},
}));
// Add any other global test setup here