[PR #5708] [MERGED] fix(test): use async import for db #31770

Closed
opened 2026-04-17 22:39:13 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5708
Author: @himself65
Created: 11/1/2025
Status: Merged
Merged: 11/1/2025
Merged by: @himself65

Base: canaryHead: himself65/2025/10/31/async-import


📝 Commits (1)

  • 26d3f0e fix(test): use async import for db

📊 Changes

1 file changed (+30 additions, -20 deletions)

View changed files

📝 packages/better-auth/src/test-utils/index.ts (+30 -20)

📄 Description

Fixes: https://github.com/better-auth/better-auth/issues/5702


Summary by cubic

Lazy-load database clients in test utils using async imports, so DB packages are only required when the test uses them. This prevents crashes in environments without Postgres/MySQL/MongoDB and makes teardown safer.

  • Bug Fixes
    • Load Postgres, MySQL, and MongoDB clients only when selected.
    • Import sql and recreate connections during teardown to reset schemas.
    • Consolidate imports: use createAuthClient from ../client and db exports from ../db.

Written for commit 26d3f0e1a2. Summary will update automatically on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/5708 **Author:** [@himself65](https://github.com/himself65) **Created:** 11/1/2025 **Status:** ✅ Merged **Merged:** 11/1/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2025/10/31/async-import` --- ### 📝 Commits (1) - [`26d3f0e`](https://github.com/better-auth/better-auth/commit/26d3f0e1a207bdf5dbfd726eeb7dbff190e140c6) fix(test): use async import for db ### 📊 Changes **1 file changed** (+30 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/test-utils/index.ts` (+30 -20) </details> ### 📄 Description Fixes: https://github.com/better-auth/better-auth/issues/5702 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Lazy-load database clients in test utils using async imports, so DB packages are only required when the test uses them. This prevents crashes in environments without Postgres/MySQL/MongoDB and makes teardown safer. - **Bug Fixes** - Load Postgres, MySQL, and MongoDB clients only when selected. - Import sql and recreate connections during teardown to reset schemas. - Consolidate imports: use createAuthClient from ../client and db exports from ../db. <sup>Written for commit 26d3f0e1a207bdf5dbfd726eeb7dbff190e140c6. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-17 22:39:13 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#31770