Skip to content

Commit d90052d

Browse files
committed
fix: fix formating issue
1 parent c5c20d9 commit d90052d

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/integration_testing/setup.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,19 @@ export const originalFetch = globalThis.fetch;
8181
export const mockFetch = mock();
8282

8383
export function enableFetchMock() {
84-
globalThis.fetch = mockFetch as unknown as typeof fetch;
84+
// 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;
8597
}
8698

8799
export function restoreFetch() {

0 commit comments

Comments
 (0)