【问题标题】:Cannot read property 'runCLI' of undefined in gulp-jest无法读取 gulp-jest 中未定义的属性“runCLI”
【发布时间】:2020-07-27 10:50:46
【问题描述】:

我正在尝试使用 gulp-jest 运行 jest 测试。 从 npm 安装这些包:

"gulp-jest": "^4.0.3", 
"jest-cli": "^25.3.0"

并提供了以下配置来开玩笑:

"jest": {
    "setupFilesAfterEnv": [
      "<rootDir>/jest.setup.js"
    ],
    "collectCoverage": true,
    "coverageDirectory": "./test/unit-test-coverage",
    "coverageReporters": [
      "text",
      "lcov"
    ]
  }

我在我的gulpfile.js中写了一个基本的方法,引用this link

function runJsTests() {
    process.env.NODE_ENV = 'test';
    const __dirname = "Features/Components";
    return gulp.src(__dirname).pipe(jest({
    }));
}

但是,当我运行 gulp 任务时出现以下错误:

TypeError:无法读取未定义的属性“runCLI”

【问题讨论】:

    标签: gulp jestjs gulp-jest


    【解决方案1】:

    我上周五遇到了同样的问题,为了解决它,我终于不得不降级使用 jest-cli 的版本:

    "@types/jest": "24.9.0", “笑话”:“24.9.0”, “ts-jest”:“24.3.0 "jest-cli": "24.9.0", "jest-html-reporter": "2.5.0",

    新版本 Jest-cli 上的已知错误

    -> 考虑删除所有 node_modules 和 package_lock.json!

    祝你好运;)

    【讨论】:

    • 我确认修复它。 :)
    • Jest 25 在 gulp-jest 的最新更新(超过 12 个月前)之后于 20 年 1 月发布,很可能发生了重大变化。
    猜你喜欢
    • 1970-01-01
    • 2016-12-07
    • 1970-01-01
    • 1970-01-01
    • 2021-04-30
    • 2017-03-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-07
    相关资源
    最近更新 更多