Replies: 1 comment
-
@Tubring25 don't mock functions use |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Background
I'm writing unit tests for a Zustand store using Jest. The store contains an asynchronous method
fetchCartItems
that calls an API and then uses an imported utility function to process the data before updating the store.Current Behavior
The test will fail. But in some ways below it works.
getCartDetails
), I can't get the latest values inresult.current
.Question
When unit testing Zustand stores that use imported utility functions (like
getCartDetails
), is it always necessary to mock these functions?Beta Was this translation helpful? Give feedback.
All reactions