Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

711 B
Raw Blame
import { vi } from "vitest";

export function mockAuthRequest() {
  // Keep the Better Auth server instance (pg pool, plugins) and next/headers
  // out of the vitest module graph. The defaults emulate "no active session";
  // tests that need user data should mock @/lib/auth/hooks/useAuth or
  // @/lib/auth/actions in their own file.
  vi.mock("@/lib/auth/auth", () => ({
    auth: {
      api: {
        getSession: vi.fn().mockResolvedValue(null),
        signOut: vi.fn().mockResolvedValue({ success: true }),
        getToken: vi.fn().mockResolvedValue(null),
      },
    },
  }));
  vi.mock("@/lib/auth/server/getServerSession", () => ({
    getServerSession: vi.fn().mockResolvedValue(null),
  }));
}