Skip to content

Linking when using kotlin not possible? NativeModule.RCTAsyncStorage is null. #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rpuls opened this issue Mar 29, 2019 · 5 comments
Closed

Comments

@rpuls
Copy link

rpuls commented Mar 29, 2019

You want to:

Since I was getting warnings that the react-native asyncStorags is becomming deprecated and is moved (here) to individual package, I decided to install... This seems to be a pain in the a** every time, was also troubleful when I installed RCs' extracted WebView. (grumpy sorry)....

Anyway, this time I am stuck with failing jest tests that I have not been able to resolve after 24 hours of trying. Have had multiple colleges passing by as well as asked for help on SO.
Please check this link for further issue despription: https://stackoverflow.com/questions/55418910/jest-test-fails-after-installing-react-native-async-storage

I did manual linking since react-native link will not work for this module as MainApplication.java does not exist when using kotlin. Instead I have MainApplication.kt

After linking manually the async functions are working just fine. Except the jest test are unable to find the module.
@RNCommunity/AsyncStorage: NativeModule.RCTAsyncStorage is null.

Any suggestions?

@tbergquist-godaddy
Copy link

Hi, I answered your post on stackoverflow.

Also see our repo if you like.

@krizzu
Copy link
Member

krizzu commented Mar 31, 2019

@rpuls Hey, thanks for reaching out.

I'm on the way of writing mocks to be used with Jest. I'm aiming to finish in few days, alongside with docs explaining how to test it.

For now, to get by this error, you'd have to mock NativeModule from react-native, to return either of those modules.

Also, about linking with Kotlin - this is more a question to CLI team, as it involves linking a module.

@rpuls
Copy link
Author

rpuls commented Apr 1, 2019

@krizzu

I'm on the way of writing mocks to be used with Jest. I'm aiming to finish in few days, alongside with docs explaining how to test it.

For now, to get by this error, you'd have to mock NativeModule from react-native, to return either of those modules.

Hey thanks for replying! I found a solution that worked. Tried many different ways of mocking the AsyncStorage. 4th attempt worked like a charm. I updated my stackoverflow with the solution https://stackoverflow.com/questions/55418910/jest-test-fails-after-installing-react-native-async-storage/55421364

@krizzu
Copy link
Member

krizzu commented Apr 7, 2019

Hey @rpuls,

I've created #53, so future cases with Jest testing will be easier.

thanks.

@krizzu
Copy link
Member

krizzu commented Apr 11, 2019

v1.3.0 released, please check it out 🙏

@krizzu krizzu closed this as completed Apr 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants