Jestjs Getting error TypeError:(0,(_jestUtil | | | _load _jestUtil(…)。validateCLIOptions)在运行jest时不是函数

Jestjs Getting error TypeError:(0,(_jestUtil | | | _load _jestUtil(…)。validateCLIOptions)在运行jest时不是函数,jestjs,Jestjs,试图在运行jest时确定此错误的来源: TypeError: (0 , (_jestUtil || _load_jestUtil(...)).validateCLIOptions) is not a function 我的目录结构: root -test --spec-files ---*.js 我的软件包中的开发人员依赖项: "devDependencies": { "babel-eslint": "6.1.2", "babel-jest": "22.1.0", "chai": "3.5.

试图在运行jest时确定此错误的来源:

TypeError: (0 , (_jestUtil || _load_jestUtil(...)).validateCLIOptions) is not a function
我的目录结构:

root
-test
--spec-files
---*.js
我的软件包中的开发人员依赖项:

"devDependencies": {
"babel-eslint": "6.1.2",
"babel-jest": "22.1.0",
"chai": "3.5.0",
"chai-as-promised": "5.3.0",
"eslint": "2.13.1",
"eslint-config-airbnb": "6.2.0",
"eslint-plugin-react": "4.3.0",
"jest": "22.1.4",
"jest-cli": "22.1.4",
"jest-runner-eslint": "0.4.0",
"nodemon": "1.12.1",
"nyc": "11.2.1",
"sinon": "2.4.1",
"snyk": "1.69.10",
"spec-xunit-file": "0.0.1-3",
"supertest": "1.2.0",
"supertest-as-promised": "3.2.0",
"xunit-file": "0.0.9"
}
jest.config.js:

module.exports = {
estPathIgnorePatterns: [
'<rootDir>/bower_components/',
'<rootDir>/node_modules/',
'<rootDir>/gulp-tasks/',
],
testMatch: ['<rootDir>/test/spec-files/*.js'],
globalSetup: '<rootDir>/test/setup.js',
};
我只注意到一个与此类错误相关的问题:


原因似乎是testPathPattern无效,但对我来说似乎不是这样

将jest和jest cli更新为以下版本修复了该问题:

"jest": "22.4.4",
"jest-cli": "22.4.4",

使用“jest”:“^26.4.2”、“jest cli”:“^26.4.2”获取错误,`不完全相同,但我遇到了类似的错误,必须
rm-rf node_模块
,然后使用
Warn安装重新安装
。从那以后就不是问题了。不知道为什么,但你可以先试试。
"jest": "22.4.4",
"jest-cli": "22.4.4",