1 parent c5c20d9 commit d90052dCopy full SHA for d90052d
1 file changed
src/integration_testing/setup.ts
@@ -81,7 +81,19 @@ export const originalFetch = globalThis.fetch;
81
export const mockFetch = mock();
82
83
export function enableFetchMock() {
84
- globalThis.fetch = mockFetch as unknown as typeof fetch;
+ // Only intercept Groq API calls; pass all others through to the original fetch
85
+ globalThis.fetch = ((url: string | URL | Request, init?: RequestInit) => {
86
+ const urlStr =
87
+ typeof url === "string"
88
+ ? url
89
+ : url instanceof URL
90
+ ? url.toString()
91
+ : url.url;
92
+ if (urlStr.includes("groq.com")) {
93
+ return mockFetch(url, init);
94
+ }
95
+ return originalFetch(url, init);
96
+ }) as typeof fetch;
97
}
98
99
export function restoreFetch() {
0 commit comments