quivr/frontend/lib/api/tests/getNock.ts
2023-09-12 18:04:35 +02:00

19 lines
523 B
TypeScript

import nock from "nock";
import { vi } from "vitest";
import { DEFAULT_BACKEND_URL } from "@/lib/config/CONSTANTS";
vi.mock("@/lib/context/SupabaseProvider", () => ({
useSupabase: () => ({}),
}));
export const getNock = (url?: string): nock.Scope => {
return nock(
url ?? `${process.env.NEXT_PUBLIC_BACKEND_URL ?? DEFAULT_BACKEND_URL}`
).defaultReplyHeaders({
"access-control-allow-origin": "*",
"access-control-allow-credentials": "true",
"access-control-allow-headers": "Authorization",
});
};