rt2zz / redux-persist

persist and rehydrate a redux store
MIT License
12.96k stars 866 forks source link

How to test with jest and react-native? #1142

Open kopax opened 4 years ago

kopax commented 4 years ago

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

moriyuu commented 2 years ago

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