获取错误TypeError:(0,(_ jestUtil || _load_jestUtil(...))。validateCLIOptions)在运行jest时不是函数

时间:2018-05-16 17:38:36

标签: jest

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

TypeError: (0 , (_jestUtil || _load_jestUtil(...)).validateCLIOptions) is not a function

我的目录结构:

root
-test
--spec-files
---*.js

我的包中的Dev依赖项:

"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',
};

运行:

./node_modules/.bin/jest --testPathPattern=test/spec-files/.*\\.js$

我只注意到与此类错误相关的一个问题:https://github.com/facebook/jest/issues/5740

原因似乎是有一个无效的testPathPattern,但是对我来说似乎并非如此。

1 个答案:

答案 0 :(得分:2)

将jest和jest-cli更新为以下问题解决了这个问题:

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