Zustand state is not updating or is not reflecting in tests #2600
-
I have Zustand store set up like the above in my React app. The problem is the state change is not reflected. I guess that is why the last assertion is failing. How can I make that assertion pass? What am I doing wrong here? |
Beta Was this translation helpful? Give feedback.
Answered by
dbritto-dev
Jun 12, 2024
Replies: 1 comment 16 replies
-
@aqarain btw, I encourage you to use testing-library/user-event. Let's fix your current code, you are missing act to call any action in order to trigger a render So your code should look like this:
Note: you need to import act from testing library |
Beta Was this translation helpful? Give feedback.
16 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@aqarain here you go -> https://stackblitz.com/edit/vitejs-vite-pcch7h?file=src%2F__tests__%2FApp.test.tsx
btw, I encourage you to review our testing guide