Every time I run jest this error pops up
console.warn node_modules/react-native-i18n/index.js:14
react-native-i18n module is not correctly linked
It works fine in both iOS and Android though. Any reason why it shows up?
Does it work fine for english only?
Same here.
console.warn node_modules/react-native-i18n/index.js:11
react-native-i18n module is not correctly linked
Using version 2.0.12:
react-native-i18n@^2.0.12:
version "2.0.12"
resolved "https://registry.yarnpkg.com/react-native-i18n/-/react-native-i18n-2.0.12.tgz#4a503cc73b2fe55e8518f6d4a1340d3b449d8d1a"
dependencies:
i18n-js "^3.0.3"
+1
Check issue #173
You have to mock every native module if you want to test it
Did you mock the module like https://github.com/AlexanderZaytsev/react-native-i18n/blob/master/example/src/__mocks__/react-native-i18n.js ?
I have this warning when running the app (without any test framework). Is there anything I could do to fix it?
@zoontek I must be misunderstanding. Why would I mock i18n-js?
import I18nJs from 'i18n-js';
I18nJs.locale = 'en'; // a locale from your available translations
export const getLanguages = (): Promise<string[]> => Promise.resolve(['en']);
export default I18nJs;
@AndrewHenderson This package only get the language of the device and return an instance of i18n-js.
Hi Guys!
This fixed the warning for me
Create a global mock for the library in the root of your project --> __mocks__/react-native-i18n.js
This will load the mock instead of the library when running the code under testing.
react-native-i18n.js should look like this
export default {
t: jest.fn(()=> 'mocked translation')
}
For more info read this https://jestjs.io/docs/en/manual-mocks.html#mocking-node-modules
your solution rendered all my snap test failed ._.
Most helpful comment
I have this warning when running the app (without any test framework). Is there anything I could do to fix it?