test(auth): add test-only auth instance with testUtils plugin and initial tests

This commit is contained in:
2026-04-25 14:14:23 +08:00
parent a9cb8a328c
commit d1e2a8f281
4 changed files with 69 additions and 2 deletions
+21
View File
@@ -0,0 +1,21 @@
import { betterAuth } from "better-auth"
import { testUtils } from "better-auth/plugins"
import { drizzleAdapter } from "@better-auth/drizzle-adapter"
import { db } from "@/lib/db/index"
export const testAuth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg",
}),
plugins: [
testUtils({ captureOTP: true }),
],
emailAndPassword: {
enabled: true,
},
})
export async function getTestHelpers() {
const ctx = await testAuth.$context
return ctx.test
}