redux-persist icon indicating copy to clipboard operation
redux-persist copied to clipboard

How to test with jest and react-native?

Open kopax opened this issue 5 years ago • 1 comments

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

kopax avatar Jan 06 '20 21:01 kopax

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

moriyuu avatar Mar 01 '22 13:03 moriyuu