Skip to content

Conversation

@yogeshchoudhary147
Copy link
Contributor

@yogeshchoudhary147 yogeshchoudhary147 commented Jan 27, 2026

Summary

Fixes intermittent test failure in should provide a logout method by waiting for authentication to complete before calling logout.

Changes

Added isAuthenticated check to the existing waitFor block to ensure the provider has finished initializing before testing logout behavior.

await waitFor(() => {
  expect(result.current.logout).toBeInstanceOf(Function);
  expect(result.current.isAuthenticated).toBe(true);
});

The test was only waiting for the logout function to exist before calling it,
but not waiting for authentication to complete first. This caused intermittent
failures when the test called logout() while isAuthenticated was still false.

Fixed by waiting for both logout function AND authentication state in the
same waitFor block, following the pattern used in other logout tests.
@yogeshchoudhary147 yogeshchoudhary147 requested a review from a team as a code owner January 27, 2026 11:11
@yogeshchoudhary147 yogeshchoudhary147 merged commit 41fdadc into main Jan 27, 2026
10 checks passed
@yogeshchoudhary147 yogeshchoudhary147 deleted the fix-flaky-logout-test branch January 27, 2026 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants