How do you test Redux applications?

Answer

Testing Redux follows a layered strategy. Reducer tests: pure functions — easiest to test: it("increments count", () => { const state = { count: 0 }; const action = increment(); expect(reducer(state, action)).toEqual({ count: 1 }); }). Selector tests: pass mock state: expect(selectActiveUsers({ users: mockUsers })).toHaveLength(2). Thunk tests: use configureStore with mock reducers: dispatch the thunk and check dispatched actions. Or use a mock axios and test against expected state. RTK Query tests: use setupServer from msw (Mock Service Worker) to intercept API calls, then use RTK Query's testing utilities. Component integration tests: wrap components with a real or mock store: render(<Provider store={testStore}><MyComponent /></Provider>). Use renderWithProviders helper. Test philosophy: test behavior not implementation. Prefer integration tests (component + store) over isolated unit tests for each layer — they catch more real bugs and are less brittle to refactoring.