[PR #7337] [MERGED] test(mcp): add unit tests for setup tool #15487

Closed
opened 2026-04-13 10:03:15 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7337
Author: @Paola3stefania
Created: 1/13/2026
Status: Merged
Merged: 1/15/2026
Merged by: @himself65

Base: canaryHead: test/mcp-add-unit-tests


📝 Commits (5)

  • 96f3392 feat: tests and better prompt
  • c19f551 fix: tests
  • 29a0be3 mske lint happy
  • 6492231 test(mcp): move test files from lib/ to tests/ directory
  • 22f7cf0 Merge branch 'canary' into test/mcp-add-unit-tests

📊 Changes

6 files changed (+1213 additions, -0 deletions)

View changed files

📝 packages/mcp/src/tools/setup-auth.ts (+10 -0)
packages/mcp/tests/lib/generator.test.ts (+495 -0)
packages/mcp/tests/lib/parser.test.ts (+329 -0)
packages/mcp/tests/lib/templates/database.test.ts (+153 -0)
packages/mcp/tests/lib/templates/features.test.ts (+150 -0)
packages/mcp/tests/lib/templates/frameworks.test.ts (+76 -0)

📄 Description

Summary by cubic

Add comprehensive unit tests for the MCP Better Auth setup tool and tighten the setup_auth prompt to prevent misconfiguration and reduce hallucinations. This improves confidence in generated configs across frameworks, databases, ORMs, and features.

  • Tests

    • Validate generateSetup outputs for Next.js and SvelteKit, srcDir, TypeScript/JavaScript, commands, and docs.
    • Verify database provider mapping, env vars (including DATABASE_URL and BETTER_AUTH_SECRET), and ORM adapters (none, Prisma, Drizzle).
    • Check social providers, plugins (2FA, organization, magic-link, passkey), and email/password defaults.
    • Parse existing setups to detect database, ORM, and features; computeFeatureDiff for incremental adds.
    • Cover template helpers for database config/env/commands, feature imports/setup/env, and framework paths.
  • Refactors

    • Strengthened setup_auth tool description with explicit Better Auth guidance, warnings against NextAuth/Auth.js syntax, and pointers to advanced options (uuid, cookieCache, stateless sessions, secondary storage).

Written for commit 22f7cf083b. Summary will update 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/7337 **Author:** [@Paola3stefania](https://github.com/Paola3stefania) **Created:** 1/13/2026 **Status:** ✅ Merged **Merged:** 1/15/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `test/mcp-add-unit-tests` --- ### 📝 Commits (5) - [`96f3392`](https://github.com/better-auth/better-auth/commit/96f3392a2c2c2089f04fa84dd28a30ab655bd354) feat: tests and better prompt - [`c19f551`](https://github.com/better-auth/better-auth/commit/c19f551ffe62ef3f834df5f19b211aaaf718b9a0) fix: tests - [`29a0be3`](https://github.com/better-auth/better-auth/commit/29a0be38e99666f8039821552e3027402e67534c) mske lint happy - [`6492231`](https://github.com/better-auth/better-auth/commit/6492231a1e0374c7a901db9d30a9dcab18672e1a) test(mcp): move test files from lib/ to tests/ directory - [`22f7cf0`](https://github.com/better-auth/better-auth/commit/22f7cf083b22457780562e55ed18e609af85c153) Merge branch 'canary' into test/mcp-add-unit-tests ### 📊 Changes **6 files changed** (+1213 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/mcp/src/tools/setup-auth.ts` (+10 -0) ➕ `packages/mcp/tests/lib/generator.test.ts` (+495 -0) ➕ `packages/mcp/tests/lib/parser.test.ts` (+329 -0) ➕ `packages/mcp/tests/lib/templates/database.test.ts` (+153 -0) ➕ `packages/mcp/tests/lib/templates/features.test.ts` (+150 -0) ➕ `packages/mcp/tests/lib/templates/frameworks.test.ts` (+76 -0) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Add comprehensive unit tests for the MCP Better Auth setup tool and tighten the setup_auth prompt to prevent misconfiguration and reduce hallucinations. This improves confidence in generated configs across frameworks, databases, ORMs, and features. - **Tests** - Validate generateSetup outputs for Next.js and SvelteKit, srcDir, TypeScript/JavaScript, commands, and docs. - Verify database provider mapping, env vars (including DATABASE_URL and BETTER_AUTH_SECRET), and ORM adapters (none, Prisma, Drizzle). - Check social providers, plugins (2FA, organization, magic-link, passkey), and email/password defaults. - Parse existing setups to detect database, ORM, and features; computeFeatureDiff for incremental adds. - Cover template helpers for database config/env/commands, feature imports/setup/env, and framework paths. - **Refactors** - Strengthened setup_auth tool description with explicit Better Auth guidance, warnings against NextAuth/Auth.js syntax, and pointers to advanced options (uuid, cookieCache, stateless sessions, secondary storage). <sup>Written for commit 22f7cf083b22457780562e55ed18e609af85c153. Summary will update 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-13 10:03:15 -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#15487