From 53b554de29b0264eb28161f291fc7949dcf8d2e0 Mon Sep 17 00:00:00 2001 From: Bereket Engida Date: Sat, 25 Oct 2025 15:46:50 -0700 Subject: [PATCH] test: update sign up tests to use rejects to throw instead --- .../src/api/routes/sign-up.test.ts | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/packages/better-auth/src/api/routes/sign-up.test.ts b/packages/better-auth/src/api/routes/sign-up.test.ts index 1e7eec64ac..ba06080e1a 100644 --- a/packages/better-auth/src/api/routes/sign-up.test.ts +++ b/packages/better-auth/src/api/routes/sign-up.test.ts @@ -132,20 +132,16 @@ describe("sign-up with custom fields", async (it) => { }); it("should not allow user to set the field that is set to input: false", async () => { - const res = await auth.api.signUpEmail({ - body: { - email: "input-false@test.com", - password: "password", - name: "Input False Test", - //@ts-expect-error - role: "admin", - }, - }); - const session = await auth.api.getSession({ - headers: new Headers({ - authorization: `Bearer ${res.token}`, + await expect( + auth.api.signUpEmail({ + body: { + email: "input-false@test.com", + password: "password", + name: "Input False Test", + //@ts-expect-error + role: "admin", + }, }), - }); - expect(session?.user.role).toBeNull(); + ).rejects.toThrow("role is not allowed to be set"); }); });