Easily test reducers by passing a state, action and expected result.
yarn install redux-reducer-test-plan
To run the test just pass the reducer into the function and then set the state, action and expected result. Finally to execute the test call .run()
const TestReducer = require("redux-reducer-test-plan")
describe("Some test", () => {
it("some test case", () => {
TestReducer(reducer)
.state({ a: true })
.action({ type: "ACTION" })
.expect({ a: false })
.run()
})
})
.expect
can be a value or a function. If it is a function is calls the passing function with following values:
result
and prevState