[PR #6005] [MERGED] chore: fix incorrect error code expectation in tests #6377

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6005
Author: @GautamBytes
Created: 11/15/2025
Status: Merged
Merged: 11/17/2025
Merged by: @Bekacru

Base: canaryHead: fix/username-test-error-code


📝 Commits (2)

  • 710281f test(username): Fix incorrect error code expectation
  • d6788b8 Add explicit error code to APIError

📊 Changes

2 files changed (+5 additions, -2 deletions)

View changed files

📝 packages/better-auth/src/plugins/username/index.ts (+3 -0)
📝 packages/better-auth/src/plugins/username/username.test.ts (+2 -2)

📄 Description

This PR fixes the broken unit tests for the username plugin identified in issue #6002.

The tests were incorrectly asserting that a short username should return the error code USERNAME_IS_TOO_SHORT. However, the implementation file (index.ts) and the defined constants (error-codes.ts) correctly use USERNAME_TOO_SHORT.

This change updates the two failing assertions in username.test.ts to expect the correct error code.

Fixes #6002


Summary by cubic

Use USERNAME_TOO_SHORT consistently by fixing two test assertions and adding the explicit error code to APIError in the username plugin. Resolves #6002.

Written for commit d6788b8d7b. 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/6005 **Author:** [@GautamBytes](https://github.com/GautamBytes) **Created:** 11/15/2025 **Status:** ✅ Merged **Merged:** 11/17/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/username-test-error-code` --- ### 📝 Commits (2) - [`710281f`](https://github.com/better-auth/better-auth/commit/710281fca868a6b2f8520cfd99084762c3d98104) test(username): Fix incorrect error code expectation - [`d6788b8`](https://github.com/better-auth/better-auth/commit/d6788b8d7bf35077b6723ccacb78400a15e9c079) Add explicit error code to APIError ### 📊 Changes **2 files changed** (+5 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/username/index.ts` (+3 -0) 📝 `packages/better-auth/src/plugins/username/username.test.ts` (+2 -2) </details> ### 📄 Description This PR fixes the broken unit tests for the username plugin identified in issue #6002. The tests were incorrectly asserting that a short username should return the error code `USERNAME_IS_TOO_SHORT`. However, the implementation file (`index.ts`) and the defined constants (`error-codes.ts`) correctly use `USERNAME_TOO_SHORT`. This change updates the two failing assertions in `username.test.ts` to expect the correct error code. Fixes #6002 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Use USERNAME_TOO_SHORT consistently by fixing two test assertions and adding the explicit error code to APIError in the username plugin. Resolves #6002. <sup>Written for commit d6788b8d7bf35077b6723ccacb78400a15e9c079. 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-03-13 12:56: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#6377