Package.json » eslint-config-react-app/jest#overrides[0]: environment key “jest/globals” is unknown

The error “package.json » eslint-config-react-app/jest#overrides[0]: environment key ‘jest/globals’ is unknown” occurs when the Jest environment configuration is not recognized by ESLint.

To resolve this error, you need to update the ESLint configuration in your package.json file. Specifically, you need to add the “jest” environment key to the overrides section of the eslintConfig object.

Here is an example of how the updated package.json file should look like:

        {
            "eslintConfig": {
                "extends": "react-app",
                "overrides": [
                    {
                        "files": ["**/*.test.js", "**/*.spec.js"],
                        "env": {
                            "jest": true
                        }
                    }
                ]
            }
        }
    

In the above example, the “jest” environment key is added to the overrides section. This tells ESLint that the specified files (in this case, any file with a .test.js or .spec.js extension) should be parsed with Jest-specific environment settings.

Leave a comment