eslint throws `no-undef` errors when linting Jest test files

You do not need to add this override option and specify in which files jest should be available. Adding only env field should be enough.

.eslintrc.js:

module.exports = {
  env: {
    jest: true
  },
//...
}

Please, add the following to your .eslintrc file:

{
  "overrides": [
    {
      "files": [
        "**/*.spec.js",
        "**/*.spec.jsx"
      ],
      "env": {
        "jest": true
      }
    }
  ]
}

Had a similar problem with eslint throwing no-undef errors for my jest setup.js file with some jest.mocks in it.

Ended up fixing it by using the ESLint plugin for Jest.

After installing the plugin as a dev dependency, I merged the following into my .eslintrc config file per instructions from the plugin readme.

{
  "extends": ["plugin:jest/recommended"],
  "plugins": ["jest"]
}

Then the no-undef errors are gone.