i18next: TypeError: _i18next2.default.use is not a function
Hello,
I’m trying to setup testing suite with jest+ vue-test-utils or karma+jasmine+vue-test-utils (both throw same errors).
Is this problem with library or not ? Any idea how this can be solved ?
TypeError: _i18next2.default.use is not a function
34 |
35 | i18next
> 36 | .use(Locize)
37 | .init(i18nextOptions);
38 |
39 | export default new VueI18Next(i18next);
at Object.<anonymous> (src/app/locale/i18n.js:36:1)
at Object.<anonymous> (src/app/store/modules/account/mutations.js:6:13)
at Object.<anonymous> (src/app/store/modules/account/index.js:7:18)
at Object.<anonymous> (src/app/store/index.js:17:16) at src/app/pages/home/index/index.vue:24:14
at Object.<anonymous> (src/app/pages/home/index/index.vue:230:3)
at Object.<anonymous> (test/unit/home.spec.js:10:14)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 25 (12 by maintainers)
seems the vue-i18next depends on the event emitter build in…you will have to mock that too
evetual a good idea to ask there
@panter/vue-i18nextwhat functions on i18next are needed to have a complete mockI’m also getting same error : _i18next.default.addResourceBundle is not a function
Although, My error was resolved via adding this two changes.
jest.mock("i18next", () => ({ addResourceBundle: jest.fn(), }));And woooo… It works!!
you can mock away i18next completely i think -> just provide a function
ton it returning first prop and noops for the restnot really…just do a console.log of i18next…seems to be import related…
not had such an issue ever…hard to help without having options to debug…but must be related to import.