代码之家  ›  专栏  ›  技术社区  ›  asulaiman

获取错误类型错误:(0,(\u jestUtil | | | u load\u jestUtil(…))。validateCLIOptions)在运行jest时不是函数

  •  3
  • asulaiman  · 技术社区  · 8 年前

    运行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"
    }
    

    开玩笑配置。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 回复  |  直到 7 年前
        1
  •  3
  •   asulaiman    8 年前

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

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