jest is undefined - in __mocks__ folders

Viewed 235

I have a file src/api/__mocks__/api-call.js:

module.exports = jest.fn(
  (method, endpointPath, queryParams, data, options = {}) => {
    if (method === 'GET') {
      return {
        data: [],
        total: 99,
      };
    }
  }
);

ESLint is complaining that "jest is undefined", yet this doesn't happen in my actual __tests__ folder for some reason.

In my project's .eslintrc.js file, I added this:

env: {
  jest: true,
},

and this seems to have fixed it. Is this fine or is there a better way?

0 Answers
Related