flaky test in packages/better-auth/src/cookies/cookies.test.ts #1740

Closed
opened 2026-03-13 09:00:03 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @himself65 on GitHub (Aug 20, 2025).

Originally created by @himself65 on GitHub (Aug 20, 2025).
GiteaMirror added the bug label 2026-03-13 09:00:03 -05:00
Author
Owner

@himself65 commented on GitHub (Aug 20, 2025):

afterAll is not called inside the function

@himself65 commented on GitHub (Aug 20, 2025): afterAll is not called inside the function
Author
Owner

@dosubot[bot] commented on GitHub (Aug 20, 2025):

There is currently no use of afterAll (or any teardown logic) in packages/better-auth/src/cookies/cookies.test.ts. This means any resources or state created during tests aren't explicitly cleaned up, which can lead to flaky tests—especially if getTestInstance or client allocate resources that persist between tests. To improve test reliability, consider adding an afterAll hook at the top level of your describe blocks to handle cleanup, such as closing connections or resetting state as needed. This aligns with best practices for test lifecycle management in Vitest and similar frameworks.
See code reference

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Aug 20, 2025): <!-- Answer --> There is currently no use of afterAll (or any teardown logic) in packages/better-auth/src/cookies/cookies.test.ts. This means any resources or state created during tests aren't explicitly cleaned up, which can lead to flaky tests—especially if getTestInstance or client allocate resources that persist between tests. To improve test reliability, consider adding an afterAll hook at the top level of your describe blocks to handle cleanup, such as closing connections or resetting state as needed. This aligns with best practices for test lifecycle management in Vitest and similar frameworks. [See code reference](https://github.com/better-auth/better-auth/blob/4472f679f09697d6743470cb58c4d4ee32eaa5f0/packages/better-auth/src/cookies/cookies.test.ts) <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/ceec332e-6645-40a0-8610-dc5033d9393e?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/ceec332e-6645-40a0-8610-dc5033d9393e?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/ceec332e-6645-40a0-8610-dc5033d9393e?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/ceec332e-6645-40a0-8610-dc5033d9393e?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/ceec332e-6645-40a0-8610-dc5033d9393e?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/ceec332e-6645-40a0-8610-dc5033d9393e?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/ceec332e-6645-40a0-8610-dc5033d9393e?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/4097)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1740