Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(react): fix React testing warnings with proper act() usage #336

Merged
merged 1 commit into from
Jan 17, 2025

Conversation

drichar
Copy link
Collaborator

@drichar drichar commented Jan 17, 2025

Description

This PR fixes React testing warnings by properly handling state updates and effects in the test suite. These warnings occurred because some state updates were happening outside of act() wrappers, which React uses to ensure tests run in a way that matches real rendering.

Details

  • Make test functions async where needed
  • Wrap component renders in act(async () => {...})
  • Wrap state updates in act(async () => {...})
  • Add small delays where needed for effects to complete
  • Simplify store state change test assertions
  • Fix setActive and setActiveAccount test implementation

Fix React testing warnings by properly wrapping state updates and effects
in `act()` with `async`/`await`. This ensures all state updates and side
effects complete before making assertions.

- Make test functions async where needed
- Wrap renders and state updates in `act(async () => {...})`
- Add small delays where needed for effects to complete
- Fix `setActive` and `setActiveAccount` test implementation
- Simplify store state change test assertions
@drichar drichar merged commit 6bcfc67 into main Jan 17, 2025
1 check passed
@drichar drichar deleted the test/react-act-async-await branch January 17, 2025 04:13
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.

1 participant