[PR #4663] [CLOSED] test: fix flaky #5513

Closed
opened 2026-03-13 12:25:37 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4663
Author: @himself65
Created: 9/15/2025
Status: Closed

Base: canaryHead: himself65/2025/09/14/prisma


📝 Commits (4)

  • 99b4c3d test: fix flaky
  • f55acfe Merge branch 'canary' into himself65/2025/09/14/prisma
  • e4e95a9 Merge branch 'canary' into himself65/2025/09/14/prisma
  • 87c7808 test: fix

📊 Changes

7 files changed (+185 additions, -188 deletions)

View changed files

📝 packages/better-auth/package.json (+0 -3)
📝 packages/better-auth/src/adapters/prisma-adapter/test/normal-tests/adapter.prisma.test.ts (+10 -18)
📝 packages/better-auth/src/adapters/prisma-adapter/test/normal-tests/get-adapter.ts (+18 -8)
📝 packages/better-auth/src/adapters/prisma-adapter/test/number-id-tests/adapter.prisma.number-id.test.ts (+11 -28)
📝 packages/better-auth/src/adapters/prisma-adapter/test/number-id-tests/get-adapter.ts (+25 -15)
📝 packages/better-auth/src/adapters/prisma-adapter/test/push-schema.ts (+12 -2)
📝 packages/better-auth/src/adapters/test.ts (+109 -114)

📄 Description

Summary by cubic

Stabilizes Prisma adapter tests by isolating each run with its own SQLite DB and making schema pushes synchronous to eliminate race conditions and data leakage.

  • Refactors

    • Each test uses a copied dev.db (crypto UUID) with datasourceUrl override.
    • getAdapter is now async and returns { adapter, clear } for cleanup.
    • Switched to beforeEach to push schema and reset DB per suite.
    • Replaced async exec with execSync in pushPrismaSchema.
    • runAdapterTest/runNumberIdAdapterTest now non-async wrappers.
  • Bug Fixes

    • Removed cross-suite file-based state and watchers; no shared DB state.
    • Tests no longer depend on unique email prefixes; fresh DB prevents collisions.
    • Adjusted assertions to avoid fixed counts; created entities per test.
    • Reset sqlite_sequence where required in number-id tests.
    • Dropped the brittle “increment id by 1” assertion that caused flakes.

🔄 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/4663 **Author:** [@himself65](https://github.com/himself65) **Created:** 9/15/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `himself65/2025/09/14/prisma` --- ### 📝 Commits (4) - [`99b4c3d`](https://github.com/better-auth/better-auth/commit/99b4c3dab619869f99c39c69382b4cf3a36dff4e) test: fix flaky - [`f55acfe`](https://github.com/better-auth/better-auth/commit/f55acfea7da2bd36e04aa63d2f1cf3cc8d400de8) Merge branch 'canary' into himself65/2025/09/14/prisma - [`e4e95a9`](https://github.com/better-auth/better-auth/commit/e4e95a9c29a347d92f972633afc10bcbde679a60) Merge branch 'canary' into himself65/2025/09/14/prisma - [`87c7808`](https://github.com/better-auth/better-auth/commit/87c78089d3756cafda97201b297821c8faa3e76f) test: fix ### 📊 Changes **7 files changed** (+185 additions, -188 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/package.json` (+0 -3) 📝 `packages/better-auth/src/adapters/prisma-adapter/test/normal-tests/adapter.prisma.test.ts` (+10 -18) 📝 `packages/better-auth/src/adapters/prisma-adapter/test/normal-tests/get-adapter.ts` (+18 -8) 📝 `packages/better-auth/src/adapters/prisma-adapter/test/number-id-tests/adapter.prisma.number-id.test.ts` (+11 -28) 📝 `packages/better-auth/src/adapters/prisma-adapter/test/number-id-tests/get-adapter.ts` (+25 -15) 📝 `packages/better-auth/src/adapters/prisma-adapter/test/push-schema.ts` (+12 -2) 📝 `packages/better-auth/src/adapters/test.ts` (+109 -114) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Stabilizes Prisma adapter tests by isolating each run with its own SQLite DB and making schema pushes synchronous to eliminate race conditions and data leakage. - **Refactors** - Each test uses a copied dev.db (crypto UUID) with datasourceUrl override. - getAdapter is now async and returns { adapter, clear } for cleanup. - Switched to beforeEach to push schema and reset DB per suite. - Replaced async exec with execSync in pushPrismaSchema. - runAdapterTest/runNumberIdAdapterTest now non-async wrappers. - **Bug Fixes** - Removed cross-suite file-based state and watchers; no shared DB state. - Tests no longer depend on unique email prefixes; fresh DB prevents collisions. - Adjusted assertions to avoid fixed counts; created entities per test. - Reset sqlite_sequence where required in number-id tests. - Dropped the brittle “increment id by 1” assertion that caused flakes. <!-- 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-03-13 12:25:37 -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#5513