Current behavior
Running jest still resulting in [@RNC/AsyncStorage]: NativeModule: AsyncStorage is null error.
Verisons
"dependencies": {
....
"@react-native-async-storage/async-storage": "^1.14.1",
"react": "16.13.1",
"react-native": "0.63.2",
},
"devDependencies": {
"@babel/core": "^7.11.6",
"@babel/runtime": "^7.11.2",
"@react-native-community/eslint-config": "^2.0.0",
"@testing-library/jest-native": "^4.0.1",
"babel-jest": "^26.3.0",
"eslint": "^7.12.1",
"jest": "^26.4.2",
"metro-react-native-babel-preset": "^0.63.0",
"prettier": "^2.1.2",
"react-test-renderer": "16.13.1"
}
I've tried the error steps here several times, including cleaning all build folders, rebooting afterwords but haven't had any success
• Run `react-native link @react-native-async-storage/async-storage` in the project root.
• 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
I've tried following the integration steps here without any luck. Tried implementation via __mocks__:
/mocks/@react-native-community/async-storage.js
export default from '@react-native-async-storage/async-storage/jest/async-storage-mock';
and jest.config.js:
jest.config.js
module.exports = {
preset: 'react-native',
setupFiles: ["./jest.setup.js"],
setupFilesAfterEnv: ["./node_modules/@testing-library/jest-native/extend-expect"],
};
jest.setup.js
import mockAsyncStorage from '@react-native-async-storage/async-storage/jest/async-storage-mock';
jest.mock('@react-native-async-storage/async-storage', () => mockAsyncStorage);
but I still get the same error:
● Test suite failed to run
[@RNC/AsyncStorage]: NativeModule: AsyncStorage is null.
To fix this issue try these steps:
• Run `react-native link @react-native-async-storage/async-storage` in the project root.
• 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/react-native-async-storage/issues
at Object.<anonymous> (jdsTheme/node_modules/@react-native-async-storage/async-storage/lib/commonjs/AsyncStorage.native.js:33:2)
at Object.<anonymous> (jdsTheme/node_modules/@react-native-async-storage/async-storage/lib/commonjs/index.js:6:1)
Current behavior
Running jest still resulting in
[@RNC/AsyncStorage]: NativeModule: AsyncStorage is nullerror.Verisons
I've tried the error steps here several times, including cleaning all build folders, rebooting afterwords but haven't had any success
I've tried following the integration steps here without any luck. Tried implementation via
__mocks__:/mocks/@react-native-community/async-storage.js
and
jest.config.js:jest.config.js
jest.setup.js
but I still get the same error: