import { Logger } from "./test-adapter.mjs"; import { Account, Session, User, Verification } from "@better-auth/core/db"; import { DBAdapter } from "@better-auth/core/db/adapter"; import { Auth } from "better-auth"; import { BetterAuthOptions } from "@better-auth/core"; //#region src/adapter/create-test-suite.d.ts /** * Test entry type that supports both callback and object formats. * Object format allows specifying migration options that will be applied before the test runs. */ type TestEntry = ((context: { readonly skip: { (note?: string | undefined): never; (condition: boolean, note?: string | undefined): void; }; }) => Promise) | { migrateBetterAuth?: BetterAuthOptions; test: (context: { readonly skip: { (note?: string | undefined): never; (condition: boolean, note?: string | undefined): void; }; }) => Promise; }; /** * Statistics tracking for test suites. */ type TestSuiteStats = { migrationCount: number; totalMigrationTime: number; testCount: number; suiteStartTime: number; suiteDuration: number; suiteName: string; groupingStats?: { totalGroups: number; averageTestsPerGroup: number; largestGroupSize: number; smallestGroupSize: number; groupsWithMultipleTests: number; totalTestsInGroups: number; }; }; type GenerateFn = (Model: M) => Promise; type Success = { data: T; error: null; }; type Failure = { data: null; error: E; }; type Result = Success | Failure; type InsertRandomFn = (model: M, count?: Count | undefined) => Promise>; declare const createTestSuite: , AdditionalOptions extends Record = {}>(suiteName: string, config: { defaultBetterAuthOptions?: BetterAuthOptions | undefined; /** * Helpful if the default better auth options require migrations to be run. */ alwaysMigrate?: boolean | undefined; prefixTests?: string | undefined; customIdGenerator?: () => any | Promise | undefined; }, tests: (helpers: { adapter: DBAdapter; log: Logger; generate: GenerateFn; insertRandom: InsertRandomFn; /** * A light cleanup function that will only delete rows it knows about. */ cleanup: () => Promise; /** * A hard cleanup function that will delete all rows from the database. */ hardCleanup: () => Promise; modifyBetterAuthOptions: (options: BetterAuthOptions, shouldRunMigrations: boolean) => Promise; getBetterAuthOptions: () => BetterAuthOptions; sortModels: (models: Array & { id: string; }>, by?: ("id" | "createdAt") | undefined) => (Record & { id: string; })[]; getAuth: () => Promise; tryCatch(promise: Promise): Promise>; customIdGenerator?: () => any | Promise | undefined; transformIdOutput?: (id: any) => string | undefined; /** * Some adapters may change the ID type, this function allows you to pass the entire model * data and it will return the correct better-auth-expected transformed data. * * Eg: * MongoDB uses ObjectId for IDs, but it's possible the user can disable that option in the adapter config. * Because of this, the expected data would be a string. * These sorts of conversions will cause issues with the test when you use the `generate` function. * This is because the `generate` function will return the raw data expected to be saved in DB, not the excpected BA output. */ transformGeneratedModel: (data: Record) => Record; }, additionalOptions?: AdditionalOptions | undefined) => Tests) => (options?: ({ disableTests?: Partial & { ALL?: boolean; }>; } & AdditionalOptions) | undefined) => (helpers: { adapter: () => Promise>; log: Logger; adapterDisplayName: string; getBetterAuthOptions: () => BetterAuthOptions; modifyBetterAuthOptions: (options: BetterAuthOptions) => Promise; cleanup: () => Promise; runMigrations: () => Promise; prefixTests?: string | undefined; onTestFinish: (stats: TestSuiteStats) => Promise; customIdGenerator?: () => any | Promise | undefined; transformIdOutput?: (id: any) => string | undefined; }) => Promise; //#endregion export { InsertRandomFn, TestEntry, TestSuiteStats, createTestSuite };