getInitialState
Returns the initial state of a reducer.
Details
getInitialState
asks the passed reducer for its initial state by calling it with an undefined
state and a dummy action, just as a Redux store would.
This helper is mainly intended for tests, where it can help improve readabilty. For example, when making assertions about a reducer's initial state, getInitialState(reducer)
is more expressive than something like reducer(undefined, { type: '' })
.
Examples
Basic usage:
Usage in Jest:
See Also
Testing guide
Last updated