Jest throws an error detecting Trans component ReferenceError: renderNodes is not defined

Viewed 244

Following this documentation: https://react.i18next.com/latest/trans-component

This is the piece of code I have written inside my component that works fine on browser.

<Trans i18nKey="myKey">
        Welcome to <br /> This Space
</Trans>

Not sure if this is relevant. ButmyKey looks something like this in JSON:

myKey: Welcome to <1 /> This Space

But due to that my test cases have started faling:

 ReferenceError: renderNodes is not defined

      11 |      // this mock makes sure any components using the translate HoC receive the t function as a prop
      12 |      withTranslation: () => (Component) => (props) => <Component t={(k) => k} {...props} />,
    > 13 |      Trans: ({ children }) => renderNodes(children),
         |                               ^
      14 |      Translation: ({ children }) => children((k) => k, { i18n: {} }),
      15 |      useTranslation: () => useMock,
      16 |

      at Trans (__mocks__/react-i18next.js:13:27)

If I remove the above snippet the test cases work fine.

0 Answers
Related