You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Redux team does not recommend testing using this library. Instead, see our [docs](https://redux.js.org/usage/writing-tests) for recommended practices, using a real store.
4
+
5
+
Testing with a mock store leads to potentially confusing behaviour, such as state not updating when actions are dispatched. Additionally, it's a lot less useful to assert on the actions dispatched rather than the observable state changes.
6
+
7
+
You can test the entire combination of action creators, reducers, and selectors in a single test, for example:
8
+
9
+
```js
10
+
it('should add a todo', () => {
11
+
conststore=makeStore() // a user defined reusable store factory
12
+
13
+
store.dispatch(addTodo('Use Redux'))
14
+
15
+
expect(selectTodos(store.getState())).toEqual([
16
+
{ text:'Use Redux', completed:false }
17
+
])
18
+
})
19
+
```
20
+
21
+
This avoids common pitfalls of testing each of these in isolation, such as mocked state shape becoming out of sync with the actual application.
* The Redux team does not recommend using this package for testing. Instead, check out our {@link https://redux.js.org/recipes/writing-tests testing docs} to learn more about testing Redux code.
10
+
*
11
+
* Testing with a mock store leads to potentially confusing behaviour, such as state not updating when actions are dispatched. Additionally, it's a lot less useful to assert on the actions dispatched rather than the observable state changes.
12
+
*
13
+
* You can test the entire combination of action creators, reducers, and selectors in a single test, for example:
14
+
* ```js
15
+
* it("should add a todo", () => {
16
+
* const store = makeStore(); // a user defined reusable store factory
0 commit comments