-
Notifications
You must be signed in to change notification settings - Fork 292
Testing redux modules
In short:
Dispatch action
foo
, expect state to bebar
after some time, no matter what happened in the middle.
dispatch(resourceCreateRequest({ title: 'foo' }))
await delay(100)
expect(getList(getState())).toEqual([
{ title: 'foo' },
])
See src-example/store/resource/test.js
As you've seen on other topics, unit testing redux things is very easy, but that's often too much work, repetition and sometimes it's impossible to do TDD. In other words, it can be hard to write tests before writing actual code because tests are very coupled to their implementations.
In addition, many teams working on quickly evolving projects will prefer to not write unit tests because requirements and implementations change very fast.
Writing integration tests for redux modules is an alternative solution for that.
Special thanks to @kybarg and @protoEvangelion for helping to write this Wiki. Please, feel free to edit/create pages if you think it might be useful (also, see #33)