react-native-i18n icon indicating copy to clipboard operation
react-native-i18n copied to clipboard

Jest Error Message - TypeError: (0 , _reactNativeI18n.getLanguages) is not a function

Open SemperChen opened this issue 6 years ago • 1 comments

**1.FAIL tests\index.android.js 123 **

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 avatar Jul 02 '18 10:07 SemperChen

@SemperChen Did you try using the provided mock? https://github.com/AlexanderZaytsev/react-native-i18n/blob/master/example/src/mocks/react-native-i18n.js

zoontek avatar Jul 12 '18 15:07 zoontek