Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 142646

Jestjs - uncaughtException: describe is not defined\nReferenceError: describe is not defined

$
0
0

I got this error uncaughtException: describe is not defined\nReferenceError: describe is not defined while doing unit testing with Jestjs in my Nodejs app. However, all tests still run well with npm run test.

I noticed that after I made a new test file in a sub-folder 2 levels below the root folder, the error appeared.

How can I fix it?

directory tree

...
app.test.js // this doesn't cause the error
modules/
   ├── utils.js
   ├── utils.test.js // this doesn't cause the error
   ├── database
        ├── database.js
        ├── database.test.js // the error appeared after this file created
...

package.json

...
"devDependencies": {
    "eslint": "^6.8.0",
    "eslint-config-airbnb-base": "^14.0.0",
    "eslint-plugin-import": "^2.19.1",
    "eslint-plugin-jest": "^23.6.0",
    "jest": "^24.9.0",
    "jsdoc": "^3.6.3",
    "nodemon": "^2.0.2",
    "supertest": "^4.0.2"
  },
"scripts": {
    "test": "jest --watchAll --verbose",
    "start": "nodemon server.js"
  },
  "jest": {
    "testEnvironment": "node",
    "coveragePathIgnorePatterns": [
      "/node_modules/"
    ]
  },
...

eslintrc.json

{
  "env": {
    "browser": true,
    "commonjs": true,
    "es6": true,
    "jest": true
  },
  "extends": [
    "airbnb-base"
  ],
  "plugins": ["jest"],
  "globals": {
    "Atomics": "readonly",
    "SharedArrayBuffer": "readonly"
  },
  "parserOptions": {
    "ecmaVersion": 2018
  },
  "rules": {
    "no-shadow": 0
  }
}

Viewing all articles
Browse latest Browse all 142646

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>