react-native-i18n
react-native-i18n copied to clipboard
Jest Error Message - TypeError: (0 , _reactNativeI18n.getLanguages) is not a function
**1.FAIL tests\index.android.js **
TypeError: (0 , _reactNativeI18n.getLanguages) is not a function at WelcomePage.componentWillMount...
2.tests\index.js
jest.mock('react-native-i18n', () => {
const i18njs = require('i18n-js');
const en = require('../../../js/i18n/locales/en');
i18njs.translations = {en};
return {
t: jest.fn((k, o) => i18njs.t(k, o)),
};
});
it("renders Regular ActionSheet", () => {
renderer.create(
<Root/>
)
})
3.index.js
getLanguages().then(languages => {
...
})
@SemperChen Did you try using the provided mock? https://github.com/AlexanderZaytsev/react-native-i18n/blob/master/example/src/mocks/react-native-i18n.js