gulp - 无法读取 gulp-jest 中未定义的属性 'runCLI'

标签 gulp jestjs gulp-jest

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

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

并提供了以下配置来开 Jest :

"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 任务时出现以下错误:

类型错误:无法读取未定义的属性“runCLI”

最佳答案

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

"@types/jest": "24.9.0", “开 Jest ”:“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!

祝你好运;)

关于gulp - 无法读取 gulp-jest 中未定义的属性 'runCLI',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61212282/

相关文章:

node.js - 如何通过 typescript 使用 jest 配置

javascript - 异步函数的行为与我对 Jest 的预期不同

gulp - 为什么 "gulp-jest"失败并显示 : "Please run node with the --harmony flag!"?

jestjs - 使用 jest.runCLI() 运行单个测试

jestjs - Jest不能处理insertAdjacentElement吗?

javascript - TypeScript、React 和 Gulp.js - 定义 React

gulp - 如何在不丑化gulp的情况下删除评论?

node.js - 从 Visual Studio 2015 任务运行程序运行 Gulpfile 时出错

angular - 如何在 Angular 2 中设置反向代理

reactjs - 如何在测试中手动模拟 Svg?