Search code examples
node.jsjestjsinternationalizationnode-modulests-jest

TypeError: logWarnFn is not a function - jest - nodejs


Getting this error when I try to run my jest test cases on my nodejs server

TypeError: logWarnFn is not a function

      18 |     });
      19 |     if (!user) {
    > 20 |       throw new createHttpError.BadRequest(i18n.__("user_not_exist"));
         |                                                 ^
      21 |     }

I am using i18n module for translation. Not sure why jest is not picking it up.


Solution

  • Mocking the i18n module seems to solve this issue.

    jest.mock("i18n")