Javascript Jestjs-未捕获异常:未定义描述\n引用错误:未定义描述

Javascript Jestjs-未捕获异常:未定义描述\n引用错误:未定义描述,javascript,node.js,unit-testing,jestjs,Javascript,Node.js,Unit Testing,Jestjs,在我的Nodejs应用程序中使用Jestjs进行单元测试时,我发现此错误uncaughtException:descripe未定义\nReferenceError:descripe未定义。然而,所有的测试在npm-runtest中仍然运行良好 我注意到在根文件夹下2层的子文件夹中创建了一个新的测试文件后,出现了错误 我怎样才能修好它 目录树 package.json eslintrc.json 原来是因为 排除数据库文件夹下index.js中的所有.test.js文件修复了该问题: const

在我的Nodejs应用程序中使用Jestjs进行单元测试时,我发现此错误
uncaughtException:descripe未定义\nReferenceError:descripe未定义。然而,所有的测试在
npm-runtest
中仍然运行良好

我注意到在根文件夹下2层的子文件夹中创建了一个新的测试文件后,出现了错误

我怎样才能修好它

目录树

package.json

eslintrc.json

原来是因为

排除数据库文件夹下index.js中的所有.test.js文件修复了该问题:

const requireDirectory = require('require-directory');

const exclude = (path) => path.includes('test.js');
module.exports = requireDirectory(module, { exclude });

database.test.js
看起来像什么?它只是一个示例测试
description('database test',()=>{It('Should run the test',()=>{expect(true).toBe(true);};})
...
"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/"
    ]
  },
...
{
  "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
  }
}
const requireDirectory = require('require-directory');

const exclude = (path) => path.includes('test.js');
module.exports = requireDirectory(module, { exclude });