How to reference state from different slices in tests #122
Unanswered
travispomeroy
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm running into a problem where I need to reference multiple slices states inside of a test. The slice state I need is at the application level, and the test I'm writing is for a specific page within the application.
For example, i have a primary header in my app that has a dropdown. This would the equivalent to the src/app/index.tsx is the sample app provided. I would like to store the selected value of the dropdown in redux, and have created a slice to do so.
Now I have a page within my application, that takes different actions based on the selection within the dropdown in the primary header. This page has its own slice as well. So now my RootState has a field for the application level data and page level data.
This works great, however, I'm struggling trying to figure out how to test the page in an isolated way, when dispatching events on application state.
Below is my current test, but it is failing because I think the ApplicationState is not loading in the store that used in the test. So even though I'm dispatching events, the store is not getting updated because it only knows about the PageState, I'm assuming.
Would you be able to provide any direction on how to update the below test to allow the ApplicationState to load in the store in addition to the PageState?
Beta Was this translation helpful? Give feedback.
All reactions