redux-persist
redux-persist copied to clipboard
How to test with jest and react-native?
I am building a react-native application with expo SDK36.
I am having error when using AsyncStorage, it seems that the whole tree is not rendered entirely yet because of the loading asynchronous.
Adding, the following line after the render solve the issue.
await new Promise(resolve => setTimeout(resolve, 1));
How should I test with jest and AsyncStorage properly?
Thanks and best!
Versions
- expo: sdk36
- redux: 4.0.5
- redux-persist: 6.0.0
I solved this problem by using the mock provided by the library. https://react-native-async-storage.github.io/async-storage/docs/advanced/jest#using-async-storage-mock