Я получил эту ошибку uncaughtException: describe is not defined\nReferenceError: describe is not defined
при выполнении модульного тестирования с Jest js в моем приложении Nodejs. Однако все тесты по-прежнему хорошо работают с npm run test
.
. Я заметил, что после создания нового файла теста в подпапке на 2 уровня ниже папки root появилась ошибка.
Как это исправить?
дерево каталогов
...
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
...
пакет. 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/"
]
},
...
eslintr c. 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
}
}