[PR #7884] [MERGED] test(email-otp): simplify test assertions and improve error handling #15857

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7884
Author: @himself65
Created: 2/10/2026
Status: Merged
Merged: 2/10/2026
Merged by: @himself65

Base: canaryHead: himself65/2026/02/10/test


📝 Commits (1)

  • 2a3e703 test(email-otp): simplify test assertions and improve error handling

📊 Changes

1 file changed (+36 additions, -59 deletions)

View changed files

📝 packages/better-auth/src/plugins/email-otp/email-otp.test.ts (+36 -59)

📄 Description

Summary by cubic

Simplified email-otp test assertions and tightened error handling. Tests now explicitly assert BAD_REQUEST for hashed OTP and validate OTP value and length for encrypted/custom encryptor modes.

  • Refactors
    • Replaced try/catch with expect(...).rejects.toMatchObject for failure cases, asserting 400 BAD_REQUEST with code OTP_IS_HASHED_CANNOT_RETURN_THE_PLAIN_TEXT_OTP.
    • Streamlined success path: direct checks for res.otp === validOTP and length 6; removed unreachable guards and console logs.

Written for commit 2a3e703c3b. 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/7884 **Author:** [@himself65](https://github.com/himself65) **Created:** 2/10/2026 **Status:** ✅ Merged **Merged:** 2/10/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2026/02/10/test` --- ### 📝 Commits (1) - [`2a3e703`](https://github.com/better-auth/better-auth/commit/2a3e703c3b90761ca705d75e1bdda8c0b3f660a2) test(email-otp): simplify test assertions and improve error handling ### 📊 Changes **1 file changed** (+36 additions, -59 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/email-otp/email-otp.test.ts` (+36 -59) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Simplified email-otp test assertions and tightened error handling. Tests now explicitly assert BAD_REQUEST for hashed OTP and validate OTP value and length for encrypted/custom encryptor modes. - **Refactors** - Replaced try/catch with expect(...).rejects.toMatchObject for failure cases, asserting 400 BAD_REQUEST with code OTP_IS_HASHED_CANNOT_RETURN_THE_PLAIN_TEXT_OTP. - Streamlined success path: direct checks for res.otp === validOTP and length 6; removed unreachable guards and console logs. <sup>Written for commit 2a3e703c3b90761ca705d75e1bdda8c0b3f660a2. 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:16:06 -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#15857