Test async React component with jest / enzyme
1 min readFeb 27, 2019
A quick post to give my solution to test React component that make async stuff (or need multiple render calls).
Tech stacks
- react
- jest
- enzyme
- async-wait-until
The idea
Since it’s impossible for jest/enzyme to know if your component is ready:
- data is loaded
- business algo is ok
- view is ok
I decided to add for all component a new state field: isReady(bool), so I can control if the component is ready to be tested or not.
Hence, I can wait properly.