joetidee / enzyme-react-intl

A complimentary wrapper function for use with Enzyme, when testing React components that rely on react-intl
MIT License
45 stars 14 forks source link

o.getChildContext #31

Open tahv0 opened 4 years ago

tahv0 commented 4 years ago
 FAIL  src/components/StartMenu/StartMenu.test.tsx
  ● <StartMenu /> › renders StartMenu component

    TypeError: o.getChildContext is not a function

       9 | describe('<StartMenu />', () => {
      10 |   it('renders StartMenu component', () => {
    > 11 |     const wrapper = mountWithIntl(<StartMenu toggleSettings={() => {}} />);
         |                     ^
      12 |     expect(wrapper.find('.MainMenuItem')).to.have.lengthOf(4);
      13 |   });
      14 | });

      at mountWithIntl (node_modules/enzyme-react-intl/lib/webpack:/enzyme-react-intl/src/index.js:59:25)
      at Object.it (src/components/StartMenu/StartMenu.test.tsx:11:21)
atav32 commented 4 years ago

this works for now, https://github.com/formatjs/react-intl/blob/master/docs/Testing-with-React-Intl.md#enzyme

gdollard commented 4 years ago

this works for now, https://github.com/formatjs/react-intl/blob/master/docs/Testing-with-React-Intl.md#enzyme

link is broken and no, it's not working for me.

henrikericsson commented 4 years ago

Any update on this? Getting the same error.

davisyi commented 4 years ago

I assume you and I all have this issue because of we all use react-intl v3 or up and enzyme-react-intl still uses react-intl v2. Any timeline for upgrading react-intl?

alechemy commented 1 year ago

https://github.com/formatjs/react-intl/blob/master/docs/Testing-with-React-Intl.md#enzyme

Here's the proper link: https://github.com/formatjs/formatjs/blob/main/website/docs/guides/testing-with-react-intl.md#enzyme

The solution here worked for me.