Closed doneill closed 6 months ago
I have this same problem, only diference is that i have this problem when i'm trying execute the unit test. I'm trying execute a unit test with Jest in react native with typescript template, and the moment start the test, the problem is the next:
app_fingo@0.0.1 test jest Auth.spec.tsx
FAIL src/Test/Auth.spec.tsx ● Test suite failed to run
[@RNC/AsyncStorage]: NativeModule: AsyncStorage is null.
To fix this issue try these steps:
• Rebuild and restart the app.
• Run the packager with `--reset-cache` flag.
• If you are using CocoaPods on iOS, run `pod install` in the `ios` directory and then rebuild and re-run the app.
• If this happens while testing with Jest, check out docs how to integrate AsyncStorage with it: https://react-native-async-storage.github.io/async-storage/docs/advanced/jest
If none of these fix the issue, please open an issue on the Github repository: https://github.com/react-native-async-storage/async-storage/issues
1 | import 'react-native';
> 2 | import '@react-native-async-storage/async-storage';
| ^
at Object.<anonymous> (node_modules/@react-native-async-storage/async-storage/lib/commonjs/AsyncStorage.native.ts:23:9)
at Object.require (node_modules/@react-native-async-storage/async-storage/lib/commonjs/index.ts:1:1)
at Object.require (setupTests.js:2:1)
at tryCatch (node_modules/@babel/runtime/helpers/regeneratorRuntime.js:46:17)
at Generator.<anonymous> (node_modules/@babel/runtime/helpers/regeneratorRuntime.js:127:22)
at Generator.next (node_modules/@babel/runtime/helpers/regeneratorRuntime.js:71:21)
at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:5:24)
at _next (node_modules/@babel/runtime/helpers/asyncToGenerator.js:24:9)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.128 s
Ran all test suites matching /Auth.spec.tsx/i.
This is he file the react native reads before execute the test:
import 'react-native';
import '@react-native-async-storage/async-storage';
"jest": {
"preset": "react-native",
"setupFilesAfterEnv": ["./setupTests.js"],
"transformIgnorePatterns": [
"/node_modules/(?!react-native-element-dropdown)/"
]
},
"plugins": [
["@babel/plugin-proposal-class-properties", { "loose": true }],
["@babel/plugin-transform-classes", { "loose": false }]
]
Hey @doneill
There is no dependency on AsyncStorage in app or app dependencies
So probably one your of third-party has dependency on AsyncStorage - meaning you'll have to have AsyncStorage in your package.json, so it's probably linked.
@FaberGrisalesDev Hey, have you checked Jest integration docs?
Thanks @krizzu, I have checked third party dependencies and comes up empty. It doesn't always happen either, but after a bunch of successful runs it returns. A full clearing of Gradle/rn/watchman/pods cache mostly works, but not always, been frustrating
@doneill Actually, it looks like it's in your tests?
setupTests.js:2:1
That reference is in the comment below, I think the issue is in the hermes stack
If none of these fix the issue, please open an issue on the Github repository: https://github.com/react-native-async-storage/react-native-async-storage/issues
, js engine: hermes, stack:
Exception in native call
com.facebook.react.common.JavascriptException: Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes
Unhandled SoftException
java.lang.RuntimeException: Catalyst Instance has already disappeared: requested by FrescoModule
I meant this stacktrace log here:
at Object.
(node_modules/@react-native-async-storage/async-storage/lib/commonjs/AsyncStorage.native.ts:23:9) at Object.require (node_modules/@react-native-async-storage/async-storage/lib/commonjs/index.ts:1:1) at Object.require (setupTests.js:2:1)
Have you used AsyncStorage before? Maybe some leftovers in jest setup?
Hi @krizzu, yes i had this in my setUpTest.js
import 'react-native';
import '@react-native-async-storage/async-storage';
And the correct code in this file have to be
jest.mock('@react-native-async-storage/async-storage', () =>
require('@react-native-async-storage/async-storage/jest/async-storage-mock')
);
@krizzu No references in our app, jest or otherwise
I also get this when trying to run my app on my expo custom development build.
ERROR Error: [@RNC/AsyncStorage]: NativeModule: AsyncStorage is null.
To fix this issue try these steps:
• Rebuild and restart the app.
• Run the packager with `--reset-cache` flag.
• If you are using CocoaPods on iOS, run `pod install` in the `ios` directory and then rebuild and re-run the app.
• If this happens while testing with Jest, check out docs how to integrate AsyncStorage with it: https://react-native-async-storage.github.io/async-storage/docs/advanced/jest
Hey @doneill I'm facing same issue. in my case it is coming from Firebase. Have you found any solution for it?
This issue has been marked as stale due to inactivity. Please respond or otherwise resolve the issue within 7 days or it will be closed.
I'm facing the same issue.
This issue has been marked as stale due to inactivity. Please respond or otherwise resolve the issue within 7 days or it will be closed.
What happened?
Running an app on Android crashes with
There is no dependency on AsyncStorage in app or app dependencies
Version
N/A
What platforms are you seeing this issue on?
System Information
Steps to Reproduce
Hard to say, app has been working for years, all of a sudden this started happening. Occasionally clearing watchman cache with the following allows the app to run but never for long
I am at a loss as it intermittently happens, assuming some change to dev environment caused this or maybe this is a React Native bug, thought I would start here.