Flaky tests fixed with improved mock isolation
Unit tests that were intermittently failing due to test isolation issues have been stabilized through improved mock isolation, giving developers more confidence in CI results.
Unit tests sometimes fail for reasons unrelated to code changes — shared state leaks between tests, incomplete mock teardown, or race conditions in async operations. When tests are flaky, developers lose trust in the suite and start ignoring failures. This PR tightens up test isolation so tests run independently and reliably. The approach focuses on proper mock lifecycle management, ensuring mocks are reset completely between test cases. An initial attempt to force Turbo cache invalidation for API coverage tests was explored but ultimately reverted in favor of the isolation-focused approach.
View Original GitHub Description
Summary
- Fix flaky unit tests by adding correct isolation
Related Linear tickets, Github issues, and Community forum posts
Review / Merge checklist
- PR title and summary are descriptive. (conventions) <!-- **Remember, the title automatically goes into the changelog. Use `(no-changelog)` otherwise.** -->
- Docs updated or follow-up ticket created.
- Tests included. <!-- A bug is not considered fixed, unless a test is added to prevent it from happening again. A feature is not complete without tests. -->
- PR Labeled with
Backport to Beta,Backport to Stable, orBackport to v1(if the PR is an urgent fix that needs to be backported)