mercredi 6 juin 2018

Symbol is not a function react enzyme i18n error

When i test my react project with jest and enzyme, i encounter this problem, `TypeError: symbol is not a function

  44 | test('PROVA', () => {
> 46 |     const wrapper = mount(<I18nextProvider i18n={i18n}><MemoryRouter><LoggedSearch t={(k) => 'translate hardcoded'} userData={Artist}/></MemoryRouter></I18nextProvider>,{context});
     |                     ^
  47 |     console.log(wrapper.debug());
  48 |     wrapper.find('#ButtonSearch').simulate('click', { preventDefault() {} });
  49 |     expect(true).toBe(true)

  at setValueForProperty (../node_modules/react-dom/cjs/react-dom.development.js:2909:46)

Now this is my test

test('PROVA', () => { //const wrapper = mount(<LoggedSearch t={key=>key} userData={Artist}/>); const wrapper = mount(<I18nextProvider i18n={i18n}><MemoryRouter><LoggedSearch t={(k) => 'translate hardcoded'} userData={Artist}/></MemoryRouter></I18nextProvider>,{context}); console.log(wrapper.debug()); wrapper.find('#ButtonSearch').simulate('click', { preventDefault() {} }); expect(true).toBe(true) });

In <LoggedSearch/> the component is exported with the named export and imported in my test file as import {LoggedSearch} from "../components/LoggedSearch"; So the component should be imported pure without decoration like i18n right? . I don't understand why the test fails with this error TypeError: symbol is not a function i think it is a i18n problem because when i use shallow instead of mount it works but i can't test function with shallow. Thanks

Aucun commentaire:

Enregistrer un commentaire